confstruct 1.0.1 → 1.0.2
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 +4 -4
- data/.travis.yml +3 -0
- data/confstruct.gemspec +1 -1
- data/lib/confstruct.rb +1 -1
- data/lib/confstruct/hash_with_struct_access.rb +9 -1
- data/spec/confstruct/configuration_spec.rb +5 -5
- data/spec/confstruct/hash_with_struct_access_spec.rb +10 -10
- data/spec/confstruct/utils_spec.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bced56b3d2b053a15f99a5fa1847c3dff09c79d2
|
4
|
+
data.tar.gz: 3bc0eda95a143b8d243f863d1a7e6ec0cb29034d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7229c6f8ecede1d20e3a52d40f495d381c24983ca801595da1c6c9e9ac02a13be8c95e1623bf3fabebbb22d62da42dc36eea239345f4e5f8928ecb43684456ca
|
7
|
+
data.tar.gz: 1dea2b2f0b4b9bc05330361974442e5e40765aafa30a6bcc825aebad3c56fd3915e3ff0de182f1ef9be04a431925c0e0604b570687b3250c174de40e729c38ad
|
data/.travis.yml
CHANGED
data/confstruct.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_development_dependency "rake", ">=0.8.7"
|
26
26
|
s.add_development_dependency "simplecov"
|
27
27
|
s.add_development_dependency "rdoc"
|
28
|
-
s.add_development_dependency "rspec", "~> 2.
|
28
|
+
s.add_development_dependency "rspec", "~> 2.99"
|
29
29
|
s.add_development_dependency "yard"
|
30
30
|
|
31
31
|
end
|
data/lib/confstruct.rb
CHANGED
@@ -122,6 +122,14 @@ module Confstruct
|
|
122
122
|
end
|
123
123
|
return val
|
124
124
|
end
|
125
|
+
|
126
|
+
def self.structurize hash
|
127
|
+
result = hash
|
128
|
+
if result.is_a?(Hash) and not result.is_a?(HashWithStructAccess)
|
129
|
+
result = HashWithStructAccess.new(result)
|
130
|
+
end
|
131
|
+
result
|
132
|
+
end
|
125
133
|
|
126
134
|
def method_missing sym, *args, &block
|
127
135
|
name = sym.to_s.chomp('=').to_sym
|
@@ -134,7 +142,7 @@ module Confstruct
|
|
134
142
|
raise TypeError, "Cannot #add! to a #{self[name].class}"
|
135
143
|
end
|
136
144
|
if args.length > 0
|
137
|
-
local_args = args.collect { |a| structurize
|
145
|
+
local_args = args.collect { |a| self.class.structurize a }
|
138
146
|
result = self[name].push *local_args
|
139
147
|
elsif block_given?
|
140
148
|
result = HashWithStructAccess.new
|
@@ -4,16 +4,16 @@ describe Confstruct::Configuration do
|
|
4
4
|
|
5
5
|
it "should initialize empty" do
|
6
6
|
conf = Confstruct::Configuration.new
|
7
|
-
conf.is_a?(Hash).should
|
8
|
-
conf.is_a?(Confstruct::Configuration).should
|
7
|
+
conf.is_a?(Hash).should be_truthy
|
8
|
+
conf.is_a?(Confstruct::Configuration).should be_truthy
|
9
9
|
conf.should == {}
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should initialize properly from a nested hash with string keys" do
|
13
13
|
x = { 'a' => { 'b' => 'c' } }
|
14
14
|
conf = Confstruct::Configuration.new(x)
|
15
|
-
conf.is_a?(Hash).should
|
16
|
-
conf.is_a?(Confstruct::Configuration).should
|
15
|
+
conf.is_a?(Hash).should be_truthy
|
16
|
+
conf.is_a?(Confstruct::Configuration).should be_truthy
|
17
17
|
conf[:a][:b].should == 'c'
|
18
18
|
conf['a']['b'].should == 'c'
|
19
19
|
conf.a.b.should == 'c'
|
@@ -137,7 +137,7 @@ describe Confstruct::Configuration do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
it "should call #after_config! when configuration is complete" do
|
140
|
-
postconfigurator =
|
140
|
+
postconfigurator = double('after_config!')
|
141
141
|
postconfigurator.should_receive(:configured!).once.with(@config)
|
142
142
|
def @config.after_config! obj
|
143
143
|
obj.project.should == 'other-project'
|
@@ -4,8 +4,8 @@ describe Confstruct::HashWithStructAccess do
|
|
4
4
|
|
5
5
|
it "should initialize empty" do
|
6
6
|
hwsa = Confstruct::HashWithStructAccess.new
|
7
|
-
hwsa.is_a?(Hash).should
|
8
|
-
hwsa.is_a?(Confstruct::HashWithStructAccess).should
|
7
|
+
hwsa.is_a?(Hash).should be_truthy
|
8
|
+
hwsa.is_a?(Confstruct::HashWithStructAccess).should be_truthy
|
9
9
|
hwsa.should == {}
|
10
10
|
end
|
11
11
|
|
@@ -72,8 +72,8 @@ describe Confstruct::HashWithStructAccess do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should properly respond to #has?" do
|
75
|
-
@hwsa.has?('github.url').should
|
76
|
-
@hwsa.has?('github.foo.bar.baz').should
|
75
|
+
@hwsa.has?('github.url').should be_truthy
|
76
|
+
@hwsa.has?('github.foo.bar.baz').should be_falsey
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should properly respond to #lookup!" do
|
@@ -204,9 +204,9 @@ describe Confstruct::HashWithStructAccess do
|
|
204
204
|
end
|
205
205
|
|
206
206
|
it "should only evaluate Confstruct::Deferred procs" do
|
207
|
-
@hwsa.github.regular_proc.is_a?(Proc).should
|
208
|
-
@hwsa.github.upcase_url.is_a?(Proc).should
|
209
|
-
@hwsa.github.reverse_url.is_a?(Proc).should
|
207
|
+
@hwsa.github.regular_proc.is_a?(Proc).should be_truthy
|
208
|
+
@hwsa.github.upcase_url.is_a?(Proc).should be_falsey
|
209
|
+
@hwsa.github.reverse_url.is_a?(Proc).should be_falsey
|
210
210
|
end
|
211
211
|
|
212
212
|
it "should instance_eval the proc with no params" do
|
@@ -233,9 +233,9 @@ describe Confstruct::HashWithStructAccess do
|
|
233
233
|
defproc deferred! { reverse_url + upcase_url }
|
234
234
|
regproc Kernel.lambda { reverse_url + upcase_url }
|
235
235
|
end
|
236
|
-
@hwsa.github.defproc.is_a?(Proc).should
|
236
|
+
@hwsa.github.defproc.is_a?(Proc).should be_falsey
|
237
237
|
@hwsa.github.defproc.should == @hwsa.github.reverse_url + @hwsa.github.upcase_url
|
238
|
-
@hwsa.github.regproc.is_a?(Proc).should
|
238
|
+
@hwsa.github.regproc.is_a?(Proc).should be_truthy
|
239
239
|
end
|
240
240
|
|
241
241
|
it "should handle i18n translations" do
|
@@ -269,7 +269,7 @@ describe Confstruct::HashWithStructAccess do
|
|
269
269
|
end
|
270
270
|
|
271
271
|
it "should gracefully handle being extended" do
|
272
|
-
|
272
|
+
skip %{probably won't fix due to the unpredictable way ActiveSupport injects #presence()}
|
273
273
|
@hwsa.a.b.presence.should be_a Confstruct::HashWithStructAccess
|
274
274
|
end
|
275
275
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe "Kernel.eval_or_yield" do
|
4
|
-
before :
|
5
|
-
@obj =
|
4
|
+
before :each do
|
5
|
+
@obj = double('obj')
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should instance_eval when the block takes no params" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confstruct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Klein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '2.
|
75
|
+
version: '2.99'
|
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
|
-
version: '2.
|
82
|
+
version: '2.99'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: yard
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.4.5
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: A simple, hash/struct-based configuration object
|