jsonpath 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +1 -1
- data/lib/jsonpath/enumerable.rb +6 -1
- data/lib/jsonpath/version.rb +1 -1
- data/test/test_jsonpath.rb +5 -0
- metadata +17 -34
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4d638b0073b7d93162c45b1feb8a91bcb09673a0
|
4
|
+
data.tar.gz: 311e31b62ab9eba37ac97934fe7dabe7c370ef5c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d6e4edb5fed25fce9fc197ba81fd77ba235fab07e5d061e74b3b142b7e1df46d4165d3b096b65f0060c0a2494e9123ce76463a999acca3edd861ee4448e82049
|
7
|
+
data.tar.gz: aa6efe25b941c14e23ecf274a099ab6e6e12a15e095bf5d236c0e9ab18e9315318ae3ba887a80436152a0f66e01bf914e9f04011165148ce52a5a8028270a894
|
data/.travis.yml
CHANGED
data/lib/jsonpath/enumerable.rb
CHANGED
@@ -108,7 +108,12 @@ class JsonPath
|
|
108
108
|
identifier = match_result[1]
|
109
109
|
# if there's no such method - convert into hash subscript
|
110
110
|
if !identifier.nil? && !@_current_node.methods.include?(identifier.to_sym)
|
111
|
-
|
111
|
+
exp_to_eval = exp.gsub(/@/, '@_current_node').gsub(/@_current_node.#{identifier}/,"@_current_node['#{identifier}']")
|
112
|
+
begin
|
113
|
+
return eval(exp_to_eval)
|
114
|
+
rescue StandardError # if eval failed because of bad arguments or missing methods
|
115
|
+
return default
|
116
|
+
end
|
112
117
|
end
|
113
118
|
# otherwise eval as is
|
114
119
|
eval(exp.gsub(/@/, '@_current_node'))
|
data/lib/jsonpath/version.rb
CHANGED
data/test/test_jsonpath.rb
CHANGED
@@ -143,6 +143,11 @@ class TestJsonpath < MiniTest::Unit::TestCase
|
|
143
143
|
assert_equal [@object['store']['book'][3]], JsonPath.new("$..book[?(@.price > 20)]").on(@object)
|
144
144
|
end
|
145
145
|
|
146
|
+
def test_support_filter_by_childnode_value_with_inconsistent_children
|
147
|
+
@object['store']['book'][0] = "string_instead_of_object"
|
148
|
+
assert_equal [@object['store']['book'][3]], JsonPath.new("$..book[?(@.price > 20)]").on(@object)
|
149
|
+
end
|
150
|
+
|
146
151
|
def example_object
|
147
152
|
{ "store"=> {
|
148
153
|
"book" => [
|
metadata
CHANGED
@@ -1,68 +1,60 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonpath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Joshua Hull
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-10-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: multi_json
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: code_stats
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: minitest
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,33 +69,29 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: phocus
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: bundler
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
description: Ruby implementation of http://goessner.net/articles/JsonPath/.
|
@@ -132,30 +119,26 @@ files:
|
|
132
119
|
- test/test_jsonpath_bin.rb
|
133
120
|
homepage: http://github.com/joshbuddy/jsonpath
|
134
121
|
licenses: []
|
122
|
+
metadata: {}
|
135
123
|
post_install_message:
|
136
124
|
rdoc_options:
|
137
125
|
- --charset=UTF-8
|
138
126
|
require_paths:
|
139
127
|
- lib
|
140
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
-
none: false
|
142
129
|
requirements:
|
143
|
-
- -
|
130
|
+
- - '>='
|
144
131
|
- !ruby/object:Gem::Version
|
145
132
|
version: '0'
|
146
|
-
segments:
|
147
|
-
- 0
|
148
|
-
hash: -601431146046760901
|
149
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
-
none: false
|
151
134
|
requirements:
|
152
|
-
- -
|
135
|
+
- - '>='
|
153
136
|
- !ruby/object:Gem::Version
|
154
137
|
version: '0'
|
155
138
|
requirements: []
|
156
139
|
rubyforge_project: jsonpath
|
157
|
-
rubygems_version:
|
140
|
+
rubygems_version: 2.0.3
|
158
141
|
signing_key:
|
159
|
-
specification_version:
|
142
|
+
specification_version: 4
|
160
143
|
summary: Ruby implementation of http://goessner.net/articles/JsonPath/
|
161
144
|
test_files: []
|