jsonpath 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/lib/jsonpath/enumerable.rb +0 -1
- data/lib/jsonpath/parser.rb +1 -1
- data/lib/jsonpath/version.rb +1 -1
- data/test/test_jsonpath.rb +26 -3
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a31bb2922acb2b1a6e84a6e640ee148eb1f40f9d8113751c6903149e472e99d9
|
4
|
+
data.tar.gz: ab119c28fe07e14bfab16e5e2905d59ccf7e8154d5ff817d14a9db92215f8bd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ede5f5c546e8ac46689b993ada2d6ed456ed9e9b1027023e421b8d27e99b3f785360a3fcf093a58be473a80ecca3485b709f23575be6b93fb71c2ae46f63966
|
7
|
+
data.tar.gz: 021a544e520b944266c276b3b79ca53e0311df7ade212655282e4f3f03b9bca18aba5858148dc7de8ec3ca91be67dbd2f5554c4b6a73273c094d94dc31f5aa71
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/lib/jsonpath/enumerable.rb
CHANGED
data/lib/jsonpath/parser.rb
CHANGED
@@ -114,7 +114,7 @@ class JsonPath
|
|
114
114
|
content = $1 || $3
|
115
115
|
options = $2 || $4
|
116
116
|
|
117
|
-
raise "unsupported regex #{t} use /foo/ style" if !content || !options
|
117
|
+
raise ArgumentError, "unsupported regex #{t} use /foo/ style" if !content || !options
|
118
118
|
|
119
119
|
content = content.gsub '\\/', '/'
|
120
120
|
|
data/lib/jsonpath/version.rb
CHANGED
data/test/test_jsonpath.rb
CHANGED
@@ -511,15 +511,31 @@ class TestJsonpath < MiniTest::Unit::TestCase
|
|
511
511
|
assert_equal [{ 'isTrue' => true, 'name' => 'testname1' }], JsonPath.new('$.data[?(@.isTrue)]').on(data)
|
512
512
|
end
|
513
513
|
|
514
|
-
def
|
515
|
-
assert_equal [], JsonPath.new('
|
514
|
+
def test_regex_simple
|
515
|
+
assert_equal %w[asdf asdf2], JsonPath.new('$.store.book..tags[?(@ =~ /asdf/)]').on(@object)
|
516
|
+
end
|
517
|
+
|
518
|
+
def test_regex_simple_miss
|
519
|
+
assert_equal [], JsonPath.new('$.store.book..tags[?(@ =~ /wut/)]').on(@object)
|
520
|
+
end
|
521
|
+
|
522
|
+
def test_regex_r
|
523
|
+
assert_equal %w[asdf asdf2], JsonPath.new('$.store.book..tags[?(@ =~ %r{asdf})]').on(@object)
|
524
|
+
end
|
525
|
+
|
526
|
+
def test_regex_flags
|
516
527
|
assert_equal [
|
517
528
|
@object['store']['book'][2],
|
518
529
|
@object['store']['book'][4],
|
519
530
|
@object['store']['book'][5],
|
520
531
|
@object['store']['book'][6]
|
521
532
|
], JsonPath.new('$..book[?(@.author =~ /herman|lukyanenko/i)]').on(@object)
|
522
|
-
|
533
|
+
end
|
534
|
+
|
535
|
+
def test_regex_error
|
536
|
+
assert_raises ArgumentError do
|
537
|
+
JsonPath.new('$.store.book..tags[?(@ =~ asdf)]').on(@object)
|
538
|
+
end
|
523
539
|
end
|
524
540
|
|
525
541
|
def test_regression_1
|
@@ -922,6 +938,13 @@ class TestJsonpath < MiniTest::Unit::TestCase
|
|
922
938
|
assert_equal(['should_still_work'], hs.on(j))
|
923
939
|
end
|
924
940
|
|
941
|
+
def test_index_access_by_number
|
942
|
+
data = {
|
943
|
+
'1': 'foo'
|
944
|
+
}
|
945
|
+
assert_equal ['foo'], JsonPath.new('$.1').on(data.to_json)
|
946
|
+
end
|
947
|
+
|
925
948
|
def example_object
|
926
949
|
{ 'store' => {
|
927
950
|
'book' => [
|
metadata
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonpath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Hull
|
8
8
|
- Gergely Brautigam
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-12-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
+
name: multi_json
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
18
|
- - ">="
|
18
19
|
- !ruby/object:Gem::Version
|
19
20
|
version: '0'
|
20
|
-
name: multi_json
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,12 +26,12 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
32
|
- - ">="
|
32
33
|
- !ruby/object:Gem::Version
|
33
34
|
version: '0'
|
34
|
-
name: bundler
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -40,12 +40,12 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
+
name: code_stats
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
46
|
- - ">="
|
46
47
|
- !ruby/object:Gem::Version
|
47
48
|
version: '0'
|
48
|
-
name: code_stats
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -54,12 +54,12 @@ dependencies:
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
+
name: minitest
|
57
58
|
requirement: !ruby/object:Gem::Requirement
|
58
59
|
requirements:
|
59
60
|
- - "~>"
|
60
61
|
- !ruby/object:Gem::Version
|
61
62
|
version: 2.2.0
|
62
|
-
name: minitest
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -68,12 +68,12 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: 2.2.0
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
+
name: phocus
|
71
72
|
requirement: !ruby/object:Gem::Requirement
|
72
73
|
requirements:
|
73
74
|
- - ">="
|
74
75
|
- !ruby/object:Gem::Version
|
75
76
|
version: '0'
|
76
|
-
name: phocus
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -82,12 +82,12 @@ dependencies:
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
+
name: rake
|
85
86
|
requirement: !ruby/object:Gem::Requirement
|
86
87
|
requirements:
|
87
88
|
- - ">="
|
88
89
|
- !ruby/object:Gem::Version
|
89
90
|
version: '0'
|
90
|
-
name: rake
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -128,7 +128,7 @@ homepage: https://github.com/joshbuddy/jsonpath
|
|
128
128
|
licenses:
|
129
129
|
- MIT
|
130
130
|
metadata: {}
|
131
|
-
post_install_message:
|
131
|
+
post_install_message:
|
132
132
|
rdoc_options: []
|
133
133
|
require_paths:
|
134
134
|
- lib
|
@@ -143,8 +143,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
|
-
rubygems_version: 3.0.
|
147
|
-
signing_key:
|
146
|
+
rubygems_version: 3.0.3
|
147
|
+
signing_key:
|
148
148
|
specification_version: 4
|
149
149
|
summary: Ruby implementation of http://goessner.net/articles/JsonPath/
|
150
150
|
test_files: []
|