sequoia 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb4670af90bd4e43c4dc7b5088bba98bd15809df
4
- data.tar.gz: d08b4ed06fe2c4e6968aaec315a7d3a2e6f50d15
3
+ metadata.gz: 2151eec515f5ae1b80cebf1cd551e0721047bd82
4
+ data.tar.gz: 4c119fa7403b3ee39777b32211c779416706fecf
5
5
  SHA512:
6
- metadata.gz: 4b88512b37e30fafb89304575902be384129e7c36ea3069a5feeafce901822898b1a670ad805e8a9c72636871dadfce4d4adec1fe2eae0d6cde0b6d35bde60bf
7
- data.tar.gz: a982713a595a9b7f6e8ddde173a1dff9d72b83551c8d7c45bae61e5a6f9f1408526dc8b40e2dbc38fdf4b7aa5bca6809a02e04a557a757f4edfe048444339374
6
+ metadata.gz: 399fba4c292726a60d081c876ca709d5abda6c723e148588f9a30f969aeeae4e6c3745c47f91c6b64112fb3b711f612ea2ba69195b5fbe731e39dd9aa56ba198
7
+ data.tar.gz: 76b4de751abdf51287854a4370ca59781905737c7e9e429e8125188294711df47ebfc04d1ac8a4a1a66305d64df5d633cb5b9aa2162235ef713535da8efe47b8
@@ -0,0 +1,7 @@
1
+ ## 0.2.0
2
+
3
+ - rename `Configurable#build` to `Configurable#build_configuration` (alias `build_config`)
4
+
5
+ ## 0.1.0
6
+
7
+ Initial release
data/README.md CHANGED
@@ -42,7 +42,7 @@ tree.configure :production do
42
42
  end
43
43
  end
44
44
 
45
- config = tree.build(:production)
45
+ config = tree.build_configuration(:production)
46
46
 
47
47
  config.working_folder #=> '/srv'
48
48
  config.timeout #=> 60
@@ -17,7 +17,7 @@ module Sequoia
17
17
  # Returns: {Sequoia::Builder} builder instance
18
18
  #
19
19
  def configure(env=:default, &block)
20
- environment = config_attributes[env.to_sym] ||= Store.new
20
+ environment = config_attributes[env.to_sym]
21
21
 
22
22
  Builder.new(environment, &block)
23
23
  end
@@ -30,11 +30,12 @@ module Sequoia
30
30
  #
31
31
  # Returns: {Sequoia::Entity} builded configuration object
32
32
  #
33
- def build(env=nil)
33
+ def build_configuration(env=nil)
34
34
  result = config_attributes[:default]
35
35
  result.deep_merge!(config_attributes[env.to_sym]) if env
36
36
  Entity.create(result)
37
37
  end
38
+ alias :build_config :build_configuration
38
39
 
39
40
  protected
40
41
 
@@ -42,8 +43,8 @@ module Sequoia
42
43
  # Config environments storage
43
44
  #
44
45
  def config_attributes
45
- @config_attributes ||= { default: Store.new }
46
+ @config_attributes ||= Hash.new { |hash, key| hash[key] = Store.new }
46
47
  end
47
48
 
48
49
  end
49
- end
50
+ end
@@ -55,5 +55,11 @@ module Sequoia
55
55
  PP.pp(to_hash, '')
56
56
  end
57
57
 
58
+ ##
59
+ # Do not raise exceptions when key not found
60
+ def method_missing(*)
61
+ return nil
62
+ end
63
+
58
64
  end
59
- end
65
+ end
@@ -1,3 +1,3 @@
1
1
  module Sequoia
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -34,7 +34,7 @@ describe Sequoia::Configurator do
34
34
  instance
35
35
  end
36
36
 
37
- let(:result) { config.build(env) }
37
+ let(:result) { config.build_config(env) }
38
38
 
39
39
  context 'without env' do
40
40
  let(:env) { nil }
@@ -52,7 +52,7 @@ describe Sequoia::Configurator do
52
52
  it 'should merge config' do
53
53
  expect(result.working_folder).to eql('/srv')
54
54
  expect(result.timeout).to eql(60)
55
- expect(result.cache).to be_false
55
+ expect(result.cache).to be(false)
56
56
  end
57
57
 
58
58
  it 'should merge namespaces' do
@@ -60,4 +60,12 @@ describe Sequoia::Configurator do
60
60
  expect(result.database.user).to eql('dev')
61
61
  end
62
62
  end
63
- end
63
+
64
+ context 'without configured env' do
65
+ let(:env) { :staging }
66
+
67
+ it 'should not raise exception' do
68
+ expect { result }.to_not raise_error
69
+ end
70
+ end
71
+ end
@@ -19,7 +19,7 @@ describe Sequoia::Builder, '#attrs' do
19
19
  end
20
20
 
21
21
  it 'should handle booleans' do
22
- expect(subject[:async]).to be_false
22
+ expect(subject[:async]).to be(false)
23
23
  end
24
24
 
25
25
  it 'should store hashes as hashes' do
@@ -81,4 +81,4 @@ describe Sequoia::Builder, '#attrs' do
81
81
  end
82
82
  end
83
83
 
84
- end
84
+ end
@@ -5,6 +5,6 @@ describe Sequoia::Builder, '#respond_to?' do
5
5
 
6
6
  it 'should respond to any method' do
7
7
  expect(instance).to respond_to(:qqeeellzmls)
8
- expect(instance.respond_to?(:qqeeellzmls)).to be_true
8
+ expect(instance.respond_to?(:qqeeellzmls)).to be(true)
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ describe Sequoia::Configurable, '#build' do
4
4
  let(:instance) { Class.new.send(:include, Sequoia::Configurable).new }
5
5
 
6
6
  it 'should return object if empty' do
7
- expect(instance.build).to be_an(Object)
7
+ expect(instance.build_configuration).to be_an(Object)
8
8
  end
9
9
 
10
10
  it 'should return entity if not empty' do
@@ -12,7 +12,7 @@ describe Sequoia::Configurable, '#build' do
12
12
  path '/home'
13
13
  end
14
14
 
15
- expect(instance.build).to be_a(Sequoia::Entity)
15
+ expect(instance.build_configuration).to be_a(Sequoia::Entity)
16
16
  end
17
17
 
18
18
  it 'should merge envs' do
@@ -24,7 +24,7 @@ describe Sequoia::Configurable, '#build' do
24
24
  log_level :info
25
25
  end
26
26
 
27
- expect(instance.build('test').path).to eq('/home')
28
- expect(instance.build(:test).log_level).to eq(:info)
27
+ expect(instance.build_configuration('test').path).to eq('/home')
28
+ expect(instance.build_configuration(:test).log_level).to eq(:info)
29
29
  end
30
- end
30
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sequoia::Entity, '#method_missing' do
4
+ let(:instance) { Sequoia::Entity.create(hash) }
5
+ let(:hash) { Sequoia::Store.new(working_folder: '/srv') }
6
+
7
+ it 'should not raise exception' do
8
+ expect { instance.nonexist }.to_not raise_error
9
+ end
10
+ end
@@ -12,4 +12,4 @@ describe Sequoia::Entity, '#pretty_inspect' do
12
12
  it 'should represent hash' do
13
13
  expect(subject).to match(/^\{\:?working_folder.*srv/)
14
14
  end
15
- end
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequoia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Savchenko
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-18 00:00:00.000000000 Z
12
+ date: 2014-03-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -79,6 +79,7 @@ files:
79
79
  - .gitignore
80
80
  - .rspec
81
81
  - .travis.yml
82
+ - CHANGELOG.md
82
83
  - Gemfile
83
84
  - LICENSE.txt
84
85
  - README.md
@@ -97,9 +98,10 @@ files:
97
98
  - spec/unit/sequoia/builder/class_spec.rb
98
99
  - spec/unit/sequoia/builder/respond_to_predicate_spec.rb
99
100
  - spec/unit/sequoia/builder/to_s_spec.rb
100
- - spec/unit/sequoia/configurable/build_spec.rb
101
+ - spec/unit/sequoia/configurable/build_configuration_spec.rb
101
102
  - spec/unit/sequoia/configurable/configure_spec.rb
102
103
  - spec/unit/sequoia/entity/class_methods/create_spec.rb
104
+ - spec/unit/sequoia/entity/method_missing_spec.rb
103
105
  - spec/unit/sequoia/entity/pretty_inspect_spec.rb
104
106
  - spec/unit/sequoia/entity/to_hash_spec.rb
105
107
  - spec/unit/sequoia/entity/to_s_spec.rb
@@ -136,9 +138,10 @@ test_files:
136
138
  - spec/unit/sequoia/builder/class_spec.rb
137
139
  - spec/unit/sequoia/builder/respond_to_predicate_spec.rb
138
140
  - spec/unit/sequoia/builder/to_s_spec.rb
139
- - spec/unit/sequoia/configurable/build_spec.rb
141
+ - spec/unit/sequoia/configurable/build_configuration_spec.rb
140
142
  - spec/unit/sequoia/configurable/configure_spec.rb
141
143
  - spec/unit/sequoia/entity/class_methods/create_spec.rb
144
+ - spec/unit/sequoia/entity/method_missing_spec.rb
142
145
  - spec/unit/sequoia/entity/pretty_inspect_spec.rb
143
146
  - spec/unit/sequoia/entity/to_hash_spec.rb
144
147
  - spec/unit/sequoia/entity/to_s_spec.rb