config 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -6
  3. data/README.md +62 -63
  4. data/config.gemspec +15 -14
  5. data/lib/config.rb +13 -9
  6. data/lib/config/compatibility.rb +1 -1
  7. data/lib/config/{engine.rb → integrations/rails/engine.rb} +0 -0
  8. data/lib/config/{integration/rails.rb → integrations/rails/railtie.rb} +0 -0
  9. data/lib/config/{integration → integrations}/sinatra.rb +0 -0
  10. data/lib/config/options.rb +7 -2
  11. data/lib/config/version.rb +1 -1
  12. data/lib/generators/config/templates/config.rb +6 -2
  13. metadata +27 -364
  14. data/.codeclimate.yml +0 -6
  15. data/.gitignore +0 -14
  16. data/.rspec +0 -2
  17. data/.ruby-gemset +0 -1
  18. data/.ruby-version +0 -1
  19. data/.travis.yml +0 -23
  20. data/Appraisals +0 -15
  21. data/Gemfile +0 -6
  22. data/Rakefile +0 -42
  23. data/gemfiles/rails_3.gemfile +0 -7
  24. data/gemfiles/rails_4.1.gemfile +0 -7
  25. data/gemfiles/rails_4.2.gemfile +0 -7
  26. data/gemfiles/rails_4.gemfile +0 -7
  27. data/lib/config/railtie.rb +0 -9
  28. data/spec/app/rails_3/Rakefile +0 -7
  29. data/spec/app/rails_3/app/assets/javascripts/application.js +0 -13
  30. data/spec/app/rails_3/app/assets/stylesheets/application.css +0 -13
  31. data/spec/app/rails_3/app/controllers/application_controller.rb +0 -3
  32. data/spec/app/rails_3/app/helpers/application_helper.rb +0 -2
  33. data/spec/app/rails_3/app/models/.gitkeep +0 -0
  34. data/spec/app/rails_3/app/views/layouts/application.html.erb +0 -14
  35. data/spec/app/rails_3/bin/bundle +0 -3
  36. data/spec/app/rails_3/bin/rails +0 -4
  37. data/spec/app/rails_3/bin/rake +0 -4
  38. data/spec/app/rails_3/config.ru +0 -4
  39. data/spec/app/rails_3/config/application.rb +0 -29
  40. data/spec/app/rails_3/config/boot.rb +0 -5
  41. data/spec/app/rails_3/config/database.yml +0 -25
  42. data/spec/app/rails_3/config/environment.rb +0 -5
  43. data/spec/app/rails_3/config/environments/development.rb +0 -42
  44. data/spec/app/rails_3/config/environments/production.rb +0 -72
  45. data/spec/app/rails_3/config/environments/test.rb +0 -42
  46. data/spec/app/rails_3/config/initializers/backtrace_silencers.rb +0 -7
  47. data/spec/app/rails_3/config/initializers/inflections.rb +0 -15
  48. data/spec/app/rails_3/config/initializers/mime_types.rb +0 -5
  49. data/spec/app/rails_3/config/initializers/secret_token.rb +0 -7
  50. data/spec/app/rails_3/config/initializers/session_store.rb +0 -8
  51. data/spec/app/rails_3/config/initializers/wrap_parameters.rb +0 -14
  52. data/spec/app/rails_3/config/locales/en.yml +0 -5
  53. data/spec/app/rails_3/config/routes.rb +0 -2
  54. data/spec/app/rails_3/config/settings.yml +0 -7
  55. data/spec/app/rails_3/db/.gitkeep +0 -0
  56. data/spec/app/rails_3/public/404.html +0 -26
  57. data/spec/app/rails_3/public/422.html +0 -26
  58. data/spec/app/rails_3/public/500.html +0 -25
  59. data/spec/app/rails_3/script/rails +0 -6
  60. data/spec/app/rails_4.1/Rakefile +0 -6
  61. data/spec/app/rails_4.1/app/assets/javascripts/application.js +0 -13
  62. data/spec/app/rails_4.1/app/assets/stylesheets/application.css +0 -15
  63. data/spec/app/rails_4.1/app/controllers/application_controller.rb +0 -5
  64. data/spec/app/rails_4.1/app/helpers/application_helper.rb +0 -2
  65. data/spec/app/rails_4.1/app/models/.keep +0 -0
  66. data/spec/app/rails_4.1/app/views/layouts/application.html.erb +0 -14
  67. data/spec/app/rails_4.1/bin/bundle +0 -3
  68. data/spec/app/rails_4.1/bin/rails +0 -4
  69. data/spec/app/rails_4.1/bin/rake +0 -4
  70. data/spec/app/rails_4.1/config.ru +0 -4
  71. data/spec/app/rails_4.1/config/application.rb +0 -27
  72. data/spec/app/rails_4.1/config/boot.rb +0 -5
  73. data/spec/app/rails_4.1/config/database.yml +0 -25
  74. data/spec/app/rails_4.1/config/environment.rb +0 -5
  75. data/spec/app/rails_4.1/config/environments/development.rb +0 -42
  76. data/spec/app/rails_4.1/config/environments/production.rb +0 -88
  77. data/spec/app/rails_4.1/config/environments/test.rb +0 -44
  78. data/spec/app/rails_4.1/config/initializers/backtrace_silencers.rb +0 -7
  79. data/spec/app/rails_4.1/config/initializers/cookies_serializer.rb +0 -3
  80. data/spec/app/rails_4.1/config/initializers/filter_parameter_logging.rb +0 -4
  81. data/spec/app/rails_4.1/config/initializers/inflections.rb +0 -16
  82. data/spec/app/rails_4.1/config/initializers/mime_types.rb +0 -4
  83. data/spec/app/rails_4.1/config/initializers/session_store.rb +0 -3
  84. data/spec/app/rails_4.1/config/initializers/wrap_parameters.rb +0 -14
  85. data/spec/app/rails_4.1/config/locales/en.yml +0 -23
  86. data/spec/app/rails_4.1/config/routes.rb +0 -2
  87. data/spec/app/rails_4.1/config/secrets.yml +0 -22
  88. data/spec/app/rails_4.1/config/settings.yml +0 -7
  89. data/spec/app/rails_4.1/db/.keep +0 -0
  90. data/spec/app/rails_4.1/public/404.html +0 -67
  91. data/spec/app/rails_4.1/public/422.html +0 -67
  92. data/spec/app/rails_4.1/public/500.html +0 -66
  93. data/spec/app/rails_4.2/Rakefile +0 -6
  94. data/spec/app/rails_4.2/app/assets/images/.keep +0 -0
  95. data/spec/app/rails_4.2/app/assets/javascripts/application.js +0 -16
  96. data/spec/app/rails_4.2/app/assets/stylesheets/application.css +0 -15
  97. data/spec/app/rails_4.2/app/controllers/application_controller.rb +0 -5
  98. data/spec/app/rails_4.2/app/controllers/concerns/.keep +0 -0
  99. data/spec/app/rails_4.2/app/helpers/application_helper.rb +0 -2
  100. data/spec/app/rails_4.2/app/mailers/.keep +0 -0
  101. data/spec/app/rails_4.2/app/models/.keep +0 -0
  102. data/spec/app/rails_4.2/app/models/concerns/.keep +0 -0
  103. data/spec/app/rails_4.2/app/views/layouts/application.html.erb +0 -14
  104. data/spec/app/rails_4.2/bin/bundle +0 -3
  105. data/spec/app/rails_4.2/bin/rails +0 -8
  106. data/spec/app/rails_4.2/bin/rake +0 -8
  107. data/spec/app/rails_4.2/bin/setup +0 -29
  108. data/spec/app/rails_4.2/bin/spring +0 -15
  109. data/spec/app/rails_4.2/config.ru +0 -4
  110. data/spec/app/rails_4.2/config/application.rb +0 -31
  111. data/spec/app/rails_4.2/config/boot.rb +0 -3
  112. data/spec/app/rails_4.2/config/database.yml +0 -25
  113. data/spec/app/rails_4.2/config/environment.rb +0 -5
  114. data/spec/app/rails_4.2/config/environments/development.rb +0 -41
  115. data/spec/app/rails_4.2/config/environments/production.rb +0 -79
  116. data/spec/app/rails_4.2/config/environments/test.rb +0 -42
  117. data/spec/app/rails_4.2/config/initializers/assets.rb +0 -11
  118. data/spec/app/rails_4.2/config/initializers/backtrace_silencers.rb +0 -7
  119. data/spec/app/rails_4.2/config/initializers/cookies_serializer.rb +0 -3
  120. data/spec/app/rails_4.2/config/initializers/filter_parameter_logging.rb +0 -4
  121. data/spec/app/rails_4.2/config/initializers/inflections.rb +0 -16
  122. data/spec/app/rails_4.2/config/initializers/mime_types.rb +0 -4
  123. data/spec/app/rails_4.2/config/initializers/session_store.rb +0 -3
  124. data/spec/app/rails_4.2/config/initializers/wrap_parameters.rb +0 -14
  125. data/spec/app/rails_4.2/config/locales/en.yml +0 -23
  126. data/spec/app/rails_4.2/config/routes.rb +0 -56
  127. data/spec/app/rails_4.2/config/secrets.yml +0 -22
  128. data/spec/app/rails_4.2/config/settings.yml +0 -7
  129. data/spec/app/rails_4.2/db/seeds.rb +0 -7
  130. data/spec/app/rails_4.2/public/404.html +0 -67
  131. data/spec/app/rails_4.2/public/422.html +0 -67
  132. data/spec/app/rails_4.2/public/500.html +0 -66
  133. data/spec/app/rails_4.2/public/favicon.ico +0 -0
  134. data/spec/app/rails_4.2/public/robots.txt +0 -5
  135. data/spec/app/rails_4/Rakefile +0 -6
  136. data/spec/app/rails_4/app/assets/javascripts/application.js +0 -13
  137. data/spec/app/rails_4/app/assets/stylesheets/application.css +0 -13
  138. data/spec/app/rails_4/app/controllers/application_controller.rb +0 -5
  139. data/spec/app/rails_4/app/helpers/application_helper.rb +0 -2
  140. data/spec/app/rails_4/app/models/.keep +0 -0
  141. data/spec/app/rails_4/app/views/layouts/application.html.erb +0 -14
  142. data/spec/app/rails_4/bin/bundle +0 -3
  143. data/spec/app/rails_4/bin/rails +0 -4
  144. data/spec/app/rails_4/bin/rake +0 -4
  145. data/spec/app/rails_4/config.ru +0 -4
  146. data/spec/app/rails_4/config/application.rb +0 -27
  147. data/spec/app/rails_4/config/boot.rb +0 -5
  148. data/spec/app/rails_4/config/database.yml +0 -25
  149. data/spec/app/rails_4/config/environment.rb +0 -5
  150. data/spec/app/rails_4/config/environments/development.rb +0 -34
  151. data/spec/app/rails_4/config/environments/production.rb +0 -85
  152. data/spec/app/rails_4/config/environments/test.rb +0 -41
  153. data/spec/app/rails_4/config/initializers/backtrace_silencers.rb +0 -7
  154. data/spec/app/rails_4/config/initializers/filter_parameter_logging.rb +0 -4
  155. data/spec/app/rails_4/config/initializers/inflections.rb +0 -16
  156. data/spec/app/rails_4/config/initializers/mime_types.rb +0 -5
  157. data/spec/app/rails_4/config/initializers/secret_token.rb +0 -12
  158. data/spec/app/rails_4/config/initializers/session_store.rb +0 -3
  159. data/spec/app/rails_4/config/initializers/wrap_parameters.rb +0 -14
  160. data/spec/app/rails_4/config/locales/en.yml +0 -23
  161. data/spec/app/rails_4/config/routes.rb +0 -2
  162. data/spec/app/rails_4/config/settings.yml +0 -7
  163. data/spec/app/rails_4/db/.keep +0 -0
  164. data/spec/app/rails_4/public/404.html +0 -58
  165. data/spec/app/rails_4/public/422.html +0 -58
  166. data/spec/app/rails_4/public/500.html +0 -57
  167. data/spec/config_spec.rb +0 -317
  168. data/spec/fixtures/bool_override/config1.yml +0 -2
  169. data/spec/fixtures/bool_override/config2.yml +0 -2
  170. data/spec/fixtures/custom_types/hash.yml +0 -7
  171. data/spec/fixtures/deep_merge/config1.yml +0 -28
  172. data/spec/fixtures/deep_merge/config2.yml +0 -28
  173. data/spec/fixtures/deep_merge2/config1.yml +0 -3
  174. data/spec/fixtures/deep_merge2/config2.yml +0 -2
  175. data/spec/fixtures/development.yml +0 -4
  176. data/spec/fixtures/empty1.yml +0 -0
  177. data/spec/fixtures/empty2.yml +0 -0
  178. data/spec/fixtures/env/settings.yml +0 -4
  179. data/spec/fixtures/malformed.yml +0 -6
  180. data/spec/fixtures/reserved_keywords.yml +0 -2
  181. data/spec/fixtures/settings.yml +0 -21
  182. data/spec/fixtures/settings2.yml +0 -1
  183. data/spec/fixtures/with_erb.yml +0 -4
  184. data/spec/options_spec.rb +0 -84
  185. data/spec/sources/yaml_source_spec.rb +0 -77
  186. data/spec/spec_helper.rb +0 -54
  187. data/spec/support/rails_config_helper.rb +0 -22
  188. data/spec/support/shared_contexts/rake.rb +0 -8
  189. data/spec/tasks/db_spec.rb +0 -9
@@ -1,2 +0,0 @@
1
- override_bool: true
2
- override_bool_opposite: false
@@ -1,2 +0,0 @@
1
- override_bool: false
2
- override_bool_opposite: true
@@ -1,7 +0,0 @@
1
- prices:
2
- type: hash
3
- contents:
4
- 1: 2.99
5
- 5: 9.99
6
- 15: 19.99
7
- 30: 29.99
@@ -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
@@ -1,3 +0,0 @@
1
- tvrage:
2
- service_url: 'http://services.tvrage.com'
3
- cache: 500
@@ -1,2 +0,0 @@
1
- tvrage:
2
- service_url: "http://url2"
@@ -1,4 +0,0 @@
1
- size: 2
2
- section:
3
- size: 3
4
- servers: [ {name: yahoo.com}, {name: amazon.com} ]
File without changes
File without changes
@@ -1,4 +0,0 @@
1
- Settings.test_var: 123
2
- Settings.size: 3
3
- Settings.hash_test.one: 1-1
4
- Settings.hash_test.two: 1-2
@@ -1,6 +0,0 @@
1
- development: &defaults
2
- adapter: postgresql
3
- encoding: unicode
4
- test:
5
- <<:*defaults
6
- database: myapp_test
@@ -1,2 +0,0 @@
1
- select: 123
2
- collect: 456
@@ -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
@@ -1 +0,0 @@
1
- another: "something"
@@ -1,4 +0,0 @@
1
- computed: <%= 1 + 2 + 3 %>
2
- section:
3
- computed1: <%= "1" %>
4
- computed2: <%= "2" %>
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
@@ -1,8 +0,0 @@
1
- require 'rake'
2
-
3
- shared_context 'rake' do
4
-
5
- # include rails rake tasks
6
- load 'rails/tasks/engine.rake'
7
-
8
- end
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'db:create' do
4
- include_context 'rake'
5
-
6
- it 'has access to Settings object and can read databases from settings.yml file' do
7
- Rake::Task['db:create'].invoke
8
- end
9
- end