structure 0.23.0 → 0.23.1

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --no-private
2
+ lib/**/*.rb
data/README.md CHANGED
@@ -3,6 +3,6 @@
3
3
  > Machines only work when they break down and by continually breaking
4
4
  > down.
5
5
 
6
- [Delve into the API.](http://rubydoc.info/github/hakanensari/structure/master/frames)
6
+ [Read the API.](http://rubydoc.info/github/hakanensari/structure/master/Structure)
7
7
 
8
8
  [![travis](https://secure.travis-ci.org/hakanensari/structure.png?branch=master)](http://travis-ci.org/hakanensari/structure)
data/lib/structure.rb CHANGED
@@ -65,6 +65,7 @@ end
65
65
  # ephemeral landscape of APIs.
66
66
  class Structure
67
67
  class << self
68
+ # @private
68
69
  attr_accessor :blueprint
69
70
 
70
71
  # Builds a structure out of a JSON representation.
@@ -118,7 +119,8 @@ class Structure
118
119
  # on the class level, but I decided to privilege consistency here.
119
120
  # Who wouldn't?
120
121
  @table = blueprint.inject({}) do |a, (k, v)|
121
- a.merge new_field(k, v[:type]) => v[:default]
122
+ default = v[:default].dup rescue v[:default]
123
+ a.merge new_field(k, v[:type]) => default
122
124
  end
123
125
 
124
126
  marshal_load(hsh)
@@ -1,4 +1,5 @@
1
1
  class Structure
2
+ # @private
2
3
  module Ext
3
4
  module ActiveSupport
4
5
  def as_json(options = nil)
@@ -1,3 +1,3 @@
1
1
  class Structure
2
- VERSION = '0.23.0'
2
+ VERSION = '0.23.1'
3
3
  end
@@ -13,7 +13,7 @@ class Foo < Structure
13
13
  field :bar, Hash
14
14
  end
15
15
 
16
- class TestDefinedStructure < MiniTest::Unit::TestCase
16
+ class TestStructureWithFields < MiniTest::Unit::TestCase
17
17
  def setup
18
18
  @product = Product.new(:title => 'Widget')
19
19
  end
@@ -48,7 +48,7 @@ class TestDefinedStructure < MiniTest::Unit::TestCase
48
48
  assert_equal [], @product.related
49
49
  end
50
50
 
51
- def test_hashes_with_recursion
51
+ def test_recursive_hashes
52
52
  foo = Foo.new('bar' => { 'baz' => 1 })
53
53
  hsh = foo.marshal_dump
54
54
  foo.marshal_load(hsh)
@@ -57,4 +57,11 @@ class TestDefinedStructure < MiniTest::Unit::TestCase
57
57
  json = foo.to_json
58
58
  assert foo, JSON.parse(json)
59
59
  end
60
+
61
+ def test_recursive_array_handling
62
+ related = Product.new
63
+ @product.related << related
64
+ assert_equal [related], @product.related
65
+ assert_equal [], @product.related.first.related
66
+ end
60
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.23.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-07 00:00:00.000000000 Z
12
+ date: 2011-12-08 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Structure is a key/value container.
15
15
  email:
@@ -20,6 +20,7 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - .gitignore
22
22
  - .travis.yml
23
+ - .yardopts
23
24
  - Gemfile
24
25
  - LICENSE
25
26
  - README.md
@@ -28,9 +29,9 @@ files:
28
29
  - lib/structure/ext/active_support.rb
29
30
  - lib/structure/version.rb
30
31
  - structure.gemspec
31
- - test/defined_structure_test.rb
32
32
  - test/helper.rb
33
33
  - test/structure_test.rb
34
+ - test/structure_with_fields_test.rb
34
35
  homepage: http://github.com/hakanensari/structure
35
36
  licenses: []
36
37
  post_install_message:
@@ -43,12 +44,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
43
44
  - - ! '>='
44
45
  - !ruby/object:Gem::Version
45
46
  version: '0'
47
+ segments:
48
+ - 0
49
+ hash: 2719962180742855248
46
50
  required_rubygems_version: !ruby/object:Gem::Requirement
47
51
  none: false
48
52
  requirements:
49
53
  - - ! '>='
50
54
  - !ruby/object:Gem::Version
51
55
  version: '0'
56
+ segments:
57
+ - 0
58
+ hash: 2719962180742855248
52
59
  requirements: []
53
60
  rubyforge_project: structure
54
61
  rubygems_version: 1.8.11
@@ -56,6 +63,6 @@ signing_key:
56
63
  specification_version: 3
57
64
  summary: A key/value container
58
65
  test_files:
59
- - test/defined_structure_test.rb
60
66
  - test/helper.rb
61
67
  - test/structure_test.rb
68
+ - test/structure_with_fields_test.rb