json-stream-path 0.0.2 → 0.0.3
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.
- data/json-stream-path.gemspec +1 -1
- data/lib/json/stream.rb +0 -1
- data/lib/json/stream/parser.rb +1 -1
- data/lib/json/stream/path/version.rb +1 -1
- data/test/stream_j_path_test.rb +68 -68
- metadata +2 -11
data/json-stream-path.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Json::Stream::Path::VERSION
|
9
9
|
spec.authors = ["Manojs"]
|
10
10
|
spec.email = ["manojs.nitt@gmail.com"]
|
11
|
-
spec.description = %q{A streaming JSON parser (generates SAX-like events) and JSON Path like implementation to parse small amount of data in a large JSON file.}
|
11
|
+
spec.description = %q{A streaming JSON parser (generates SAX-like events) and "JSON Path" like implementation to parse small amount of data in a large JSON file.}
|
12
12
|
spec.summary = %q{A parser best suited for huge JSON documents that don't fit in memory and to parse small amount of data in a large JSON file.}
|
13
13
|
spec.homepage = "https://github.com/bethink/json-stream-path"
|
14
14
|
spec.license = "MIT"
|
data/lib/json/stream.rb
CHANGED
data/lib/json/stream/parser.rb
CHANGED
data/test/stream_j_path_test.rb
CHANGED
@@ -34,54 +34,54 @@ class StreamJPathTest < Test::Unit::TestCase
|
|
34
34
|
}
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
37
|
+
def test_parsing_without_jpath
|
38
|
+
stream = File.open('test/stream_example.json')
|
39
|
+
@parser = JSON::Stream::Parser.new
|
40
|
+
result = @parser.parse(stream)
|
41
|
+
assert_equal(@hash, result)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_parsing_with_empty_jpath
|
45
|
+
stream = File.open('test/stream_example.json')
|
46
|
+
@parser = JSON::Stream::Parser.new
|
47
|
+
result = @parser.parse(stream)
|
48
|
+
assert_equal(@hash, result)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_parsing_with_empty_jpath
|
52
|
+
stream = File.open('test/stream_example.json')
|
53
|
+
@parser = JSON::Stream::Parser.new
|
54
|
+
result = @parser.parse(stream, '')
|
55
|
+
assert_equal(@hash, result)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_parsing_whole
|
59
|
+
stream = File.open('test/stream_example.json')
|
60
|
+
@parser = JSON::Stream::Parser.new
|
61
|
+
result = @parser.parse(stream, '/')
|
62
|
+
assert_equal(@hash, result)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_parsing_root
|
66
|
+
stream = File.open('test/stream_example.json')
|
67
|
+
@parser = JSON::Stream::Parser.new
|
68
|
+
result = @parser.parse(stream, '/root')
|
69
|
+
assert_equal(@hash['root'], result)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_parsing_root_one
|
73
|
+
stream = File.open('test/stream_example.json')
|
74
|
+
@parser = JSON::Stream::Parser.new
|
75
|
+
result = @parser.parse(stream, '/root/one')
|
76
|
+
assert_equal(@hash['root']['one'], result)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_parsing_root_two
|
80
|
+
stream = File.open('test/stream_example.json')
|
81
|
+
@parser = JSON::Stream::Parser.new
|
82
|
+
result = @parser.parse(stream, '/root/two')
|
83
|
+
assert_equal(@hash['root']['two'], result)
|
84
|
+
end
|
85
85
|
|
86
86
|
def test_parsing_root_three
|
87
87
|
stream = File.open('test/stream_example.json')
|
@@ -90,25 +90,25 @@ class StreamJPathTest < Test::Unit::TestCase
|
|
90
90
|
assert_equal(@hash['root']['three'], result)
|
91
91
|
end
|
92
92
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
93
|
+
def test_parsing_root_three1
|
94
|
+
stream = File.open('test/stream_example.json')
|
95
|
+
@parser = JSON::Stream::Parser.new
|
96
|
+
result = @parser.parse(stream, '/root/three/three1')
|
97
|
+
assert_equal(@hash['root']['three']['three1'], result)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_parsing_root_three2
|
101
|
+
stream = File.open('test/stream_example.json')
|
102
|
+
@parser = JSON::Stream::Parser.new
|
103
|
+
hash = @parser.parse(stream, '/root/three/three2')
|
104
|
+
assert_equal(@hash['root']['three']['three2'], hash)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_parsing_root_
|
108
|
+
stream = File.open('test/stream_example.json')
|
109
|
+
@parser = JSON::Stream::Parser.new
|
110
|
+
hash = @parser.parse(stream, '/sibling')
|
111
|
+
assert_equal(@hash['sibling'], hash)
|
112
|
+
end
|
113
113
|
|
114
114
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json-stream-path
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
description: A streaming JSON parser (generates SAX-like events) and JSON Path like
|
62
|
+
description: A streaming JSON parser (generates SAX-like events) and "JSON Path" like
|
63
63
|
implementation to parse small amount of data in a large JSON file.
|
64
64
|
email:
|
65
65
|
- manojs.nitt@gmail.com
|
@@ -68,15 +68,6 @@ extensions: []
|
|
68
68
|
extra_rdoc_files: []
|
69
69
|
files:
|
70
70
|
- .gitignore
|
71
|
-
- .idea/.name
|
72
|
-
- .idea/.rakeTasks
|
73
|
-
- .idea/encodings.xml
|
74
|
-
- .idea/json-stream-path.iml
|
75
|
-
- .idea/misc.xml
|
76
|
-
- .idea/modules.xml
|
77
|
-
- .idea/scopes/scope_settings.xml
|
78
|
-
- .idea/vcs.xml
|
79
|
-
- .idea/workspace.xml
|
80
71
|
- Gemfile
|
81
72
|
- LICENSE
|
82
73
|
- README.md
|