squire 1.2.6 → 1.3.6

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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NWY4ODFlMTY4YzIzYjlkNmVlNTIyYWQ2ODJkYzQ1M2UxYmU4ZjNlOQ==
5
- data.tar.gz: !binary |-
6
- NTZjNmZiM2JjNTY1ZjhjNmI2ZGE2YWRjZDllMjQyMjlhYzlmM2QwMg==
2
+ SHA1:
3
+ metadata.gz: db2bb28316c8d01b055c02e29df0c7bd8b85c3fe
4
+ data.tar.gz: da3ef166ef7889ae4efb019fcdc4a6dd8ec5e82e
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZDE2ZTNlYWQwMmU2OTdjMTg1MGE5ZGI5OTJkYTcxNWRmNDcxNmJkN2UzMTdj
10
- YTRkNjZkMTViZTQ3YWIyMzYxYzk4MmEzNGUwZTFhMTE3Y2MzNmUzOGQwYWYy
11
- YzNmZmE2Zjc3NDU5ZDU4ZjQ4YTBhMTczOTQ5M2ZmNGJmNWZiYWM=
12
- data.tar.gz: !binary |-
13
- MGQ4Nzg3Yjc3Yjc4MjFjOTBmZTg0ZTM2ZTVhZjk1NzkxNWE3NGM0NGM2Y2Zk
14
- MGMzMGMxMjg5Y2UwM2U5NmQ0NTQ2YzZkNjkzMjM2Nzk2ZTVhMDA1NThlNTI4
15
- OTlhNWNkYzA1YjBmNGUyNzRiZjcxNDUzNzM5OTdlOThlZDM2ODY=
6
+ metadata.gz: 86160134e6339a2efc5b8d735194c88fc13dc0b94ea242027d742db4d8afb2420e07fba0b9da41e598f064f994bb660a8e5e19cba877b55c6bbf2c133cf7774a
7
+ data.tar.gz: 90b34e2fcc12c5aa2b2235b90c6341b1d52d2db261fdfa9719c5c1bcb2e1d99fd8f8823350aafc6f2a96758aa6348afc2f336d8a6f2728e31ea7e67be9b121e9
@@ -116,6 +116,7 @@ module Squire
116
116
 
117
117
  result
118
118
  end
119
+ alias :to_h to_hash
119
120
 
120
121
  ##
121
122
  # Shows string representation of settings
@@ -1,3 +1,3 @@
1
1
  module Squire
2
- VERSION = '1.2.6'
2
+ VERSION = '1.3.6'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -8,5 +8,9 @@ require 'squire'
8
8
  Dir[File.join(File.expand_path(File.dirname(__FILE__)), "support/**/*.rb")].each { |f| require f }
9
9
 
10
10
  RSpec.configure do |config|
11
+ config.expect_with :rspec do |c|
12
+ c.syntax = :expect
13
+ end
14
+
11
15
  config.include Fixture
12
16
  end
@@ -11,7 +11,7 @@ describe Squire::Base do
11
11
  subject.squire.reload!
12
12
  end
13
13
 
14
- it 'should properly setup base configuration' do
14
+ it 'properly sets up base configuration' do
15
15
  subject.squire.source development: { a: 1, b: 2 }
16
16
  subject.squire.namespace :development
17
17
 
@@ -19,23 +19,23 @@ describe Squire::Base do
19
19
  config.c = 3
20
20
  end
21
21
 
22
- subject.config.a.should eql(1)
23
- subject.config.b.should eql(2)
24
- subject.config.c.should eql(3)
22
+ expect(subject.config.a).to eql(1)
23
+ expect(subject.config.b).to eql(2)
24
+ expect(subject.config.c).to eql(3)
25
25
 
26
- subject.a.should eql(1)
27
- subject.b.should eql(2)
28
- subject.c.should eql(3)
26
+ expect(subject.a).to eql(1)
27
+ expect(subject.b).to eql(2)
28
+ expect(subject.c).to eql(3)
29
29
 
30
30
  expect { subject.d }.to raise_error(Squire::MissingSettingError)
31
31
  end
32
32
 
33
- it 'should properly delegate keys' do
33
+ it 'properly delegates keys' do
34
34
  subject.squire.source test: { a: 1, b: 2 }
35
35
  subject.squire.namespace :test
36
36
 
37
- subject.a.should eql(1)
38
- subject.b.should eql(2)
37
+ expect(subject.a).to eql(1)
38
+ expect(subject.b).to eql(2)
39
39
 
40
40
  expect { subject.c }.to raise_error(Squire::MissingSettingError, /Missing setting 'c' in 'test'/)
41
41
  end
@@ -27,81 +27,81 @@ describe Squire::Configuration do
27
27
  }
28
28
 
29
29
  describe '#source' do
30
- it 'should properly set hash as source' do
30
+ it 'properly sets hash as source' do
31
31
  subject.source hash
32
32
 
33
- subject.source.should eql(hash)
33
+ expect(subject.source).to eql(hash)
34
34
  end
35
35
 
36
- it 'should properly set yaml sa a source' do
36
+ it 'properly sets yaml sa a source' do
37
37
  subject.source 'config.yml'
38
38
 
39
- subject.source.should eql('config.yml')
40
- subject.type.should eql(:yml)
39
+ expect(subject.source).to eql('config.yml')
40
+ expect(subject.type).to eql(:yml)
41
41
  end
42
42
  end
43
43
 
44
44
  describe '#namespace' do
45
- it 'should properly set namespace' do
45
+ it 'properly sets namespace' do
46
46
  subject.source hash
47
47
  subject.namespace :development
48
48
 
49
- subject.settings.a.should eql(1)
50
- subject.namespace.should eql(:development)
49
+ expect(subject.settings.a).to eql(1)
50
+ expect(subject.namespace).to eql(:development)
51
51
 
52
52
  expect { subject.settings.development }.to raise_exception(Squire::MissingSettingError)
53
53
  end
54
54
 
55
- it 'should properly handle runtime changing of namespaces' do
55
+ it 'properly handles runtime changing of namespaces' do
56
56
  subject.source hash
57
57
  subject.namespace :development
58
58
 
59
- subject.settings.a.should eql(1)
59
+ expect(subject.settings.a).to eql(1)
60
60
 
61
61
  subject.namespace :production
62
62
 
63
- subject.settings.a.should eql(3)
63
+ expect(subject.settings.a).to eql(3)
64
64
  end
65
65
 
66
- it 'should handle base namespace overriding' do
66
+ it 'handles base namespace overriding' do
67
67
  subject.source hash
68
68
  subject.namespace :development, base: :defaults
69
69
 
70
- subject.settings.a.should eql(1)
71
- subject.settings.nested.b.should eql(2) # from development.nested.b
72
- subject.settings.nested.d.should be_false # from development.nested.d
73
- subject.settings.nested.c.should eql(4) # from defaults.nested.c
70
+ expect(subject.settings.a).to eql(1)
71
+ expect(subject.settings.nested.b).to eql(2) # from development.nested.b
72
+ expect(subject.settings.nested.d).to be_false # from development.nested.d
73
+ expect(subject.settings.nested.c).to eql(4) # from defaults.nested.c
74
74
 
75
75
  subject.source hash
76
76
  subject.namespace :production, base: :defaults
77
77
 
78
- subject.settings.a.should eql(3)
79
- subject.settings.nested.b.should eql(4) # from development.nested.b
80
- subject.settings.nested.d.should be_true # from development.nested.d
78
+ expect(subject.settings.a).to eql(3)
79
+ expect(subject.settings.nested.b).to eql(4) # from development.nested.b
80
+ expect(subject.settings.nested.d).to be_true # from development.nested.d
81
81
  end
82
82
  end
83
83
 
84
84
  describe '#setup' do
85
- let(:path) { '/path/to/file.yml'}
85
+ let(:path) { '/path/to/file.yml'}
86
86
  let(:factory) { double(:factory) }
87
87
  let(:parser) { double(:parser) }
88
88
 
89
- it 'should setup basic settings from hash' do
89
+ it 'sets up basic settings from hash' do
90
90
  subject.source(hash)
91
91
 
92
- factory.should_receive(:of).with(:hash).and_return(parser)
93
- parser.should_receive(:parse).with(hash).and_return(hash)
92
+ expect(factory).to receive(:of).with(:hash).and_return(parser)
93
+ expect(parser).to receive(:parse).with(hash).and_return(hash)
94
94
 
95
95
  stub_const('Squire::Parser', factory)
96
96
 
97
97
  settings = subject.setup
98
98
 
99
- settings.to_hash.should eql(hash)
99
+ expect(settings.to_hash).to eql(hash)
100
100
  end
101
101
 
102
- it 'should setup basic settings yml' do
103
- factory.should_receive(:of).with(:yml).and_return(parser)
104
- parser.should_receive(:parse).with(path).and_return(hash)
102
+ it 'sets up basic settings yml' do
103
+ expect(factory).to receive(:of).with(:yml).and_return(parser)
104
+ expect(parser).to receive(:parse).with(path).and_return(hash)
105
105
 
106
106
  stub_const('Squire::Parser', factory)
107
107
 
@@ -109,11 +109,11 @@ describe Squire::Configuration do
109
109
 
110
110
  settings = subject.settings
111
111
 
112
- settings.development.a.should eql(1)
113
- settings.development.nested.b.should eql(2)
112
+ expect(settings.development.a).to eql(1)
113
+ expect(settings.development.nested.b).to eql(2)
114
114
  end
115
115
 
116
- it 'should not setup source with unknown filetype' do
116
+ it 'does not set up source with unknown filetype' do
117
117
  subject.source(path, type: :bogus)
118
118
 
119
119
  expect { subject.setup }.to raise_error Squire::UndefinedParserError
@@ -5,16 +5,16 @@ describe Hash do
5
5
  let(:a) {{ a: 1, b: 2, c: 3, nested: { a: 1 }}}
6
6
  let(:b) {{ a: 1, c: 3, d: 4, nested: { a: 2, b: 3 }}}
7
7
 
8
- it 'should merge hashes deeply' do
8
+ it 'merges hashes deeply' do
9
9
  merge = { a: 1, b: 2, c: 3, d: 4, nested: { a: 2, b: 3 }}
10
10
 
11
- a.deep_merge(b).should eql(merge)
11
+ expect(a.deep_merge(b)).to eql(merge)
12
12
  end
13
13
 
14
- it 'should merge hashes deeply with block' do
14
+ it 'merges hashes deeply with block' do
15
15
  merge = { a: [:a, 1, 1], b: 2, c: [:c, 3, 3], d: [:d, nil, 4], nested: { a: [:a, 1, 2], b: [:b, nil, 3] }}
16
16
 
17
- (a.deep_merge(b) { |key, old, new| [key, old, new] }).should eql(merge)
17
+ expect(a.deep_merge(b) { |key, old, new| [key, old, new] }).to eql(merge)
18
18
  end
19
19
  end
20
20
  end
@@ -3,11 +3,11 @@ require 'spec_helper'
3
3
  describe Squire::Parser::Hash do
4
4
  subject { Squire::Parser::Hash }
5
5
 
6
- it 'should parse source hash' do
6
+ it 'parses source hash' do
7
7
  source = { 'a' => 1, 'b' => 2, 'nested' => { 'c' => 2} }
8
8
 
9
9
  hash = subject.parse(source)
10
10
 
11
- hash.should eql(source)
11
+ expect(hash).to eql(source)
12
12
  end
13
13
  end
@@ -3,10 +3,10 @@ require 'spec_helper'
3
3
  describe Squire::Parser::YAML do
4
4
  subject { described_class }
5
5
 
6
- it 'should parse yaml file from path' do
6
+ it 'parses yaml file from path' do
7
7
  hash = subject.parse(fixture('basic.yml').path)
8
8
 
9
- hash.should eql(
9
+ expect(hash).to eql(
10
10
  'defaults' => nil,
11
11
  'development' => {
12
12
  'a' => 1,
@@ -13,7 +13,7 @@ describe Squire::Proxy do
13
13
 
14
14
  let(:another) { AnotherProxiedConfiguration}
15
15
 
16
- it 'should properly setup proxied configuration' do
16
+ it 'properly sets up proxied configuration' do
17
17
  subject.squire.source development: { a: 1, b: 2 }
18
18
  subject.squire.namespace :development
19
19
 
@@ -21,26 +21,26 @@ describe Squire::Proxy do
21
21
  config.c = 3
22
22
  end
23
23
 
24
- subject.config.a.should eql(1)
25
- subject.config.b.should eql(2)
26
- subject.config.c.should eql(3)
24
+ expect(subject.config.a).to eql(1)
25
+ expect(subject.config.b).to eql(2)
26
+ expect(subject.config.c).to eql(3)
27
27
 
28
28
  expect { subject.a }.to raise_error(NoMethodError)
29
29
  end
30
30
 
31
- it 'should properly setup separate proxies' do
31
+ it 'properly sets up separate proxies' do
32
32
  subject.squire.source development: { a: 1, b: 2 }
33
33
  subject.squire.namespace :development
34
34
 
35
35
  another.squire.source production: { a: 3, b: 4 }
36
36
  another.squire.namespace :production
37
37
 
38
- subject.squire.namespace.should eql(:development)
39
- subject.config.a.should eql(1)
40
- subject.config.b.should eql(2)
38
+ expect(subject.squire.namespace).to eql(:development)
39
+ expect(subject.config.a).to eql(1)
40
+ expect(subject.config.b).to eql(2)
41
41
 
42
- another.squire.namespace.should eql(:production)
43
- another.config.a.should eql(3)
44
- another.config.b.should eql(4)
42
+ expect(another.squire.namespace).to eql(:production)
43
+ expect(another.config.a).to eql(3)
44
+ expect(another.config.b).to eql(4)
45
45
  end
46
46
  end
@@ -5,17 +5,17 @@ require 'spec_helper'
5
5
  describe Squire::Settings do
6
6
  subject { Squire::Settings }
7
7
 
8
- it 'should define simple configuration' do
8
+ it 'defines simple configuration' do
9
9
  config = subject.new
10
10
 
11
11
  config.a = 1
12
12
  config.b = 2
13
13
 
14
- config.a.should eql(1)
15
- config.b.should eql(2)
14
+ expect(config.a).to eql(1)
15
+ expect(config.b).to eql(2)
16
16
  end
17
17
 
18
- it 'should define nested configuration' do
18
+ it 'defines nested configuration' do
19
19
  config = subject.new
20
20
 
21
21
  config.nested do |nested|
@@ -26,11 +26,11 @@ describe Squire::Settings do
26
26
  nested.b = 2
27
27
  end
28
28
 
29
- config.nested.a.should eql(1)
30
- config.nested.b.should eql(2)
29
+ expect(config.nested.a).to eql(1)
30
+ expect(config.nested.b).to eql(2)
31
31
  end
32
32
 
33
- it 'should check if the value is set' do
33
+ it 'checks if the value is set' do
34
34
  config = subject.new
35
35
 
36
36
  config.a = 1
@@ -38,13 +38,13 @@ describe Squire::Settings do
38
38
  nested.b = 2
39
39
  end
40
40
 
41
- config.a?.should be_true
42
- config.nested.b?.should be_true
43
- config.nested.a?.should be_false
44
- config.global?.should be_false
41
+ expect(config.a?).to be_true
42
+ expect(config.nested.b?).to be_true
43
+ expect(config.nested.a?).to be_false
44
+ expect(config.global?).to be_false
45
45
  end
46
46
 
47
- it 'should cache value after setting' do
47
+ it 'caches value after setting' do
48
48
  config = subject.new
49
49
 
50
50
  config.a = 1
@@ -52,18 +52,30 @@ describe Squire::Settings do
52
52
  nested.b = 2
53
53
  end
54
54
 
55
- config.should respond_to(:a)
56
- config.nested.should respond_to(:b)
55
+ expect(config).to respond_to(:a)
56
+ expect(config.nested).to respond_to(:b)
57
57
  end
58
58
 
59
- it 'should raise error when setting is missing' do
59
+ it 'raises error when setting is missing' do
60
60
  config = subject.new
61
61
 
62
62
  expect { config.a }.to raise_error(Squire::MissingSettingError, /Missing setting 'a'/)
63
63
  end
64
64
 
65
+ it 'behaves as plain object' do
66
+ config = subject.new
67
+
68
+ config.puts = 1
69
+ config.test do |nested|
70
+ nested.a = 2
71
+ end
72
+
73
+ expect(config.puts).to eql(1)
74
+ expect(config.test.a).to eql(2)
75
+ end
76
+
65
77
  describe '#to_s' do
66
- it 'should convert settings to string representation' do
78
+ it 'converts settings to string representation' do
67
79
  config = subject.new
68
80
 
69
81
  config.a = 1
@@ -73,24 +85,24 @@ describe Squire::Settings do
73
85
  nested.c = 3
74
86
  end
75
87
 
76
- config.to_s.should eql('#<Squire::Settings a=1, b=2, nested=#<Squire::Settings c=3>>')
88
+ expect(config.to_s).to eql('#<Squire::Settings a=1, b=2, nested=#<Squire::Settings c=3>>')
77
89
  end
78
90
  end
79
91
 
80
92
  describe '#[]' do
81
- it 'should allow accesing keys in hash manner' do
93
+ it 'allows accesing keys in hash manner' do
82
94
  config = subject.new
83
95
 
84
96
  config.a = 1
85
97
 
86
- config[:a].should eql(1)
87
- config['a'].should eql(1)
88
- config[:b].should be_nil
98
+ expect(config[:a]).to eql(1)
99
+ expect(config['a']).to eql(1)
100
+ expect(config[:b]).to be_nil
89
101
  end
90
102
  end
91
103
 
92
104
  describe '#to_hash' do
93
- it 'should properly dump settings as hash' do
105
+ it 'properly dumps settings as hash' do
94
106
  config = subject.new
95
107
 
96
108
  config.a = 1
@@ -105,7 +117,7 @@ describe Squire::Settings do
105
117
  end
106
118
  end
107
119
 
108
- config.to_hash.should eql({
120
+ expect(config.to_hash).to eql({
109
121
  a: 1,
110
122
  b: 2,
111
123
  nested: {
@@ -120,7 +132,7 @@ describe Squire::Settings do
120
132
  end
121
133
 
122
134
  describe '.from_hash' do
123
- it 'it should parse settings from hash' do
135
+ it 'parses settings from hash' do
124
136
  settings = subject.from_hash({
125
137
  a: 1,
126
138
  b: 2,
@@ -133,15 +145,15 @@ describe Squire::Settings do
133
145
  }
134
146
  })
135
147
 
136
- settings.a.should eql(1)
137
- settings.b.should eql(2)
148
+ expect(settings.a).to eql(1)
149
+ expect(settings.b).to eql(2)
138
150
 
139
151
  settings.nested do |nested|
140
- nested.c.should eql(3)
141
- nested.d.should eql(4)
152
+ expect(nested.c).to eql(3)
153
+ expect(nested.d).to eql(4)
142
154
 
143
155
  nested.other do |other|
144
- other.e.should eql(5)
156
+ expect(other.e).to eql(5)
145
157
  end
146
158
  end
147
159
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squire
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Molnar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-09 00:00:00.000000000 Z
11
+ date: 2014-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
@@ -42,42 +42,42 @@ dependencies:
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: fuubar
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: settingslogic
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Squire handles your configuration by common config DSL.
@@ -128,17 +128,17 @@ require_paths:
128
128
  - lib
129
129
  required_ruby_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - ! '>='
131
+ - - '>='
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ! '>='
136
+ - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  requirements: []
140
140
  rubyforge_project:
141
- rubygems_version: 2.1.2
141
+ rubygems_version: 2.0.3
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: Squire handles your configuration per class/file by common config DSL and