jsonpath 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -8
- data/jsonpath.gemspec +1 -1
- data/lib/jsonpath/enumerable.rb +9 -4
- data/lib/jsonpath/version.rb +1 -1
- data/test/test_jsonpath.rb +4 -0
- metadata +50 -18
data/Rakefile
CHANGED
@@ -1,14 +1,6 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
|
-
require 'rake/rdoctask'
|
5
|
-
desc "Generate documentation"
|
6
|
-
Rake::RDocTask.new do |rd|
|
7
|
-
rd.main = "README.rdoc"
|
8
|
-
rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
|
9
|
-
rd.rdoc_dir = 'rdoc'
|
10
|
-
end
|
11
|
-
|
12
4
|
task :test do
|
13
5
|
$: << 'lib'
|
14
6
|
require 'minitest/autorun'
|
data/jsonpath.gemspec
CHANGED
@@ -26,6 +26,6 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_development_dependency 'rake'
|
27
27
|
s.add_development_dependency 'minitest', '~> 2.2.0'
|
28
28
|
s.add_development_dependency 'phocus'
|
29
|
-
s.add_development_dependency 'bundler'
|
29
|
+
s.add_development_dependency 'bundler'
|
30
30
|
end
|
31
31
|
|
data/lib/jsonpath/enumerable.rb
CHANGED
@@ -44,11 +44,16 @@ class JsonPath
|
|
44
44
|
else
|
45
45
|
if node.is_a?(Array)
|
46
46
|
array_args = sub_path.split(':')
|
47
|
-
|
48
|
-
|
47
|
+
if array_args[0] == ?*
|
48
|
+
start_idx = 0
|
49
|
+
end_idx = node.size - 1
|
50
|
+
else
|
51
|
+
start_idx = process_function_or_literal(array_args[0], 0)
|
52
|
+
next unless start_idx
|
53
|
+
end_idx = (array_args[1] && process_function_or_literal(array_args[1], -1) || (sub_path.count(':') == 0 ? start_idx : -1))
|
54
|
+
next unless end_idx
|
55
|
+
end
|
49
56
|
start_idx %= node.size
|
50
|
-
end_idx = (array_args[1] && process_function_or_literal(array_args[1], -1) || (sub_path.count(':') == 0 ? start_idx : -1))
|
51
|
-
next unless end_idx
|
52
57
|
end_idx %= node.size
|
53
58
|
step = process_function_or_literal(array_args[2], 1)
|
54
59
|
next unless step
|
data/lib/jsonpath/version.rb
CHANGED
data/test/test_jsonpath.rb
CHANGED
@@ -122,6 +122,10 @@ class TestJsonpath < MiniTest::Unit::TestCase
|
|
122
122
|
assert_equal({'you' => nil}, h)
|
123
123
|
end
|
124
124
|
|
125
|
+
def test_wildcard
|
126
|
+
assert_equal @object['store']['book'].collect{|e| e['price']}, JsonPath.on(@object, '$..book[*].price')
|
127
|
+
end
|
128
|
+
|
125
129
|
def example_object
|
126
130
|
{ "store"=> {
|
127
131
|
"book" => [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonpath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: code_stats
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rake
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: minitest
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: 2.2.0
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.2.0
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: phocus
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,18 +85,28 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: bundler
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
|
-
- -
|
99
|
+
- - ! '>='
|
75
100
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
101
|
+
version: '0'
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
80
110
|
description: Ruby implementation of http://goessner.net/articles/JsonPath/.
|
81
111
|
email: joshbuddy@gmail.com
|
82
112
|
executables:
|
@@ -113,6 +143,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
143
|
- - ! '>='
|
114
144
|
- !ruby/object:Gem::Version
|
115
145
|
version: '0'
|
146
|
+
segments:
|
147
|
+
- 0
|
148
|
+
hash: -4414844720981211301
|
116
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
150
|
none: false
|
118
151
|
requirements:
|
@@ -121,9 +154,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
154
|
version: '0'
|
122
155
|
requirements: []
|
123
156
|
rubyforge_project: jsonpath
|
124
|
-
rubygems_version: 1.8.
|
157
|
+
rubygems_version: 1.8.24
|
125
158
|
signing_key:
|
126
159
|
specification_version: 3
|
127
160
|
summary: Ruby implementation of http://goessner.net/articles/JsonPath/
|
128
161
|
test_files: []
|
129
|
-
has_rdoc:
|