chamber 2.7.1 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4a3d686721e6b3ccbf6352227cfa0a6bdfb2b43
4
- data.tar.gz: 798f1cec12ea2648a916d7830739f0ef50647679
3
+ metadata.gz: 4f7dbdffb12b7b5622f0599bd110ce6ff1ff5316
4
+ data.tar.gz: 16f1879d1d7bafadd27f9e573b420cceeb18abfb
5
5
  SHA512:
6
- metadata.gz: 68c4c8c96652a068514f1ac17edda03d06977b11dfc776f06d4b5f39fd75a579efde318806c29d8169d899f562bd75cd41de743b81d088b7721af2afc4adf197
7
- data.tar.gz: 0de18f64eb779247df51a06085287f73eaf56acd9662a1643e75a5b5864c4cfc060a46ce6562f2ee67ad23560d9dfab4d39b64fcb3f43fd1d99b5f946b838b89
6
+ metadata.gz: cd5da56e5554973ac39e4615ec410f12e3771069182c65081a90f9a2b41476f06db63c853d373810336ebe097e2cd83a46215972e2f8c808ad5669514391dea4
7
+ data.tar.gz: cea1cd1f08b84475c92ea6391755f58e0621eccf3dd08d4a54acd9c8125705ee78fc5ff874d508767ddafb2f125281a62b6e6c3cea8e75c7a01947ab4b715cf6
data/README.md CHANGED
@@ -29,3 +29,17 @@ management library.
29
29
  ## Full Reference
30
30
 
31
31
  Visit the [wiki](https://github.com/thekompanee/chamber/wiki)
32
+
33
+ ## Credits
34
+
35
+ Chamber was written by Jeff Felchner and Mark McEahern.
36
+
37
+ ![The Kompanee](https://www.dropbox.com/s/86jfka1d6bhv8as/kompanee-text-black.png?dl=1)
38
+
39
+ Chamber is maintained and funded by [The Kompanee, Ltd.](http://www.thekompanee.com/)
40
+
41
+ The names and logos for The Kompanee are trademarks of The Kompanee, Ltd.
42
+
43
+ ## License
44
+
45
+ Chamber is Copyright © 2014 Jeff Felchner and Mark McEahern. It is free software, and may be redistributed under the terms specified in the [LICENSE](https://github.com/thekompanee/chamber/blob/master/LICENSE) file.
@@ -1,4 +1,5 @@
1
1
  require 'pathname'
2
+ require 'fileutils'
2
3
  require 'openssl'
3
4
  require 'chamber/configuration'
4
5
  require 'chamber/commands/base'
@@ -12,7 +13,7 @@ class Initialize < Chamber::Commands::Base
12
13
  self.basepath = Chamber.configuration.basepath
13
14
  end
14
15
 
15
- # rubocop:disable Metrics/LineLength, Metrics/MethodLength
16
+ # rubocop:disable Metrics/LineLength, Metrics/MethodLength, Metrics/AbcSize
16
17
  def call
17
18
  shell.create_file private_key_filepath, rsa_private_key.to_pem
18
19
  shell.create_file protected_key_filepath, rsa_protected_key
@@ -22,9 +23,12 @@ class Initialize < Chamber::Commands::Base
22
23
  `chmod 600 #{protected_key_filepath}`
23
24
  `chmod 644 #{public_key_filepath}`
24
25
 
26
+ ::FileUtils.touch gitignore_filepath
27
+
25
28
  unless ::File.read(gitignore_filepath).match(/^.chamber.pem$/)
26
- shell.append_to_file gitignore_filepath, private_key_filename
27
- shell.append_to_file gitignore_filepath, protected_key_filename
29
+ shell.append_to_file gitignore_filepath, "\n# Private and protected key files for Chamber\n"
30
+ shell.append_to_file gitignore_filepath, "#{private_key_filename}\n"
31
+ shell.append_to_file gitignore_filepath, "#{protected_key_filename}\n"
28
32
  end
29
33
 
30
34
  shell.copy_file settings_template_filepath, settings_filepath
@@ -41,10 +45,10 @@ class Initialize < Chamber::Commands::Base
41
45
  shell.say protected_key_filepath, :green
42
46
  shell.say ''
43
47
  shell.say 'and not have to worry about sending it via a secure medium (such as', :green
44
- shell.say 'email), however do not send the passphrase along with it. Give it to'
48
+ shell.say 'email), however do not send the passphrase along with it. Give it to', :green
45
49
  shell.say 'your team members in person.', :green
46
50
  shell.say ''
47
- shell.say 'In order for them to decrypt it (for use with Chamber), they can run:'
51
+ shell.say 'In order for them to decrypt it (for use with Chamber), they can run:', :green
48
52
  shell.say ''
49
53
  shell.say "$ cp /path/to/{#{protected_key_filename},#{private_key_filename}}", :green
50
54
  shell.say "$ ssh-keygen -p -f /path/to/#{private_key_filename}", :green
@@ -52,7 +56,7 @@ class Initialize < Chamber::Commands::Base
52
56
  shell.say 'Enter the passphrase when prompted and leave the new passphrase blank.', :green
53
57
  shell.say ''
54
58
  end
55
- # rubocop:enable Metrics/LineLength, Metrics/MethodLength
59
+ # rubocop:enable Metrics/LineLength, Metrics/MethodLength, Metrics/AbcSize
56
60
 
57
61
  def self.call(options = {})
58
62
  new(options).call
@@ -9,6 +9,8 @@ class ContextResolver
9
9
  self.options = Hashie::Mash.new(options)
10
10
  end
11
11
 
12
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
13
+ # rubocop:disable Metrics/PerceivedComplexity, Metrics/MethodLength
12
14
  def resolve
13
15
  options[:rootpath] ||= Pathname.pwd
14
16
  options[:rootpath] = Pathname.new(options[:rootpath])
@@ -17,11 +19,22 @@ class ContextResolver
17
19
  options[:namespaces] ||= []
18
20
  options[:preset] ||= resolve_preset
19
21
 
20
- if options[:preset] == 'rails'
22
+ if %w{rails rails-engine}.include?(options[:preset])
23
+ if options[:preset] == 'rails-engine'
24
+ engine_spec_dummy_directory = options[:rootpath] + 'spec' + 'dummy'
25
+ engine_test_dummy_directory = options[:rootpath] + 'test' + 'dummy'
26
+
27
+ options[:rootpath] = if (engine_spec_dummy_directory + 'config.ru').exist?
28
+ engine_spec_dummy_directory
29
+ elsif (engine_test_dummy_directory + 'config.ru').exist?
30
+ engine_test_dummy_directory
31
+ end
32
+ end
33
+
21
34
  options[:basepath] ||= options[:rootpath] + 'config'
22
35
 
23
36
  if options[:namespaces] == []
24
- require options[:rootpath].join('config', 'application')
37
+ require options[:rootpath].join('config', 'application').to_s
25
38
 
26
39
  options[:namespaces] = [
27
40
  ::Rails.env,
@@ -41,6 +54,8 @@ class ContextResolver
41
54
  rescue LoadError
42
55
  options
43
56
  end
57
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
58
+ # rubocop:enable Metrics/PerceivedComplexity, Metrics/MethodLength
44
59
 
45
60
  def self.resolve(options = {})
46
61
  new(options).resolve
@@ -51,7 +66,11 @@ class ContextResolver
51
66
  attr_accessor :options
52
67
 
53
68
  def resolve_preset
54
- 'rails' if in_a_rails_project?
69
+ if in_a_rails_project?
70
+ 'rails'
71
+ elsif in_a_rails_engine?
72
+ 'rails-engine'
73
+ end
55
74
  end
56
75
 
57
76
  def resolve_encryption_key(key)
@@ -70,6 +89,11 @@ class ContextResolver
70
89
  rails_executable_exists?
71
90
  end
72
91
 
92
+ def in_a_rails_engine?
93
+ (options[:rootpath] + 'spec' + 'dummy' + 'config.ru').exist? ||
94
+ (options[:rootpath] + 'test' + 'dummy' + 'config.ru').exist?
95
+ end
96
+
73
97
  def rails_executable_exists?
74
98
  options[:rootpath].join('bin', 'rails').exist? ||
75
99
  options[:rootpath].join('script', 'rails').exist? ||
@@ -1,3 +1,3 @@
1
1
  module Chamber
2
- VERSION = '2.7.1'
2
+ VERSION = '2.8.0'
3
3
  end
@@ -4,9 +4,13 @@ require 'chamber/context_resolver'
4
4
  module Chamber
5
5
  module Commands
6
6
  describe ContextResolver do
7
- let(:rails_2_path) { ::File.expand_path('../../../rails-2-test', __FILE__) }
8
- let(:rails_3_path) { ::File.expand_path('../../../rails-3-test', __FILE__) }
9
- let(:rails_4_path) { ::File.expand_path('../../../rails-4-test', __FILE__) }
7
+ let(:rails_2_path) { ::File.expand_path('../../../rails-2-test', __FILE__) }
8
+ let(:rails_3_path) { ::File.expand_path('../../../rails-3-test', __FILE__) }
9
+ let(:rails_4_path) { ::File.expand_path('../../../rails-4-test', __FILE__) }
10
+ let(:rails_engine_path) { ::File.expand_path('../../../rails-engine-test', __FILE__) }
11
+
12
+ before(:each) { @old_chamber_key = ENV.delete('CHAMBER_KEY') }
13
+ after(:each) { ENV['CHAMBER_KEY'] = @old_chamber_key }
10
14
 
11
15
  it 'does not attempt to do any resolution if all valid options are passed in' do
12
16
  options = ContextResolver.resolve(basepath: 'my_path',
@@ -142,6 +146,16 @@ describe ContextResolver do
142
146
  expect(options[:basepath].to_s).to include 'rails-4-test/config'
143
147
  expect(options[:namespaces]).to eql %w{development my_host}
144
148
  end
149
+
150
+ it 'sets the basepath if inside a Rails engine' do
151
+ allow(Socket).to receive(:gethostname).and_return 'my_host'
152
+
153
+ options = ContextResolver.resolve(rootpath: rails_engine_path)
154
+
155
+ expect(options[:rootpath].to_s).to include 'rails-engine-test/spec/dummy'
156
+ expect(options[:basepath].to_s).to include 'rails-engine-test/spec/dummy/config'
157
+ expect(options[:namespaces]).to eql %w{development my_host}
158
+ end
145
159
  end
146
160
  end
147
161
  end
@@ -71,7 +71,7 @@ only_namespaced_sub_settings:
71
71
  HEREDOC
72
72
  end
73
73
 
74
- describe Chamber do
74
+ describe 'Chamber' do
75
75
  before(:each) { Chamber.load(basepath: '/tmp/chamber') }
76
76
 
77
77
  it 'knows how to load itself with a path string' do
@@ -280,13 +280,13 @@ describe Chamber do
280
280
  end
281
281
 
282
282
  it 'can render itself as a string even if it has not been loaded' do
283
- Chamber.load
283
+ Chamber.load basepath: '/'
284
284
 
285
285
  expect(Chamber.to_s).to eql ''
286
286
  end
287
287
 
288
288
  it 'can determine settings even if it has not been loaded' do
289
- Chamber.load
289
+ Chamber.load basepath: '/'
290
290
 
291
291
  expect(Chamber.to_hash).to eql({})
292
292
  end
@@ -0,0 +1,5 @@
1
+ class Rails
2
+ def self.env
3
+ 'development'
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ development:
2
+ setting: development_value
3
+ # The following will become 'secure_setting'
4
+ _secure_secure_setting: secure_development_value
5
+
6
+ test:
7
+ setting: test_value
8
+ # The following will become 'secure_setting'
9
+ _secure_secure_setting: secure_test_value
10
+
11
+ production:
12
+ setting: production_value
13
+ # The following will become 'secure_setting'
14
+ _secure_secure_setting: secure_production_value
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chamber
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thekompanee
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-10-30 00:00:00.000000000 Z
14
+ date: 2015-03-24 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: thor
@@ -69,20 +69,6 @@ dependencies:
69
69
  - - "~>"
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0.46'
72
- - !ruby/object:Gem::Dependency
73
- name: codeclimate-test-reporter
74
- requirement: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - "~>"
77
- - !ruby/object:Gem::Version
78
- version: 0.3.0
79
- type: :development
80
- prerelease: false
81
- version_requirements: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - "~>"
84
- - !ruby/object:Gem::Version
85
- version: 0.3.0
86
72
  description: "\n Chamber lets you source your Settings from
87
73
  an arbitrary number of YAML files and\n provides a simple
88
74
  mechanism for overriding settings from the ENV, which is\n friendly
@@ -171,8 +157,12 @@ files:
171
157
  - spec/rails-4-test/bin/rails
172
158
  - spec/rails-4-test/config.ru
173
159
  - spec/rails-4-test/config/application.rb
160
+ - spec/rails-engine-test/spec/dummy/config.ru
161
+ - spec/rails-engine-test/spec/dummy/config/application.rb
162
+ - spec/rails-engine-test/spec/dummy/script/rails
174
163
  - spec/spec_key
175
164
  - spec/spec_key.pub
165
+ - templates/settings.yml
176
166
  homepage: https://github.com/thekompanee/chamber
177
167
  licenses:
178
168
  - MIT
@@ -193,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
183
  version: '0'
194
184
  requirements: []
195
185
  rubyforge_project:
196
- rubygems_version: 2.4.2
186
+ rubygems_version: 2.4.6
197
187
  signing_key:
198
188
  specification_version: 4
199
189
  summary: A surprisingly configurable convention-based approach to managing your application's
@@ -222,15 +212,17 @@ test_files:
222
212
  - spec/lib/chamber/namespace_set_spec.rb
223
213
  - spec/lib/chamber/settings_spec.rb
224
214
  - spec/lib/chamber_spec.rb
225
- - spec/rails-2-test/config/application.rb
226
215
  - spec/rails-2-test/config.ru
216
+ - spec/rails-2-test/config/application.rb
227
217
  - spec/rails-2-test/script/console
228
- - spec/rails-3-test/config/application.rb
229
218
  - spec/rails-3-test/config.ru
219
+ - spec/rails-3-test/config/application.rb
230
220
  - spec/rails-3-test/script/rails
231
221
  - spec/rails-4-test/bin/rails
232
- - spec/rails-4-test/config/application.rb
233
222
  - spec/rails-4-test/config.ru
223
+ - spec/rails-4-test/config/application.rb
224
+ - spec/rails-engine-test/spec/dummy/config.ru
225
+ - spec/rails-engine-test/spec/dummy/config/application.rb
226
+ - spec/rails-engine-test/spec/dummy/script/rails
234
227
  - spec/spec_key
235
228
  - spec/spec_key.pub
236
- has_rdoc: