taps 0.3.18 → 0.3.19.pre1

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.
@@ -0,0 +1,320 @@
1
+ require 'strscan'
2
+
3
+ module JSON
4
+ module Pure
5
+ # This class implements the JSON parser that is used to parse a JSON string
6
+ # into a Ruby data structure.
7
+ class Parser < StringScanner
8
+ STRING = /" ((?:[^\x0-\x1f"\\] |
9
+ # escaped special characters:
10
+ \\["\\\/bfnrt] |
11
+ \\u[0-9a-fA-F]{4} |
12
+ # match all but escaped special characters:
13
+ \\[\x20-\x21\x23-\x2e\x30-\x5b\x5d-\x61\x63-\x65\x67-\x6d\x6f-\x71\x73\x75-\xff])*)
14
+ "/nx
15
+ INTEGER = /(-?0|-?[1-9]\d*)/
16
+ FLOAT = /(-?
17
+ (?:0|[1-9]\d*)
18
+ (?:
19
+ \.\d+(?i:e[+-]?\d+) |
20
+ \.\d+ |
21
+ (?i:e[+-]?\d+)
22
+ )
23
+ )/x
24
+ NAN = /NaN/
25
+ INFINITY = /Infinity/
26
+ MINUS_INFINITY = /-Infinity/
27
+ OBJECT_OPEN = /\{/
28
+ OBJECT_CLOSE = /\}/
29
+ ARRAY_OPEN = /\[/
30
+ ARRAY_CLOSE = /\]/
31
+ PAIR_DELIMITER = /:/
32
+ COLLECTION_DELIMITER = /,/
33
+ TRUE = /true/
34
+ FALSE = /false/
35
+ NULL = /null/
36
+ IGNORE = %r(
37
+ (?:
38
+ //[^\n\r]*[\n\r]| # line comments
39
+ /\* # c-style comments
40
+ (?:
41
+ [^*/]| # normal chars
42
+ /[^*]| # slashes that do not start a nested comment
43
+ \*[^/]| # asterisks that do not end this comment
44
+ /(?=\*/) # single slash before this comment's end
45
+ )*
46
+ \*/ # the End of this comment
47
+ |[ \t\r\n]+ # whitespaces: space, horicontal tab, lf, cr
48
+ )+
49
+ )mx
50
+
51
+ UNPARSED = Object.new
52
+
53
+ # Creates a new JSON::Pure::Parser instance for the string _source_.
54
+ #
55
+ # It will be configured by the _opts_ hash. _opts_ can have the following
56
+ # keys:
57
+ # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
58
+ # structures. Disable depth checking with :max_nesting => false|nil|0,
59
+ # it defaults to 19.
60
+ # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
61
+ # defiance of RFC 4627 to be parsed by the Parser. This option defaults
62
+ # to false.
63
+ # * *symbolize_names*: If set to true, returns symbols for the names
64
+ # (keys) in a JSON object. Otherwise strings are returned, which is also
65
+ # the default.
66
+ # * *create_additions*: If set to false, the Parser doesn't create
67
+ # additions even if a matchin class and create_id was found. This option
68
+ # defaults to true.
69
+ # * *object_class*: Defaults to Hash
70
+ # * *array_class*: Defaults to Array
71
+ def initialize(source, opts = {})
72
+ opts ||= {}
73
+ if defined?(::Encoding)
74
+ if source.encoding == ::Encoding::ASCII_8BIT
75
+ b = source[0, 4].bytes.to_a
76
+ source = case
77
+ when b.size >= 4 && b[0] == 0 && b[1] == 0 && b[2] == 0
78
+ source.dup.force_encoding(::Encoding::UTF_32BE).encode!(::Encoding::UTF_8)
79
+ when b.size >= 4 && b[0] == 0 && b[2] == 0
80
+ source.dup.force_encoding(::Encoding::UTF_16BE).encode!(::Encoding::UTF_8)
81
+ when b.size >= 4 && b[1] == 0 && b[2] == 0 && b[3] == 0
82
+ source.dup.force_encoding(::Encoding::UTF_32LE).encode!(::Encoding::UTF_8)
83
+
84
+ when b.size >= 4 && b[1] == 0 && b[3] == 0
85
+ source.dup.force_encoding(::Encoding::UTF_16LE).encode!(::Encoding::UTF_8)
86
+ else
87
+ source.dup
88
+ end
89
+ else
90
+ source = source.encode(::Encoding::UTF_8)
91
+ end
92
+ source.force_encoding(::Encoding::ASCII_8BIT)
93
+ else
94
+ b = source
95
+ source = case
96
+ when b.size >= 4 && b[0] == 0 && b[1] == 0 && b[2] == 0
97
+ JSON.iconv('utf-8', 'utf-32be', b)
98
+ when b.size >= 4 && b[0] == 0 && b[2] == 0
99
+ JSON.iconv('utf-8', 'utf-16be', b)
100
+ when b.size >= 4 && b[1] == 0 && b[2] == 0 && b[3] == 0
101
+ JSON.iconv('utf-8', 'utf-32le', b)
102
+ when b.size >= 4 && b[1] == 0 && b[3] == 0
103
+ JSON.iconv('utf-8', 'utf-16le', b)
104
+ else
105
+ b
106
+ end
107
+ end
108
+ super source
109
+ if !opts.key?(:max_nesting) # defaults to 19
110
+ @max_nesting = 19
111
+ elsif opts[:max_nesting]
112
+ @max_nesting = opts[:max_nesting]
113
+ else
114
+ @max_nesting = 0
115
+ end
116
+ @allow_nan = !!opts[:allow_nan]
117
+ @symbolize_names = !!opts[:symbolize_names]
118
+ @create_additions = opts.key?(:create_additions) ? !!opts[:create_additions] : true
119
+ @create_id = opts[:create_id] || JSON.create_id
120
+ @object_class = opts[:object_class] || Hash
121
+ @array_class = opts[:array_class] || Array
122
+ @match_string = opts[:match_string]
123
+ end
124
+
125
+ alias source string
126
+
127
+ # Parses the current JSON string _source_ and returns the complete data
128
+ # structure as a result.
129
+ def parse
130
+ reset
131
+ obj = nil
132
+ until eos?
133
+ case
134
+ when scan(OBJECT_OPEN)
135
+ obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
136
+ @current_nesting = 1
137
+ obj = parse_object
138
+ when scan(ARRAY_OPEN)
139
+ obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
140
+ @current_nesting = 1
141
+ obj = parse_array
142
+ when skip(IGNORE)
143
+ ;
144
+ else
145
+ raise ParserError, "source '#{peek(20)}' not in JSON!"
146
+ end
147
+ end
148
+ obj or raise ParserError, "source did not contain any JSON!"
149
+ obj
150
+ end
151
+
152
+ private
153
+
154
+ # Unescape characters in strings.
155
+ UNESCAPE_MAP = Hash.new { |h, k| h[k] = k.chr }
156
+ UNESCAPE_MAP.update({
157
+ ?" => '"',
158
+ ?\\ => '\\',
159
+ ?/ => '/',
160
+ ?b => "\b",
161
+ ?f => "\f",
162
+ ?n => "\n",
163
+ ?r => "\r",
164
+ ?t => "\t",
165
+ ?u => nil,
166
+ })
167
+
168
+ EMPTY_8BIT_STRING = ''
169
+ if ::String.method_defined?(:encode)
170
+ EMPTY_8BIT_STRING.force_encoding Encoding::ASCII_8BIT
171
+ end
172
+
173
+ def parse_string
174
+ if scan(STRING)
175
+ return '' if self[1].empty?
176
+ string = self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
177
+ if u = UNESCAPE_MAP[$&[1]]
178
+ u
179
+ else # \uXXXX
180
+ bytes = EMPTY_8BIT_STRING.dup
181
+ i = 0
182
+ while c[6 * i] == ?\\ && c[6 * i + 1] == ?u
183
+ bytes << c[6 * i + 2, 2].to_i(16) << c[6 * i + 4, 2].to_i(16)
184
+ i += 1
185
+ end
186
+ JSON.iconv('utf-8', 'utf-16be', bytes)
187
+ end
188
+ end
189
+ if string.respond_to?(:force_encoding)
190
+ string.force_encoding(::Encoding::UTF_8)
191
+ end
192
+ if @create_additions and @match_string
193
+ for (regexp, klass) in @match_string
194
+ klass.json_creatable? or next
195
+ string =~ regexp and return klass.json_create(string)
196
+ end
197
+ end
198
+ string
199
+ else
200
+ UNPARSED
201
+ end
202
+ rescue => e
203
+ raise ParserError, "Caught #{e.class} at '#{peek(20)}': #{e}"
204
+ end
205
+
206
+ def parse_value
207
+ case
208
+ when scan(FLOAT)
209
+ Float(self[1])
210
+ when scan(INTEGER)
211
+ Integer(self[1])
212
+ when scan(TRUE)
213
+ true
214
+ when scan(FALSE)
215
+ false
216
+ when scan(NULL)
217
+ nil
218
+ when (string = parse_string) != UNPARSED
219
+ string
220
+ when scan(ARRAY_OPEN)
221
+ @current_nesting += 1
222
+ ary = parse_array
223
+ @current_nesting -= 1
224
+ ary
225
+ when scan(OBJECT_OPEN)
226
+ @current_nesting += 1
227
+ obj = parse_object
228
+ @current_nesting -= 1
229
+ obj
230
+ when @allow_nan && scan(NAN)
231
+ NaN
232
+ when @allow_nan && scan(INFINITY)
233
+ Infinity
234
+ when @allow_nan && scan(MINUS_INFINITY)
235
+ MinusInfinity
236
+ else
237
+ UNPARSED
238
+ end
239
+ end
240
+
241
+ def parse_array
242
+ raise NestingError, "nesting of #@current_nesting is too deep" if
243
+ @max_nesting.nonzero? && @current_nesting > @max_nesting
244
+ result = @array_class.new
245
+ delim = false
246
+ until eos?
247
+ case
248
+ when (value = parse_value) != UNPARSED
249
+ delim = false
250
+ result << value
251
+ skip(IGNORE)
252
+ if scan(COLLECTION_DELIMITER)
253
+ delim = true
254
+ elsif match?(ARRAY_CLOSE)
255
+ ;
256
+ else
257
+ raise ParserError, "expected ',' or ']' in array at '#{peek(20)}'!"
258
+ end
259
+ when scan(ARRAY_CLOSE)
260
+ if delim
261
+ raise ParserError, "expected next element in array at '#{peek(20)}'!"
262
+ end
263
+ break
264
+ when skip(IGNORE)
265
+ ;
266
+ else
267
+ raise ParserError, "unexpected token in array at '#{peek(20)}'!"
268
+ end
269
+ end
270
+ result
271
+ end
272
+
273
+ def parse_object
274
+ raise NestingError, "nesting of #@current_nesting is too deep" if
275
+ @max_nesting.nonzero? && @current_nesting > @max_nesting
276
+ result = @object_class.new
277
+ delim = false
278
+ until eos?
279
+ case
280
+ when (string = parse_string) != UNPARSED
281
+ skip(IGNORE)
282
+ unless scan(PAIR_DELIMITER)
283
+ raise ParserError, "expected ':' in object at '#{peek(20)}'!"
284
+ end
285
+ skip(IGNORE)
286
+ unless (value = parse_value).equal? UNPARSED
287
+ result[@symbolize_names ? string.to_sym : string] = value
288
+ delim = false
289
+ skip(IGNORE)
290
+ if scan(COLLECTION_DELIMITER)
291
+ delim = true
292
+ elsif match?(OBJECT_CLOSE)
293
+ ;
294
+ else
295
+ raise ParserError, "expected ',' or '}' in object at '#{peek(20)}'!"
296
+ end
297
+ else
298
+ raise ParserError, "expected value in object at '#{peek(20)}'!"
299
+ end
300
+ when scan(OBJECT_CLOSE)
301
+ if delim
302
+ raise ParserError, "expected next name, value pair in object at '#{peek(20)}'!"
303
+ end
304
+ if @create_additions and klassname = result[@create_id]
305
+ klass = JSON.deep_const_get klassname
306
+ break unless klass and klass.json_creatable?
307
+ result = klass.json_create(result)
308
+ end
309
+ break
310
+ when skip(IGNORE)
311
+ ;
312
+ else
313
+ raise ParserError, "unexpected token in object at '#{peek(20)}'!"
314
+ end
315
+ end
316
+ result
317
+ end
318
+ end
319
+ end
320
+ end
@@ -0,0 +1,8 @@
1
+ module JSON
2
+ # JSON version
3
+ VERSION = '1.5.1'
4
+ VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
+ VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
+ VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
7
+ VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
8
+ end
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taps
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
5
- prerelease:
4
+ hash: 1923831811
5
+ prerelease: 7
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 18
10
- version: 0.3.18
9
+ - 19
10
+ - pre
11
+ - 1
12
+ version: 0.3.19.pre1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Ricardo Chimal, Jr.
@@ -15,29 +17,13 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2011-03-04 00:00:00 -05:00
20
+ date: 2011-03-09 00:00:00 -05:00
19
21
  default_executable:
20
22
  dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: json
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 1
30
- segments:
31
- - 1
32
- - 5
33
- - 1
34
- version: 1.5.1
35
- type: :runtime
36
- version_requirements: *id001
37
23
  - !ruby/object:Gem::Dependency
38
24
  name: rack
39
25
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
26
+ requirement: &id001 !ruby/object:Gem::Requirement
41
27
  none: false
42
28
  requirements:
43
29
  - - ">="
@@ -49,11 +35,11 @@ dependencies:
49
35
  - 1
50
36
  version: 1.0.1
51
37
  type: :runtime
52
- version_requirements: *id002
38
+ version_requirements: *id001
53
39
  - !ruby/object:Gem::Dependency
54
40
  name: rest-client
55
41
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
42
+ requirement: &id002 !ruby/object:Gem::Requirement
57
43
  none: false
58
44
  requirements:
59
45
  - - ">="
@@ -73,11 +59,11 @@ dependencies:
73
59
  - 0
74
60
  version: 1.7.0
75
61
  type: :runtime
76
- version_requirements: *id003
62
+ version_requirements: *id002
77
63
  - !ruby/object:Gem::Dependency
78
64
  name: sequel
79
65
  prerelease: false
80
- requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirement: &id003 !ruby/object:Gem::Requirement
81
67
  none: false
82
68
  requirements:
83
69
  - - ~>
@@ -89,11 +75,11 @@ dependencies:
89
75
  - 0
90
76
  version: 3.20.0
91
77
  type: :runtime
92
- version_requirements: *id004
78
+ version_requirements: *id003
93
79
  - !ruby/object:Gem::Dependency
94
80
  name: sinatra
95
81
  prerelease: false
96
- requirement: &id005 !ruby/object:Gem::Requirement
82
+ requirement: &id004 !ruby/object:Gem::Requirement
97
83
  none: false
98
84
  requirements:
99
85
  - - ~>
@@ -105,11 +91,11 @@ dependencies:
105
91
  - 0
106
92
  version: 1.0.0
107
93
  type: :runtime
108
- version_requirements: *id005
94
+ version_requirements: *id004
109
95
  - !ruby/object:Gem::Dependency
110
96
  name: sqlite3-ruby
111
97
  prerelease: false
112
- requirement: &id006 !ruby/object:Gem::Requirement
98
+ requirement: &id005 !ruby/object:Gem::Requirement
113
99
  none: false
114
100
  requirements:
115
101
  - - ~>
@@ -120,11 +106,11 @@ dependencies:
120
106
  - 2
121
107
  version: "1.2"
122
108
  type: :runtime
123
- version_requirements: *id006
109
+ version_requirements: *id005
124
110
  - !ruby/object:Gem::Dependency
125
111
  name: bacon
126
112
  prerelease: false
127
- requirement: &id007 !ruby/object:Gem::Requirement
113
+ requirement: &id006 !ruby/object:Gem::Requirement
128
114
  none: false
129
115
  requirements:
130
116
  - - ">="
@@ -134,11 +120,11 @@ dependencies:
134
120
  - 0
135
121
  version: "0"
136
122
  type: :development
137
- version_requirements: *id007
123
+ version_requirements: *id006
138
124
  - !ruby/object:Gem::Dependency
139
125
  name: mocha
140
126
  prerelease: false
141
- requirement: &id008 !ruby/object:Gem::Requirement
127
+ requirement: &id007 !ruby/object:Gem::Requirement
142
128
  none: false
143
129
  requirements:
144
130
  - - ">="
@@ -148,11 +134,11 @@ dependencies:
148
134
  - 0
149
135
  version: "0"
150
136
  type: :development
151
- version_requirements: *id008
137
+ version_requirements: *id007
152
138
  - !ruby/object:Gem::Dependency
153
139
  name: rack-test
154
140
  prerelease: false
155
- requirement: &id009 !ruby/object:Gem::Requirement
141
+ requirement: &id008 !ruby/object:Gem::Requirement
156
142
  none: false
157
143
  requirements:
158
144
  - - ">="
@@ -162,11 +148,11 @@ dependencies:
162
148
  - 0
163
149
  version: "0"
164
150
  type: :development
165
- version_requirements: *id009
151
+ version_requirements: *id008
166
152
  - !ruby/object:Gem::Dependency
167
153
  name: rake
168
154
  prerelease: false
169
- requirement: &id010 !ruby/object:Gem::Requirement
155
+ requirement: &id009 !ruby/object:Gem::Requirement
170
156
  none: false
171
157
  requirements:
172
158
  - - ">="
@@ -176,11 +162,11 @@ dependencies:
176
162
  - 0
177
163
  version: "0"
178
164
  type: :development
179
- version_requirements: *id010
165
+ version_requirements: *id009
180
166
  - !ruby/object:Gem::Dependency
181
167
  name: rcov
182
168
  prerelease: false
183
- requirement: &id011 !ruby/object:Gem::Requirement
169
+ requirement: &id010 !ruby/object:Gem::Requirement
184
170
  none: false
185
171
  requirements:
186
172
  - - ">="
@@ -190,7 +176,7 @@ dependencies:
190
176
  - 0
191
177
  version: "0"
192
178
  type: :development
193
- version_requirements: *id011
179
+ version_requirements: *id010
194
180
  description: A simple database agnostic import/export app to transfer data to/from a remote database.
195
181
  email: ricardo@heroku.com
196
182
  executables:
@@ -210,6 +196,7 @@ files:
210
196
  - lib/taps/data_stream.rb
211
197
  - lib/taps/db_session.rb
212
198
  - lib/taps/errors.rb
199
+ - lib/taps/json.rb
213
200
  - lib/taps/log.rb
214
201
  - lib/taps/monkey.rb
215
202
  - lib/taps/multipart.rb
@@ -218,6 +205,26 @@ files:
218
205
  - lib/taps/schema.rb
219
206
  - lib/taps/server.rb
220
207
  - lib/taps/utils.rb
208
+ - lib/taps/vendor/json_pure-1.5.1/CHANGES
209
+ - lib/taps/vendor/json_pure-1.5.1/COPYING
210
+ - lib/taps/vendor/json_pure-1.5.1/COPYING-json-jruby
211
+ - lib/taps/vendor/json_pure-1.5.1/GPL
212
+ - lib/taps/vendor/json_pure-1.5.1/lib/json/add/core.rb
213
+ - lib/taps/vendor/json_pure-1.5.1/lib/json/add/rails.rb
214
+ - lib/taps/vendor/json_pure-1.5.1/lib/json/common.rb
215
+ - lib/taps/vendor/json_pure-1.5.1/lib/json/editor.rb
216
+ - lib/taps/vendor/json_pure-1.5.1/lib/json/ext.rb
217
+ - lib/taps/vendor/json_pure-1.5.1/lib/json/json.xpm
218
+ - lib/taps/vendor/json_pure-1.5.1/lib/json/pure/generator.rb
219
+ - lib/taps/vendor/json_pure-1.5.1/lib/json/pure/parser.rb
220
+ - lib/taps/vendor/json_pure-1.5.1/lib/json/pure.rb
221
+ - lib/taps/vendor/json_pure-1.5.1/lib/json/version.rb
222
+ - lib/taps/vendor/json_pure-1.5.1/lib/json.rb
223
+ - lib/taps/vendor/json_pure-1.5.1/Rakefile
224
+ - lib/taps/vendor/json_pure-1.5.1/README
225
+ - lib/taps/vendor/json_pure-1.5.1/README-json-jruby.markdown
226
+ - lib/taps/vendor/json_pure-1.5.1/TODO
227
+ - lib/taps/vendor/json_pure-1.5.1/VERSION
221
228
  - lib/taps/version.rb
222
229
  - README.rdoc
223
230
  - spec/base.rb
@@ -249,12 +256,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
249
256
  required_rubygems_version: !ruby/object:Gem::Requirement
250
257
  none: false
251
258
  requirements:
252
- - - ">="
259
+ - - ">"
253
260
  - !ruby/object:Gem::Version
254
- hash: 3
261
+ hash: 25
255
262
  segments:
256
- - 0
257
- version: "0"
263
+ - 1
264
+ - 3
265
+ - 1
266
+ version: 1.3.1
258
267
  requirements: []
259
268
 
260
269
  rubyforge_project: