jsonpath 0.8.10 → 0.8.11

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
  SHA1:
3
- metadata.gz: 2ccfcb77f1e1d53075429a1de02a47582533adaa
4
- data.tar.gz: df31c7f7e048956e4377c15102dbace9427e9a50
3
+ metadata.gz: 5cdb674e56726cbd684e5d375ac5c215fa1a1e05
4
+ data.tar.gz: 3303030517f082f2aa1fb86fd10e239a5e5348f5
5
5
  SHA512:
6
- metadata.gz: 525c8cff304cb529977edc935a2c2a8163b632a1e7290cef4b7ea73d80cb1c20a228ea18e545023231367c3255a74a5183a9f854c7b147877ff6cea9e5f716e5
7
- data.tar.gz: 0dc3e440ba55497515f40b82d594beef82f70e495d20f658d839cb1ce2a757d626756bb0ce59aad526c3b0089b245769926875e257b67b93d625a5330039ba1c
6
+ metadata.gz: f25145b3223bbe6e2d7814616b355ac9ccb4d4b2a56378c7214cadf92c1d49d71fc2c6acce881933139863ec8dddfcdc854f68381280f32bb4d7063143818d3b
7
+ data.tar.gz: f30b7dbb89ba91cee2a77efb8b6ddc4c25eb499161123222006cd51157955f52eab7d48aad315330072d5b6aa4181da6bd1554db7b56410be5c54b8ebfe55243
data/jsonpath.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
 
25
25
  # dependencies
26
26
  s.add_runtime_dependency 'multi_json'
27
+ s.add_runtime_dependency 'to_regexp', '~> 0.2.1'
27
28
  s.add_development_dependency 'code_stats'
28
29
  s.add_development_dependency 'rake'
29
30
  s.add_development_dependency 'minitest', '~> 2.2.0'
@@ -1,4 +1,5 @@
1
1
  require 'strscan'
2
+ require 'to_regexp'
2
3
 
3
4
  class JsonPath
4
5
  # Parser parses and evaluates an expression passed to @_current_node.
@@ -34,10 +35,12 @@ class JsonPath
34
35
  end
35
36
  if t = scanner.scan(/\['[a-zA-Z@&\*\/\$%\^\?_]+'\]+/)
36
37
  elements << t.gsub(/\[|\]|'|\s+/, '')
37
- elsif t = scanner.scan(/(\s+)?[<>=][<>=]?(\s+)?/)
38
+ elsif t = scanner.scan(/(\s+)?[<>=][=~]?(\s+)?/)
38
39
  operator = t
39
40
  elsif t = scanner.scan(/(\s+)?'?.*'?(\s+)?/)
40
- operand = t.delete("'").strip
41
+ operand = operator.strip == "=~" ? t.to_regexp : t.delete("'").strip
42
+ elsif t = scanner.scan(/\/\w+\//)
43
+
41
44
  elsif t = scanner.scan(/.*/)
42
45
  raise "Could not process symbol: #{t}"
43
46
  end
@@ -1,3 +1,3 @@
1
1
  class JsonPath
2
- VERSION = '0.8.10'.freeze
2
+ VERSION = '0.8.11'.freeze
3
3
  end
@@ -368,6 +368,17 @@ class TestJsonpath < MiniTest::Unit::TestCase
368
368
  assert_equal [{'number'=>'(492) 080-3961'}], JsonPath.new("$.data[?(@.number == '(492) 080-3961')]").on(data)
369
369
  end
370
370
 
371
+ def test_regex
372
+ assert_equal [], JsonPath.new('$..book[?(@.author =~ /herman/)]').on(@object)
373
+ assert_equal [
374
+ @object['store']['book'][2],
375
+ @object['store']['book'][4],
376
+ @object['store']['book'][5],
377
+ @object['store']['book'][6],
378
+ ], JsonPath.new('$..book[?(@.author =~ /herman|lukyanenko/i)]').on(@object)
379
+ assert_equal ["asdf", "asdf2"], JsonPath.new("$.store.book..tags[?(@ =~ /asdf/)]").on(@object)
380
+ end
381
+
371
382
  def example_object
372
383
  { 'store' => {
373
384
  '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.8.10
4
+ version: 0.8.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Hull
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-10-27 00:00:00.000000000 Z
12
+ date: 2018-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: to_regexp
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 0.2.1
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 0.2.1
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: code_stats
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -143,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
157
  version: '0'
144
158
  requirements: []
145
159
  rubyforge_project: jsonpath
146
- rubygems_version: 2.4.8
160
+ rubygems_version: 2.6.12
147
161
  signing_key:
148
162
  specification_version: 4
149
163
  summary: Ruby implementation of http://goessner.net/articles/JsonPath/