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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c156dcfda0e97156b872e63c64fc1b4a4f2379f217103165f22de78e3415800
4
- data.tar.gz: ab9647efecba7fa057dc77b4f447c9ea09aba719d117e95edefeace45915c2cb
3
+ metadata.gz: a31bb2922acb2b1a6e84a6e640ee148eb1f40f9d8113751c6903149e472e99d9
4
+ data.tar.gz: ab119c28fe07e14bfab16e5e2905d59ccf7e8154d5ff817d14a9db92215f8bd2
5
5
  SHA512:
6
- metadata.gz: 74ca2152d154f76497df525616aba1792c192be58025c47e6e76a9ebb6c6ebd3a3cbbcf66c2a7b49d4ec1d211ce46ce0b2ba3c334b6c755e0acde4042be9f27f
7
- data.tar.gz: 47d2c181d409d1091b23080e8f62f8b708e5bd171040599b2ed3f1ce3c0a379e5a11eb72b441c61395682ec40f1f6d16bdfb51fa967a4a16046ba63caefb99ca
6
+ metadata.gz: 4ede5f5c546e8ac46689b993ada2d6ed456ed9e9b1027023e421b8d27e99b3f785360a3fcf093a58be473a80ecca3485b709f23575be6b93fb71c2ae46f63966
7
+ data.tar.gz: 021a544e520b944266c276b3b79ca53e0311df7ade212655282e4f3f03b9bca18aba5858148dc7de8ec3ca91be67dbd2f5554c4b6a73273c094d94dc31f5aa71
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ doc/*
5
5
  .yardoc
6
6
  .DS_Store
7
7
  .idea
8
+ vendor
@@ -5,3 +5,4 @@ rvm:
5
5
  - 2.7
6
6
  - ruby-head
7
7
  - jruby-head
8
+ - truffleruby-head
@@ -128,7 +128,6 @@ class JsonPath
128
128
  end
129
129
 
130
130
  def yield_value(blk, context, key)
131
- key = Integer(key) rescue key if key
132
131
  case @mode
133
132
  when nil
134
133
  blk.call(key ? context[key] : context)
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class JsonPath
4
- VERSION = '1.0.6'
4
+ VERSION = '1.0.7'
5
5
  end
@@ -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 test_regex
515
- assert_equal [], JsonPath.new('$..book[?(@.author =~ /herman/)]').on(@object)
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
- assert_equal %w[asdf asdf2], JsonPath.new('$.store.book..tags[?(@ =~ /asdf/)]').on(@object)
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.6
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-11-18 00:00:00.000000000 Z
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.8
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: []