config 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -6
- data/README.md +62 -63
- data/config.gemspec +15 -14
- data/lib/config.rb +13 -9
- data/lib/config/compatibility.rb +1 -1
- data/lib/config/{engine.rb → integrations/rails/engine.rb} +0 -0
- data/lib/config/{integration/rails.rb → integrations/rails/railtie.rb} +0 -0
- data/lib/config/{integration → integrations}/sinatra.rb +0 -0
- data/lib/config/options.rb +7 -2
- data/lib/config/version.rb +1 -1
- data/lib/generators/config/templates/config.rb +6 -2
- metadata +27 -364
- data/.codeclimate.yml +0 -6
- data/.gitignore +0 -14
- data/.rspec +0 -2
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -23
- data/Appraisals +0 -15
- data/Gemfile +0 -6
- data/Rakefile +0 -42
- data/gemfiles/rails_3.gemfile +0 -7
- data/gemfiles/rails_4.1.gemfile +0 -7
- data/gemfiles/rails_4.2.gemfile +0 -7
- data/gemfiles/rails_4.gemfile +0 -7
- data/lib/config/railtie.rb +0 -9
- data/spec/app/rails_3/Rakefile +0 -7
- data/spec/app/rails_3/app/assets/javascripts/application.js +0 -13
- data/spec/app/rails_3/app/assets/stylesheets/application.css +0 -13
- data/spec/app/rails_3/app/controllers/application_controller.rb +0 -3
- data/spec/app/rails_3/app/helpers/application_helper.rb +0 -2
- data/spec/app/rails_3/app/models/.gitkeep +0 -0
- data/spec/app/rails_3/app/views/layouts/application.html.erb +0 -14
- data/spec/app/rails_3/bin/bundle +0 -3
- data/spec/app/rails_3/bin/rails +0 -4
- data/spec/app/rails_3/bin/rake +0 -4
- data/spec/app/rails_3/config.ru +0 -4
- data/spec/app/rails_3/config/application.rb +0 -29
- data/spec/app/rails_3/config/boot.rb +0 -5
- data/spec/app/rails_3/config/database.yml +0 -25
- data/spec/app/rails_3/config/environment.rb +0 -5
- data/spec/app/rails_3/config/environments/development.rb +0 -42
- data/spec/app/rails_3/config/environments/production.rb +0 -72
- data/spec/app/rails_3/config/environments/test.rb +0 -42
- data/spec/app/rails_3/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/app/rails_3/config/initializers/inflections.rb +0 -15
- data/spec/app/rails_3/config/initializers/mime_types.rb +0 -5
- data/spec/app/rails_3/config/initializers/secret_token.rb +0 -7
- data/spec/app/rails_3/config/initializers/session_store.rb +0 -8
- data/spec/app/rails_3/config/initializers/wrap_parameters.rb +0 -14
- data/spec/app/rails_3/config/locales/en.yml +0 -5
- data/spec/app/rails_3/config/routes.rb +0 -2
- data/spec/app/rails_3/config/settings.yml +0 -7
- data/spec/app/rails_3/db/.gitkeep +0 -0
- data/spec/app/rails_3/public/404.html +0 -26
- data/spec/app/rails_3/public/422.html +0 -26
- data/spec/app/rails_3/public/500.html +0 -25
- data/spec/app/rails_3/script/rails +0 -6
- data/spec/app/rails_4.1/Rakefile +0 -6
- data/spec/app/rails_4.1/app/assets/javascripts/application.js +0 -13
- data/spec/app/rails_4.1/app/assets/stylesheets/application.css +0 -15
- data/spec/app/rails_4.1/app/controllers/application_controller.rb +0 -5
- data/spec/app/rails_4.1/app/helpers/application_helper.rb +0 -2
- data/spec/app/rails_4.1/app/models/.keep +0 -0
- data/spec/app/rails_4.1/app/views/layouts/application.html.erb +0 -14
- data/spec/app/rails_4.1/bin/bundle +0 -3
- data/spec/app/rails_4.1/bin/rails +0 -4
- data/spec/app/rails_4.1/bin/rake +0 -4
- data/spec/app/rails_4.1/config.ru +0 -4
- data/spec/app/rails_4.1/config/application.rb +0 -27
- data/spec/app/rails_4.1/config/boot.rb +0 -5
- data/spec/app/rails_4.1/config/database.yml +0 -25
- data/spec/app/rails_4.1/config/environment.rb +0 -5
- data/spec/app/rails_4.1/config/environments/development.rb +0 -42
- data/spec/app/rails_4.1/config/environments/production.rb +0 -88
- data/spec/app/rails_4.1/config/environments/test.rb +0 -44
- data/spec/app/rails_4.1/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/app/rails_4.1/config/initializers/cookies_serializer.rb +0 -3
- data/spec/app/rails_4.1/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/app/rails_4.1/config/initializers/inflections.rb +0 -16
- data/spec/app/rails_4.1/config/initializers/mime_types.rb +0 -4
- data/spec/app/rails_4.1/config/initializers/session_store.rb +0 -3
- data/spec/app/rails_4.1/config/initializers/wrap_parameters.rb +0 -14
- data/spec/app/rails_4.1/config/locales/en.yml +0 -23
- data/spec/app/rails_4.1/config/routes.rb +0 -2
- data/spec/app/rails_4.1/config/secrets.yml +0 -22
- data/spec/app/rails_4.1/config/settings.yml +0 -7
- data/spec/app/rails_4.1/db/.keep +0 -0
- data/spec/app/rails_4.1/public/404.html +0 -67
- data/spec/app/rails_4.1/public/422.html +0 -67
- data/spec/app/rails_4.1/public/500.html +0 -66
- data/spec/app/rails_4.2/Rakefile +0 -6
- data/spec/app/rails_4.2/app/assets/images/.keep +0 -0
- data/spec/app/rails_4.2/app/assets/javascripts/application.js +0 -16
- data/spec/app/rails_4.2/app/assets/stylesheets/application.css +0 -15
- data/spec/app/rails_4.2/app/controllers/application_controller.rb +0 -5
- data/spec/app/rails_4.2/app/controllers/concerns/.keep +0 -0
- data/spec/app/rails_4.2/app/helpers/application_helper.rb +0 -2
- data/spec/app/rails_4.2/app/mailers/.keep +0 -0
- data/spec/app/rails_4.2/app/models/.keep +0 -0
- data/spec/app/rails_4.2/app/models/concerns/.keep +0 -0
- data/spec/app/rails_4.2/app/views/layouts/application.html.erb +0 -14
- data/spec/app/rails_4.2/bin/bundle +0 -3
- data/spec/app/rails_4.2/bin/rails +0 -8
- data/spec/app/rails_4.2/bin/rake +0 -8
- data/spec/app/rails_4.2/bin/setup +0 -29
- data/spec/app/rails_4.2/bin/spring +0 -15
- data/spec/app/rails_4.2/config.ru +0 -4
- data/spec/app/rails_4.2/config/application.rb +0 -31
- data/spec/app/rails_4.2/config/boot.rb +0 -3
- data/spec/app/rails_4.2/config/database.yml +0 -25
- data/spec/app/rails_4.2/config/environment.rb +0 -5
- data/spec/app/rails_4.2/config/environments/development.rb +0 -41
- data/spec/app/rails_4.2/config/environments/production.rb +0 -79
- data/spec/app/rails_4.2/config/environments/test.rb +0 -42
- data/spec/app/rails_4.2/config/initializers/assets.rb +0 -11
- data/spec/app/rails_4.2/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/app/rails_4.2/config/initializers/cookies_serializer.rb +0 -3
- data/spec/app/rails_4.2/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/app/rails_4.2/config/initializers/inflections.rb +0 -16
- data/spec/app/rails_4.2/config/initializers/mime_types.rb +0 -4
- data/spec/app/rails_4.2/config/initializers/session_store.rb +0 -3
- data/spec/app/rails_4.2/config/initializers/wrap_parameters.rb +0 -14
- data/spec/app/rails_4.2/config/locales/en.yml +0 -23
- data/spec/app/rails_4.2/config/routes.rb +0 -56
- data/spec/app/rails_4.2/config/secrets.yml +0 -22
- data/spec/app/rails_4.2/config/settings.yml +0 -7
- data/spec/app/rails_4.2/db/seeds.rb +0 -7
- data/spec/app/rails_4.2/public/404.html +0 -67
- data/spec/app/rails_4.2/public/422.html +0 -67
- data/spec/app/rails_4.2/public/500.html +0 -66
- data/spec/app/rails_4.2/public/favicon.ico +0 -0
- data/spec/app/rails_4.2/public/robots.txt +0 -5
- data/spec/app/rails_4/Rakefile +0 -6
- data/spec/app/rails_4/app/assets/javascripts/application.js +0 -13
- data/spec/app/rails_4/app/assets/stylesheets/application.css +0 -13
- data/spec/app/rails_4/app/controllers/application_controller.rb +0 -5
- data/spec/app/rails_4/app/helpers/application_helper.rb +0 -2
- data/spec/app/rails_4/app/models/.keep +0 -0
- data/spec/app/rails_4/app/views/layouts/application.html.erb +0 -14
- data/spec/app/rails_4/bin/bundle +0 -3
- data/spec/app/rails_4/bin/rails +0 -4
- data/spec/app/rails_4/bin/rake +0 -4
- data/spec/app/rails_4/config.ru +0 -4
- data/spec/app/rails_4/config/application.rb +0 -27
- data/spec/app/rails_4/config/boot.rb +0 -5
- data/spec/app/rails_4/config/database.yml +0 -25
- data/spec/app/rails_4/config/environment.rb +0 -5
- data/spec/app/rails_4/config/environments/development.rb +0 -34
- data/spec/app/rails_4/config/environments/production.rb +0 -85
- data/spec/app/rails_4/config/environments/test.rb +0 -41
- data/spec/app/rails_4/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/app/rails_4/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/app/rails_4/config/initializers/inflections.rb +0 -16
- data/spec/app/rails_4/config/initializers/mime_types.rb +0 -5
- data/spec/app/rails_4/config/initializers/secret_token.rb +0 -12
- data/spec/app/rails_4/config/initializers/session_store.rb +0 -3
- data/spec/app/rails_4/config/initializers/wrap_parameters.rb +0 -14
- data/spec/app/rails_4/config/locales/en.yml +0 -23
- data/spec/app/rails_4/config/routes.rb +0 -2
- data/spec/app/rails_4/config/settings.yml +0 -7
- data/spec/app/rails_4/db/.keep +0 -0
- data/spec/app/rails_4/public/404.html +0 -58
- data/spec/app/rails_4/public/422.html +0 -58
- data/spec/app/rails_4/public/500.html +0 -57
- data/spec/config_spec.rb +0 -317
- data/spec/fixtures/bool_override/config1.yml +0 -2
- data/spec/fixtures/bool_override/config2.yml +0 -2
- data/spec/fixtures/custom_types/hash.yml +0 -7
- data/spec/fixtures/deep_merge/config1.yml +0 -28
- data/spec/fixtures/deep_merge/config2.yml +0 -28
- data/spec/fixtures/deep_merge2/config1.yml +0 -3
- data/spec/fixtures/deep_merge2/config2.yml +0 -2
- data/spec/fixtures/development.yml +0 -4
- data/spec/fixtures/empty1.yml +0 -0
- data/spec/fixtures/empty2.yml +0 -0
- data/spec/fixtures/env/settings.yml +0 -4
- data/spec/fixtures/malformed.yml +0 -6
- data/spec/fixtures/reserved_keywords.yml +0 -2
- data/spec/fixtures/settings.yml +0 -21
- data/spec/fixtures/settings2.yml +0 -1
- data/spec/fixtures/with_erb.yml +0 -4
- data/spec/options_spec.rb +0 -84
- data/spec/sources/yaml_source_spec.rb +0 -77
- data/spec/spec_helper.rb +0 -54
- data/spec/support/rails_config_helper.rb +0 -22
- data/spec/support/shared_contexts/rake.rb +0 -8
- data/spec/tasks/db_spec.rb +0 -9
@@ -1,28 +0,0 @@
|
|
1
|
-
size: 1
|
2
|
-
server: google.com
|
3
|
-
inner:
|
4
|
-
something1: "blah1"
|
5
|
-
something2: "blah2"
|
6
|
-
|
7
|
-
inner2:
|
8
|
-
inner2_inner:
|
9
|
-
foo1: "blah1"
|
10
|
-
|
11
|
-
|
12
|
-
arraylist1:
|
13
|
-
- 1
|
14
|
-
- 2
|
15
|
-
- 3
|
16
|
-
|
17
|
-
arraylist2:
|
18
|
-
inner:
|
19
|
-
- 1
|
20
|
-
- 2
|
21
|
-
- 3
|
22
|
-
|
23
|
-
hash_array:
|
24
|
-
- 1
|
25
|
-
- inner:
|
26
|
-
- 1
|
27
|
-
- 2
|
28
|
-
- 3
|
@@ -1,28 +0,0 @@
|
|
1
|
-
server: google.com
|
2
|
-
|
3
|
-
inner:
|
4
|
-
something3: "blah3"
|
5
|
-
|
6
|
-
inner2:
|
7
|
-
inner2_inner:
|
8
|
-
foo2: "blah2"
|
9
|
-
foo3: "blah3"
|
10
|
-
|
11
|
-
arraylist1:
|
12
|
-
- 4
|
13
|
-
- 5
|
14
|
-
- 6
|
15
|
-
|
16
|
-
|
17
|
-
arraylist2:
|
18
|
-
inner:
|
19
|
-
- 4
|
20
|
-
- 5
|
21
|
-
- 6
|
22
|
-
|
23
|
-
hash_array:
|
24
|
-
- 2
|
25
|
-
- inner:
|
26
|
-
- 4
|
27
|
-
- 5
|
28
|
-
- 6
|
data/spec/fixtures/empty1.yml
DELETED
File without changes
|
data/spec/fixtures/empty2.yml
DELETED
File without changes
|
data/spec/fixtures/malformed.yml
DELETED
data/spec/fixtures/settings.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# Settings for Rails database.yml
|
3
|
-
#
|
4
|
-
databases:
|
5
|
-
development:
|
6
|
-
database: db/development.sqlite3
|
7
|
-
test:
|
8
|
-
database: db/test.sqlite3
|
9
|
-
production:
|
10
|
-
database: db/production.sqlite3
|
11
|
-
##
|
12
|
-
# ...
|
13
|
-
#
|
14
|
-
size: 1
|
15
|
-
server: google.com
|
16
|
-
1: "one"
|
17
|
-
photo_sizes:
|
18
|
-
avatar: [60, 60]
|
19
|
-
root:
|
20
|
-
yahoo.com: 2
|
21
|
-
'google.com': 3
|
data/spec/fixtures/settings2.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
another: "something"
|
data/spec/fixtures/with_erb.yml
DELETED
data/spec/options_spec.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Config::Options do
|
4
|
-
|
5
|
-
context 'when Settings file is using keywords reserved for OpenStruct' do
|
6
|
-
let(:config) do
|
7
|
-
Config.load_files("#{fixture_path}/reserved_keywords.yml")
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should allow to access them via object member notation' do
|
11
|
-
expect(config.select).to eq(123)
|
12
|
-
expect(config.collect).to eq(456)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should allow to access them using [] operator' do
|
16
|
-
expect(config['select']).to eq(123)
|
17
|
-
expect(config['collect']).to eq(456)
|
18
|
-
|
19
|
-
expect(config[:select]).to eq(123)
|
20
|
-
expect(config[:collect]).to eq(456)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'adding sources' do
|
25
|
-
let(:config) do
|
26
|
-
Config.load_files("#{fixture_path}/settings.yml")
|
27
|
-
end
|
28
|
-
|
29
|
-
before do
|
30
|
-
config.add_source!("#{fixture_path}/deep_merge2/config1.yml")
|
31
|
-
config.reload!
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should still have the initial config' do
|
35
|
-
expect(config['size']).to eq(1)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should add keys from the added file' do
|
39
|
-
expect(config['tvrage']['service_url']).to eq('http://services.tvrage.com')
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'overwrite' do
|
43
|
-
before do
|
44
|
-
config.add_source!("#{fixture_path}/deep_merge2/config2.yml")
|
45
|
-
config.reload!
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should overwrite the previous values' do
|
49
|
-
expect(config['tvrage']['service_url']).to eq('http://url2')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'prepending sources' do
|
55
|
-
let(:config) do
|
56
|
-
Config.load_files("#{fixture_path}/settings.yml")
|
57
|
-
end
|
58
|
-
|
59
|
-
before do
|
60
|
-
config.prepend_source!("#{fixture_path}/deep_merge2/config1.yml")
|
61
|
-
config.reload!
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'should still have the initial config' do
|
65
|
-
expect(config['size']).to eq(1)
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'should add keys from the added file' do
|
69
|
-
expect(config['tvrage']['service_url']).to eq('http://services.tvrage.com')
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'be overwriten' do
|
73
|
-
before do
|
74
|
-
config.prepend_source!("#{fixture_path}/deep_merge2/config2.yml")
|
75
|
-
config.reload!
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'should overwrite the previous values' do
|
79
|
-
expect(config['tvrage']['service_url']).to eq('http://services.tvrage.com')
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Config::Sources
|
4
|
-
describe YAMLSource do
|
5
|
-
it "should take a path as initializer" do
|
6
|
-
source = YAMLSource.new "somepath"
|
7
|
-
expect(source.path).to eq("somepath")
|
8
|
-
end
|
9
|
-
|
10
|
-
context "basic yml file" do
|
11
|
-
let(:source) do
|
12
|
-
YAMLSource.new "#{fixture_path}/development.yml"
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should properly read the settings" do
|
16
|
-
results = source.load
|
17
|
-
expect(results["size"]).to eq(2)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should properly read nested settings" do
|
21
|
-
results = source.load
|
22
|
-
expect(results["section"]["size"]).to eq(3)
|
23
|
-
expect(results["section"]["servers"]).to be_instance_of(Array)
|
24
|
-
expect(results["section"]["servers"].size).to eq(2)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "yml file with erb tags" do
|
29
|
-
let(:source) do
|
30
|
-
YAMLSource.new "#{fixture_path}/with_erb.yml"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should properly evaluate the erb" do
|
34
|
-
results = source.load
|
35
|
-
expect(results["computed"]).to eq(6)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should properly evaluate the nested erb settings" do
|
39
|
-
results = source.load
|
40
|
-
expect(results["section"]["computed1"]).to eq(1)
|
41
|
-
expect(results["section"]["computed2"]).to eq(2)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "missing yml file" do
|
46
|
-
let(:source) do
|
47
|
-
YAMLSource.new "somewhere_that_doesnt_exist.yml"
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should return an empty hash" do
|
51
|
-
results = source.load
|
52
|
-
expect(results).to eq({})
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "blank yml file" do
|
57
|
-
let(:source) do
|
58
|
-
YAMLSource.new "#{fixture_path}/empty1.yml"
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should return an empty hash" do
|
62
|
-
results = source.load
|
63
|
-
expect(results).to eq({})
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context "malformed yml file" do
|
68
|
-
let(:source) do
|
69
|
-
YAMLSource.new "#{fixture_path}/malformed.yml"
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should raise an useful exception" do
|
73
|
-
expect { source.load }.to raise_error(/malformed\.yml/)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
ENV["RAILS_ENV"] ||= 'test'
|
2
|
-
|
3
|
-
##
|
4
|
-
# Code Climate
|
5
|
-
#
|
6
|
-
if ENV["TRAVIS"]
|
7
|
-
require "codeclimate-test-reporter"
|
8
|
-
CodeClimate::TestReporter.start
|
9
|
-
end
|
10
|
-
|
11
|
-
##
|
12
|
-
# Load Rspec supporting files
|
13
|
-
#
|
14
|
-
Dir['./spec/support/**/*.rb'].each { |f| require f }
|
15
|
-
|
16
|
-
##
|
17
|
-
# Load Rails dummy application based on gemfile name substituted by Appraisal
|
18
|
-
#
|
19
|
-
if ENV["APPRAISAL_INITIALIZED"] || ENV["TRAVIS"]
|
20
|
-
app_name = Pathname.new(ENV['BUNDLE_GEMFILE']).basename.sub('.gemfile', '')
|
21
|
-
else
|
22
|
-
app_name = 'rails_3'
|
23
|
-
end
|
24
|
-
|
25
|
-
require File.expand_path("../../spec/app/#{app_name}/config/environment", __FILE__)
|
26
|
-
|
27
|
-
APP_RAKEFILE = File.expand_path("../../spec/app/#{app_name}/Rakefile", __FILE__)
|
28
|
-
|
29
|
-
##
|
30
|
-
# Load Rspec
|
31
|
-
#
|
32
|
-
require 'rspec/rails'
|
33
|
-
|
34
|
-
# Configure
|
35
|
-
RSpec.configure do |config|
|
36
|
-
config.fixture_path = File.join(File.dirname(__FILE__), "/fixtures")
|
37
|
-
|
38
|
-
# Turn the deprecation warnings into errors, giving you the full backtrace
|
39
|
-
config.raise_errors_for_deprecations!
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
##
|
44
|
-
# Print some debug info
|
45
|
-
#
|
46
|
-
puts
|
47
|
-
puts "Gemfile: #{ENV['BUNDLE_GEMFILE']}"
|
48
|
-
puts "Rails version:"
|
49
|
-
|
50
|
-
Gem.loaded_specs.each { |name, spec|
|
51
|
-
puts "\t#{name}-#{spec.version}" if %w{rails activesupport sqlite3 rspec-rails}.include?(name)
|
52
|
-
}
|
53
|
-
|
54
|
-
puts
|
@@ -1,22 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# Config Rspec Helpers
|
3
|
-
#
|
4
|
-
|
5
|
-
# Loads ENV vars from a yaml file
|
6
|
-
def load_env(filename)
|
7
|
-
if filename and File.exists?(filename.to_s)
|
8
|
-
result = YAML.load(ERB.new(IO.read(filename.to_s)).result)
|
9
|
-
end
|
10
|
-
result.each { |key, value| ENV[key.to_s] = value.to_s } unless result.nil?
|
11
|
-
end
|
12
|
-
|
13
|
-
# Checks if (default) Config const is already available
|
14
|
-
def config_available?
|
15
|
-
where = caller[0].split(':')[0].gsub(File.expand_path(File.dirname(__FILE__)), '')
|
16
|
-
|
17
|
-
if defined?(::Settings)
|
18
|
-
puts "Config available in #{where}"
|
19
|
-
else
|
20
|
-
raise "Config not available in #{where}"
|
21
|
-
end
|
22
|
-
end
|