chamber 2.0.0 → 2.1.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: e5d109673b130deb762adb5bb07bdce3f93c3848
4
- data.tar.gz: 7bbce53ee5448ac94a876ca314461ce216ad881c
3
+ metadata.gz: 25bcff86c6f67c097a5b89db28c8f04cb92ca51b
4
+ data.tar.gz: fdb0c2f9f311ccd0f8f99a2a678bd584842e8d4f
5
5
  SHA512:
6
- metadata.gz: 8e1cdda8675bdb504657159f52209dd24fa5bd9accecd2cfddbb68a1df08011684b1152eeb975362a0b3452d8a9183655e886f5b3078659a934349229ee5a4a3
7
- data.tar.gz: d540cd77c3e966b9f355f1e910b74317254f4d8b6ea32e47db39fc92f567b3e6d71d029daebd059cbe371fcc5d63f7e3e106090dec9bb8f6944245cc3626dd0d
6
+ metadata.gz: 775493e4d7cb32f6878e6f86cef1995eff27816324aecb0d33b8b99a3d2e04b8684644f035f3a806b82dfd969bed778c980e99c8871c4176993e2bafc103b319
7
+ data.tar.gz: 54104049d2d5de2362a5f72e5d683040956e9338cbf374903db15538ccdb62174231e48adebd290a046ce65139e1771af2a8c9992d29cf8eb7d9878a9235a708
data/README.md CHANGED
@@ -10,10 +10,10 @@ We reviewed [some other gems](#alternatives), and while each fit a specific need
10
10
  and each did some things well, none of them met all of the criteria that we felt
11
11
  we (and assumed others) needed.
12
12
 
13
- <img src="https://akiajm7spx4gtbhaxe3qcomhaystacksoftwarearp.s3.amazonaws.com/photos/readmes/ten-commandments.png" align="right" />
14
-
15
13
  **Our Ten Commandments of Configuration Management**
16
14
 
15
+ <img src="https://akiajm7spx4gtbhaxe3qcomhaystacksoftwarearp.s3.amazonaws.com/photos/readmes/ten-commandments.png" align="right" />
16
+
17
17
  1. Thou shalt be configurable, but use conventions so that configuration isn't
18
18
  necessary
19
19
  1. Thou shalt seemlessly work with Heroku or other deployment platforms, where custom
@@ -1,4 +1,3 @@
1
- require 'chamber/commands/context_resolver'
2
1
  require 'chamber/instance'
3
2
 
4
3
  module Chamber
@@ -6,8 +5,6 @@ module Commands
6
5
  class Base
7
6
 
8
7
  def initialize(options = {})
9
- options = ContextResolver.resolve(options)
10
-
11
8
  self.chamber = Chamber::Instance.new options
12
9
  self.shell = options[:shell]
13
10
  self.rootpath = options[:rootpath]
@@ -1,3 +1,5 @@
1
+ require 'chamber/context_resolver'
2
+
1
3
  module Chamber
2
4
  class Configuration
3
5
  attr_accessor :basepath,
@@ -7,14 +9,13 @@ class Configuration
7
9
  :namespaces
8
10
 
9
11
  def initialize(options = {})
10
- self.basepath = options[:basepath] || ''
11
- self.namespaces = options[:namespaces] || []
12
+ options = ContextResolver.resolve(options)
13
+
14
+ self.basepath = options[:basepath]
15
+ self.namespaces = options[:namespaces]
12
16
  self.decryption_key = options[:decryption_key]
13
17
  self.encryption_key = options[:encryption_key]
14
- self.files = options[:files] || [
15
- self.basepath + 'credentials*.yml',
16
- self.basepath + 'settings*.yml',
17
- self.basepath + 'settings' ]
18
+ self.files = options[:files]
18
19
  end
19
20
 
20
21
  def to_hash
@@ -26,9 +27,5 @@ class Configuration
26
27
  namespaces: self.namespaces,
27
28
  }
28
29
  end
29
-
30
- def basepath=(pathlike)
31
- @basepath = pathlike == '' ? '' : Pathname.new(::File.expand_path(pathlike))
32
- end
33
30
  end
34
31
  end
@@ -1,5 +1,4 @@
1
1
  module Chamber
2
- module Commands
3
2
  class ContextResolver
4
3
 
5
4
  def initialize(options = {})
@@ -26,6 +25,12 @@ class ContextResolver
26
25
  options[:basepath] ||= options[:rootpath]
27
26
  end
28
27
 
28
+ options[:basepath] = Pathname.new(options[:basepath])
29
+
30
+ options[:files] ||= [ options[:basepath] + 'credentials*.yml',
31
+ options[:basepath] + 'settings*.yml',
32
+ options[:basepath] + 'settings' ]
33
+
29
34
  options
30
35
  rescue LoadError
31
36
  options
@@ -69,4 +74,3 @@ class ContextResolver
69
74
  end
70
75
  end
71
76
  end
72
- end
@@ -1,3 +1,3 @@
1
1
  module Chamber
2
- VERSION = '2.0.0'
2
+ VERSION = '2.1.0'
3
3
  end
@@ -1,19 +1,18 @@
1
1
  require 'rspectacular'
2
- require 'chamber/commands/context_resolver'
2
+ require 'chamber/context_resolver'
3
3
 
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
10
 
11
11
  it 'does not attempt to do any resolution if all valid options are passed in' do
12
12
  options = ContextResolver.resolve(basepath: 'my_path',
13
13
  namespaces: 'ns')
14
14
 
15
- expect(options[:basepath]).to eql 'my_path'
16
- expect(options[:files]).to be_nil
15
+ expect(options[:basepath].to_s).to eql 'my_path'
17
16
  expect(options[:namespaces]).to eql 'ns'
18
17
  end
19
18
 
@@ -32,6 +31,20 @@ describe ContextResolver do
32
31
  expect(options[:basepath].to_s).to eql './app'
33
32
  end
34
33
 
34
+ it 'always sets the basepath to a Pathname even if it is passed in as a String' do
35
+ options = ContextResolver.resolve(basepath: './app')
36
+
37
+ expect(options[:basepath]).to be_a Pathname
38
+ end
39
+
40
+ it 'sets the default files if none are passed in' do
41
+ options = ContextResolver.resolve(basepath: './app')
42
+
43
+ expect(options[:files].map(&:to_s)).to eql [ './app/credentials*.yml',
44
+ './app/settings*.yml',
45
+ './app/settings' ]
46
+ end
47
+
35
48
  it 'sets the rootpath to the current working directory if none is passed in' do
36
49
  allow(Pathname).to receive(:pwd).
37
50
  and_return('my_dir')
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.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - stevenhallen
@@ -101,7 +101,6 @@ files:
101
101
  - lib/chamber/commands/base.rb
102
102
  - lib/chamber/commands/comparable.rb
103
103
  - lib/chamber/commands/compare.rb
104
- - lib/chamber/commands/context_resolver.rb
105
104
  - lib/chamber/commands/files.rb
106
105
  - lib/chamber/commands/heroku/clear.rb
107
106
  - lib/chamber/commands/heroku/compare.rb
@@ -115,6 +114,7 @@ files:
115
114
  - lib/chamber/commands/travis/secure.rb
116
115
  - lib/chamber/commands/travis.rb
117
116
  - lib/chamber/configuration.rb
117
+ - lib/chamber/context_resolver.rb
118
118
  - lib/chamber/environmentable.rb
119
119
  - lib/chamber/errors/undecryptable_value_error.rb
120
120
  - lib/chamber/file.rb
@@ -136,7 +136,6 @@ files:
136
136
  - README.md
137
137
  - LICENSE
138
138
  - spec/fixtures/settings.yml
139
- - spec/lib/chamber/commands/context_resolver_spec.rb
140
139
  - spec/lib/chamber/commands/files_spec.rb
141
140
  - spec/lib/chamber/commands/heroku/clear_spec.rb
142
141
  - spec/lib/chamber/commands/heroku/compare_spec.rb
@@ -144,6 +143,7 @@ files:
144
143
  - spec/lib/chamber/commands/heroku/push_spec.rb
145
144
  - spec/lib/chamber/commands/secure_spec.rb
146
145
  - spec/lib/chamber/commands/show_spec.rb
146
+ - spec/lib/chamber/context_resolver_spec.rb
147
147
  - spec/lib/chamber/file_set_spec.rb
148
148
  - spec/lib/chamber/file_spec.rb
149
149
  - spec/lib/chamber/filters/boolean_conversion_filter_spec.rb
@@ -196,7 +196,6 @@ summary: A surprisingly configurable convention-based approach to managing your
196
196
  custom configuration settings.
197
197
  test_files:
198
198
  - spec/fixtures/settings.yml
199
- - spec/lib/chamber/commands/context_resolver_spec.rb
200
199
  - spec/lib/chamber/commands/files_spec.rb
201
200
  - spec/lib/chamber/commands/heroku/clear_spec.rb
202
201
  - spec/lib/chamber/commands/heroku/compare_spec.rb
@@ -204,6 +203,7 @@ test_files:
204
203
  - spec/lib/chamber/commands/heroku/push_spec.rb
205
204
  - spec/lib/chamber/commands/secure_spec.rb
206
205
  - spec/lib/chamber/commands/show_spec.rb
206
+ - spec/lib/chamber/context_resolver_spec.rb
207
207
  - spec/lib/chamber/file_set_spec.rb
208
208
  - spec/lib/chamber/file_spec.rb
209
209
  - spec/lib/chamber/filters/boolean_conversion_filter_spec.rb