Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

It can use erb tag on configuration.yml. #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/redmine/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def with(settings)
def load_from_yaml(filename, env)
yaml = nil
begin
yaml = YAML::load_file(filename)
body = File.read(filename)
yaml = YAML::load(Erubis::Eruby.new(body).evaluate)
rescue ArgumentError
$stderr.puts "Your Redmine configuration file located at #{filename} is not a valid YAML file and could not be loaded."
exit 1
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/configuration/erb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
default:
somesetting: <%= ENV['somesetting'] %>
6 changes: 6 additions & 0 deletions test/unit/lib/redmine/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def test_overrides
assert_equal 'bar', @conf['somesetting']
end

def test_use_erb
ENV['somesetting'] = 'foobar'
load_conf('erb.yml', 'test')
assert_equal ENV['somesetting'], @conf['somesetting']
end

def test_with
load_conf('default.yml', 'test')
assert_equal 'foo', @conf['somesetting']
Expand Down