attribute_struct 0.2.2 → 0.2.4
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 +7 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +2 -2
- data/lib/attribute_struct/attribute_struct.rb +5 -11
- data/lib/attribute_struct/version.rb +1 -1
- data/test/specs/collapse.rb +1 -4
- metadata +20 -26
- data/attribute_struct-0.2.0.gem +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 709d30c8e86eba9009d9fca15051da16231cd56a
|
4
|
+
data.tar.gz: e8d57a6e7b239b494208dd58614502220775ebe6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 061d981d6a1d49882acf7acea0c231b0111e0163e47a448c5bb71b3ebdcec3ac5a077950d9a6237e3eb75050fcdf2883a9d46619a507fc147b9b0be920128b98
|
7
|
+
data.tar.gz: 9bc6279dc98283f19a27c09fc920ccd28455f34f2629c4573f50fb13d47b8fa2189b4216d3211e355d0c6511d531440a4e6f81232e3357bd0e2dd85555428ebb
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## v0.2.4
|
2
|
+
* Revert #class method removal (required by hash helpers when duping)
|
3
|
+
* Set base prior to path walking
|
4
|
+
* Initialize struct if nil is encountered
|
5
|
+
* Collapse values at leaf
|
6
|
+
|
1
7
|
## v0.2.2
|
2
8
|
* Update block evaluation assignment to prevent value knockout
|
3
9
|
* Fix `#is_a?` behavior and include base class in check list
|
data/Gemfile.lock
CHANGED
@@ -190,12 +190,9 @@ class AttributeStruct < BasicObject
|
|
190
190
|
end
|
191
191
|
end
|
192
192
|
elsif(!args.empty? && block)
|
193
|
-
base = @table
|
194
|
-
|
195
|
-
key = sym
|
196
|
-
args.each do |arg|
|
193
|
+
result = leaf = base = @table.fetch(sym, _klass_new)
|
194
|
+
args.flatten.each do |arg|
|
197
195
|
leaf = base[arg]
|
198
|
-
key = arg
|
199
196
|
unless(leaf.is_a?(_klass))
|
200
197
|
leaf = _klass_new
|
201
198
|
base._set(arg, leaf)
|
@@ -206,18 +203,14 @@ class AttributeStruct < BasicObject
|
|
206
203
|
orig = leaf
|
207
204
|
leaf = orig.parent._klass_new
|
208
205
|
end
|
209
|
-
|
210
|
-
leaf.instance_exec(&block)
|
211
|
-
else
|
212
|
-
leaf.instance_exec(leaf, &block)
|
213
|
-
end
|
206
|
+
block.arity == 0 ? leaf._build(&block) : leaf._build(leaf, &block)
|
214
207
|
if(orig)
|
215
208
|
orig = [orig] unless orig.is_a?(::Array)
|
216
209
|
orig << leaf
|
217
210
|
else
|
218
211
|
orig = leaf
|
219
212
|
end
|
220
|
-
@table[sym] =
|
213
|
+
@table[sym] = result
|
221
214
|
else
|
222
215
|
if(args.size > 1)
|
223
216
|
@table[sym] = _klass_new unless @table[sym].is_a?(_klass)
|
@@ -421,6 +414,7 @@ class AttributeStruct < BasicObject
|
|
421
414
|
end
|
422
415
|
alias_method :klass!, :_klass
|
423
416
|
alias_method :class!, :_klass
|
417
|
+
alias_method :class, :_klass
|
424
418
|
|
425
419
|
# @return [AttributeStruct] new struct instance
|
426
420
|
# @note will set self as parent and propogate camelizing status
|
data/test/specs/collapse.rb
CHANGED
@@ -67,10 +67,7 @@ describe AttributeStruct do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should return both assigned values as an array' do
|
70
|
-
@dump['direct'].must_equal [
|
71
|
-
{'assignment' => true},
|
72
|
-
{'assignment' => false}
|
73
|
-
]
|
70
|
+
@dump['direct']['assignment'].must_equal [true, false]
|
74
71
|
end
|
75
72
|
|
76
73
|
end
|
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attribute_struct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Chris Roberts
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-06-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: hashie
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 2.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 2.0.0
|
30
27
|
description: Attribute structures
|
@@ -33,49 +30,46 @@ executables: []
|
|
33
30
|
extensions: []
|
34
31
|
extra_rdoc_files: []
|
35
32
|
files:
|
33
|
+
- CHANGELOG.md
|
34
|
+
- CONTRIBUTING.md
|
35
|
+
- Gemfile
|
36
|
+
- Gemfile.lock
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- attribute_struct.gemspec
|
36
40
|
- lib/attribute_struct.rb
|
41
|
+
- lib/attribute_struct/attribute_hash.rb
|
37
42
|
- lib/attribute_struct/attribute_struct.rb
|
38
|
-
- lib/attribute_struct/version.rb
|
39
43
|
- lib/attribute_struct/irb_compat.rb
|
40
|
-
- lib/attribute_struct/attribute_hash.rb
|
41
44
|
- lib/attribute_struct/monkey_camels.rb
|
42
|
-
- attribute_struct
|
45
|
+
- lib/attribute_struct/version.rb
|
43
46
|
- test/spec.rb
|
44
|
-
- test/specs/camel.rb
|
45
|
-
- test/specs/merging.rb
|
46
47
|
- test/specs/basic.rb
|
48
|
+
- test/specs/camel.rb
|
47
49
|
- test/specs/collapse.rb
|
48
|
-
-
|
49
|
-
- README.md
|
50
|
-
- LICENSE
|
51
|
-
- attribute_struct.gemspec
|
52
|
-
- CHANGELOG.md
|
53
|
-
- CONTRIBUTING.md
|
54
|
-
- Gemfile.lock
|
50
|
+
- test/specs/merging.rb
|
55
51
|
homepage: http://github.com/chrisroberts/attribute_struct
|
56
52
|
licenses:
|
57
53
|
- Apache 2.0
|
54
|
+
metadata: {}
|
58
55
|
post_install_message:
|
59
56
|
rdoc_options: []
|
60
57
|
require_paths:
|
61
58
|
- lib
|
62
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
60
|
requirements:
|
65
|
-
- -
|
61
|
+
- - ">="
|
66
62
|
- !ruby/object:Gem::Version
|
67
63
|
version: '0'
|
68
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
65
|
requirements:
|
71
|
-
- -
|
66
|
+
- - ">="
|
72
67
|
- !ruby/object:Gem::Version
|
73
68
|
version: '0'
|
74
69
|
requirements: []
|
75
70
|
rubyforge_project:
|
76
|
-
rubygems_version:
|
71
|
+
rubygems_version: 2.2.2
|
77
72
|
signing_key:
|
78
|
-
specification_version:
|
73
|
+
specification_version: 4
|
79
74
|
summary: Attribute structures
|
80
75
|
test_files: []
|
81
|
-
has_rdoc:
|
data/attribute_struct-0.2.0.gem
DELETED
Binary file
|