mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Merge pull request #1951 from thoughtbot/bb-erb
Use ERB to pull conf files into app
This commit is contained in:
commit
884346cbea
3 changed files with 14 additions and 1 deletions
|
@ -63,7 +63,7 @@ class GlobalSetting
|
||||||
end
|
end
|
||||||
|
|
||||||
def read
|
def read
|
||||||
File.read(@file).split("\n").each do |line|
|
ERB.new(File.read(@file)).result().split("\n").each do |line|
|
||||||
if line =~ /([a-z_]+)\s*=\s*(\"([^\"]*)\"|\'([^\']*)\'|[^#]*)/
|
if line =~ /([a-z_]+)\s*=\s*(\"([^\"]*)\"|\'([^\']*)\'|[^#]*)/
|
||||||
@data[$1.strip.to_sym] = ($4 || $3 || $2).strip
|
@data[$1.strip.to_sym] = ($4 || $3 || $2).strip
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#
|
#
|
||||||
# DO NOT EDIT THIS FILE
|
# DO NOT EDIT THIS FILE
|
||||||
# If you need to make changes create a file called discourse.conf in this directory with your changes
|
# If you need to make changes create a file called discourse.conf in this directory with your changes
|
||||||
|
# On inport this file will be imported using ERB
|
||||||
#
|
#
|
||||||
|
|
||||||
# Discourse supports multiple mechanisms for production config.
|
# Discourse supports multiple mechanisms for production config.
|
||||||
|
|
|
@ -31,4 +31,16 @@ describe GlobalSetting::FileProvider do
|
||||||
f.unlink
|
f.unlink
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "uses ERB" do
|
||||||
|
f = Tempfile.new('foo')
|
||||||
|
f.write("a = <%= 500 %> # this is a comment\n")
|
||||||
|
f.close
|
||||||
|
|
||||||
|
provider = GlobalSetting::FileProvider.from(f.path)
|
||||||
|
|
||||||
|
provider.lookup(:a,"").should == 500
|
||||||
|
|
||||||
|
f.unlink
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue