autoparse 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ # 0.3.3
2
+
3
+ * Fixed issue with parent class redefinition
4
+
1
5
  # 0.3.2
2
6
 
3
7
  * Fixed issue with booleans and default values
@@ -15,6 +15,8 @@
15
15
  require 'autoparse/instance'
16
16
  require 'autoparse/version'
17
17
  require 'addressable/uri'
18
+ require 'multi_json'
19
+ require 'compat/multi_json'
18
20
 
19
21
  module AutoParse
20
22
  def self.schemas
@@ -138,7 +140,7 @@ module AutoParse
138
140
  end
139
141
 
140
142
  # Register the new schema.
141
- self.schemas[schema.uri] = schema
143
+ self.schemas[schema.uri] = schema unless parent && parent.uri == schema.uri
142
144
  return schema
143
145
  end
144
146
 
@@ -332,7 +334,7 @@ module AutoParse
332
334
  elsif value.respond_to?(:to_hash)
333
335
  value.to_hash
334
336
  elsif value.respond_to?(:to_json)
335
- MultiJson.decode(value.to_json)
337
+ MultiJson.load(value.to_json)
336
338
  else
337
339
  raise TypeError, "Expected Hash, got #{value.class}."
338
340
  end
@@ -14,6 +14,7 @@
14
14
 
15
15
 
16
16
  require 'multi_json'
17
+ require 'compat/multi_json'
17
18
  require 'time'
18
19
  require 'autoparse/inflection'
19
20
  require 'addressable/uri'
@@ -458,7 +459,7 @@ module AutoParse
458
459
  # Ignores extra arguments to avoid throwing errors w/ certain JSON
459
460
  # libraries.
460
461
  def to_json(*args)
461
- return MultiJson.encode(self.to_hash)
462
+ return MultiJson.dump(self.to_hash)
462
463
  end
463
464
 
464
465
  ##
@@ -18,7 +18,7 @@ unless defined? AutoParse::VERSION
18
18
  module VERSION
19
19
  MAJOR = 0
20
20
  MINOR = 3
21
- TINY = 2
21
+ TINY = 3
22
22
 
23
23
  STRING = [MAJOR, MINOR, TINY].join('.')
24
24
  end
@@ -0,0 +1,17 @@
1
+ gem 'multi_json', '>= 1.0.0'
2
+ require 'multi_json'
3
+
4
+ unless MultiJson.respond_to?(:load)
5
+ module MultiJson
6
+ class <<self
7
+ alias :load :decode
8
+ end
9
+ end
10
+ end
11
+ unless MultiJson.respond_to?(:dump)
12
+ module MultiJson
13
+ class <<self
14
+ alias :dump :encode
15
+ end
16
+ end
17
+ end
@@ -1581,6 +1581,47 @@ describe AutoParse::Instance, 'with the file schema' do
1581
1581
  file.items.first.parents.first.should be_an_instance_of @parentref_parser
1582
1582
  end
1583
1583
 
1584
+
1585
+ it 'should not redefine the parent when accessing anonymous children' do
1586
+ file_json = {
1587
+ "kind" => "drive#file",
1588
+ "id" => "0Bz2X2-r-Ou9fYTJFLVFYZENzMjA",
1589
+ "parents" => [
1590
+ {
1591
+ "kind" => "drive#parentReference",
1592
+ "id" => "0AD2X2-r-Ou9fUk9PVA",
1593
+ }]
1594
+ }
1595
+
1596
+ list_json = {
1597
+ "kind" => "drive#fileList",
1598
+ "items" => [
1599
+ {
1600
+ "kind" => "drive#file",
1601
+ "id" => "0Bz2X2-r-Ou9fYTJFLVFYZENzMjA",
1602
+ "parents" => [
1603
+ {
1604
+ "kind" => "drive#parentReference",
1605
+ "id" => "0AD2X2-r-Ou9fUk9PVA",
1606
+ }
1607
+ ],
1608
+ }
1609
+ ]
1610
+ }
1611
+
1612
+ file = @file_parser.new(file_json)
1613
+ file.should be_an_instance_of @file_parser
1614
+ file.parents.first.should be_an_instance_of @parentref_parser
1615
+
1616
+ # Regression check for bug where accessing the parents property would redefine
1617
+ # file. This resulted in an inability to parse that type later on, such as when
1618
+ # used in the items array.
1619
+ list = @filelist_parser.new(list_json)
1620
+ list.should be_an_instance_of @filelist_parser
1621
+ list.items.first.should be_an_instance_of @file_parser
1622
+ list.items.first.parents.first.should be_an_instance_of @parentref_parser
1623
+ end
1624
+
1584
1625
  it 'should handle booleans correctly' do
1585
1626
  file = @filelist_parser.new(@data)
1586
1627
  file.should be_an_instance_of @filelist_parser
metadata CHANGED
@@ -1,99 +1,129 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: autoparse
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.3
4
5
  prerelease:
5
- version: 0.3.2
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Bob Aman
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-07-31 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2013-03-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: addressable
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
23
21
  version: 2.3.1
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: multi_json
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
30
25
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.3.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: multi_json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
34
37
  version: 1.0.0
35
38
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: extlib
39
39
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: extlib
48
+ requirement: !ruby/object:Gem::Requirement
41
49
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
45
53
  version: 0.9.15
46
54
  type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: rake
50
55
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.15
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
52
65
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
56
69
  version: 0.9.0
57
70
  type: :development
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: rspec
61
71
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 0.9.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
63
81
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
67
85
  version: 2.11.0
68
86
  type: :development
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
- name: launchy
72
87
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
74
89
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 2.11.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: launchy
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
78
101
  version: 2.1.1
79
102
  type: :development
80
- version_requirements: *id006
81
- description: |
82
- An implementation of the JSON Schema specification. Provides automatic parsing
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 2.1.1
110
+ description: ! 'An implementation of the JSON Schema specification. Provides automatic
111
+ parsing
112
+
83
113
  for any given JSON Schema.
84
114
 
115
+ '
85
116
  email: bobaman@google.com
86
117
  executables: []
87
-
88
118
  extensions: []
89
-
90
- extra_rdoc_files:
119
+ extra_rdoc_files:
91
120
  - README.md
92
- files:
121
+ files:
122
+ - lib/autoparse.rb
93
123
  - lib/autoparse/inflection.rb
94
124
  - lib/autoparse/instance.rb
95
125
  - lib/autoparse/version.rb
96
- - lib/autoparse.rb
126
+ - lib/compat/multi_json.rb
97
127
  - spec/autoparse/instance_spec.rb
98
128
  - spec/data/account.json
99
129
  - spec/data/address.json
@@ -123,40 +153,35 @@ files:
123
153
  - tasks/rdoc.rake
124
154
  - tasks/spec.rake
125
155
  - tasks/yard.rake
126
- - website/index.html
127
156
  - CHANGELOG.md
128
157
  - Gemfile
129
- - Gemfile.lock
130
158
  - LICENSE
131
- - Rakefile
132
159
  - README.md
160
+ - Rakefile
133
161
  homepage: http://autoparse.rubyforge.org/
134
162
  licenses: []
135
-
136
163
  post_install_message:
137
- rdoc_options:
164
+ rdoc_options:
138
165
  - --main
139
166
  - README.md
140
- require_paths:
167
+ require_paths:
141
168
  - lib
142
- required_ruby_version: !ruby/object:Gem::Requirement
169
+ required_ruby_version: !ruby/object:Gem::Requirement
143
170
  none: false
144
- requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- version: "0"
148
- required_rubygems_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
176
  none: false
150
- requirements:
151
- - - ">="
152
- - !ruby/object:Gem::Version
153
- version: "0"
177
+ requirements:
178
+ - - ! '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
154
181
  requirements: []
155
-
156
182
  rubyforge_project: autoparse
157
183
  rubygems_version: 1.8.24
158
184
  signing_key:
159
185
  specification_version: 3
160
186
  summary: A parsing system based on JSON Schema.
161
187
  test_files: []
162
-
@@ -1,32 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- addressable (2.3.1)
5
- diff-lcs (1.1.3)
6
- extlib (0.9.15)
7
- multi_json (1.3.6)
8
- rake (0.9.2.2)
9
- rcov (1.0.0)
10
- redcarpet (2.1.1)
11
- rspec (2.11.0)
12
- rspec-core (~> 2.11.0)
13
- rspec-expectations (~> 2.11.0)
14
- rspec-mocks (~> 2.11.0)
15
- rspec-core (2.11.1)
16
- rspec-expectations (2.11.1)
17
- diff-lcs (~> 1.1.3)
18
- rspec-mocks (2.11.1)
19
- yard (0.8.2.1)
20
-
21
- PLATFORMS
22
- ruby
23
-
24
- DEPENDENCIES
25
- addressable (>= 2.3.1)
26
- extlib (>= 0.9.15)
27
- multi_json (>= 1.0.0)
28
- rake (>= 0.9.0)
29
- rcov (>= 0.9.9)
30
- redcarpet
31
- rspec (>= 2.11.0)
32
- yard
@@ -1,95 +0,0 @@
1
- <!DOCTYPE html>
2
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
3
- <head>
4
- <meta charset="utf-8"/>
5
- <title>AutoParse</title>
6
- <style type="text/css">
7
- * {
8
- font-size: 100%;
9
- margin: 0;
10
- padding: 0;
11
- }
12
-
13
- body {
14
- font-family: "Lucida Grande", Verdana, sans-serif;
15
- margin: 1em;
16
- }
17
-
18
- a {
19
- color: #880000;
20
- }
21
-
22
- a:visited {
23
- color: #333333;
24
- }
25
-
26
- h1 {
27
- font-size: 2em;
28
- margin: 0 0 0.8em 0;
29
- text-align: center;
30
- }
31
-
32
- h2 {
33
- font-size: 1em;
34
- margin: 0.8em 0;
35
- }
36
-
37
- p {
38
- margin: 0.8em 0;
39
- }
40
-
41
- ul {
42
- font-size: 0.9em;
43
- margin: 0 0 0 1.5em;
44
- }
45
-
46
- div {
47
- width: 50%;
48
- margin: 0 auto;
49
- padding: 0.8em;
50
- background-color: #AA5852;
51
- border: 2px solid #C2645D;
52
- }
53
-
54
- @media print {
55
- body {
56
- font-size: 0.9em;
57
- }
58
-
59
- a {
60
- text-decoration: none;
61
- color: #000;
62
- }
63
- }
64
- </style>
65
- </head>
66
- <body>
67
- <h1>AutoParse</h1>
68
- <div>
69
- <p>
70
- An implementation of the JSON Schema specification.
71
- </p>
72
- <ul>
73
- <li>
74
- <a href="http://rubyforge.org/projects/autoparse/">
75
- Project Page
76
- </a>
77
- </li>
78
- <li>
79
- <a href="http://github.com/sporkmonger/autoparse/tree/">
80
- GitHub Page
81
- </a>
82
- </li>
83
- <li><a href="/api/">API</a></li>
84
- <li><a href="/specdoc/">Specifications</a></li>
85
- <li><a href="/coverage/">Code Coverage</a></li>
86
- </ul>
87
- <p>
88
- You know what to do:
89
- </p>
90
- <p>
91
- <code>sudo gem install autoparse</code>
92
- </p>
93
- </div>
94
- </body>
95
- </html>