jsonpath 0.8.8 → 0.8.10

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: 401aa3e206ffa2419b6d577e09e721a5d2a0eb5d
4
- data.tar.gz: 2fbf9f702bd048b551b494768c31a0e9aef8c361
3
+ metadata.gz: 2ccfcb77f1e1d53075429a1de02a47582533adaa
4
+ data.tar.gz: df31c7f7e048956e4377c15102dbace9427e9a50
5
5
  SHA512:
6
- metadata.gz: c2bba3a7ff2c1e8cde53b60fdc49ab579e55eb7064a059a2f5c622088bbadc304db26741c371aa46a3e97a1e6d85e6a942ccd8f3727ca0522972d094f41f72e0
7
- data.tar.gz: ace0993e371d6365967652e3e8240860a197e736c8f91870341bed2163e940fcc0035ad91598a7581bb0285408c2250c3488890eeb1b722060bf6a0de9ee3495
6
+ metadata.gz: 525c8cff304cb529977edc935a2c2a8163b632a1e7290cef4b7ea73d80cb1c20a228ea18e545023231367c3255a74a5183a9f854c7b147877ff6cea9e5f716e5
7
+ data.tar.gz: 0dc3e440ba55497515f40b82d594beef82f70e495d20f658d839cb1ce2a757d626756bb0ce59aad526c3b0089b245769926875e257b67b93d625a5330039ba1c
@@ -22,7 +22,7 @@ class JsonPath
22
22
  end
23
23
 
24
24
  def parse_exp(exp)
25
- exp = exp.sub(/@/, '').gsub(/[\(\)]/, '').gsub(/"/, '\'').strip
25
+ exp = exp.sub(/@/, '').gsub(/^\(/, '').gsub(/\)$/, '').gsub(/"/, '\'').strip
26
26
  scanner = StringScanner.new(exp)
27
27
  elements = []
28
28
  until scanner.eos?
@@ -32,7 +32,7 @@ class JsonPath
32
32
  num = scanner.scan(/\d+/)
33
33
  return @_current_node.send(sym.to_sym).send(op.to_sym, num.to_i)
34
34
  end
35
- if t = scanner.scan(/\['[a-zA-Z@&\*\/\$%\^\?]+'\]+/)
35
+ if t = scanner.scan(/\['[a-zA-Z@&\*\/\$%\^\?_]+'\]+/)
36
36
  elements << t.gsub(/\[|\]|'|\s+/, '')
37
37
  elsif t = scanner.scan(/(\s+)?[<>=][<>=]?(\s+)?/)
38
38
  operator = t
@@ -1,3 +1,3 @@
1
1
  class JsonPath
2
- VERSION = '0.8.8'.freeze
2
+ VERSION = '0.8.10'.freeze
3
3
  end
@@ -329,6 +329,20 @@ class TestJsonpath < MiniTest::Unit::TestCase
329
329
  assert_equal(['Place'], JsonPath.new("$..mentions[?(@['$type'] == 'Place')].$type").on(jsonld))
330
330
  end
331
331
 
332
+ def test_underscore_in_filter
333
+ jsonld = {
334
+ "attributes" => [
335
+ {
336
+ "store" => [
337
+ { "with" => "urn" },
338
+ { "with_underscore" => "urn:1" }
339
+ ]
340
+ }
341
+ ]
342
+ }
343
+ assert_equal(['urn:1'], JsonPath.new("$.attributes..store[?(@['with_underscore'] == 'urn:1')].with_underscore").on(jsonld))
344
+ end
345
+
332
346
  def test_at_in_value
333
347
  jsonld = {
334
348
  "mentions" =>
@@ -343,7 +357,16 @@ class TestJsonpath < MiniTest::Unit::TestCase
343
357
  }
344
358
  }
345
359
  assert_equal(['@Place'], JsonPath.new("$..mentions.type[?(@ == '@Place')]").on(jsonld))
346
- end
360
+ end
361
+
362
+ def test_parens_in_value
363
+ data = {
364
+ 'data' => {
365
+ 'number' => '(492) 080-3961'
366
+ }
367
+ }
368
+ assert_equal [{'number'=>'(492) 080-3961'}], JsonPath.new("$.data[?(@.number == '(492) 080-3961')]").on(data)
369
+ end
347
370
 
348
371
  def example_object
349
372
  { 'store' => {
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.8
4
+ version: 0.8.10
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-01 00:00:00.000000000 Z
12
+ date: 2017-10-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  requirements: []
145
145
  rubyforge_project: jsonpath
146
- rubygems_version: 2.6.12
146
+ rubygems_version: 2.4.8
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Ruby implementation of http://goessner.net/articles/JsonPath/