jsonpath 0.8.7 → 0.8.8

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: c4dc5e8947c2c9855c34c7d0f25fb750393002f9
4
- data.tar.gz: 5ee652f3eed9380f357d19a0ff53dfa2dd9d64e2
3
+ metadata.gz: 401aa3e206ffa2419b6d577e09e721a5d2a0eb5d
4
+ data.tar.gz: 2fbf9f702bd048b551b494768c31a0e9aef8c361
5
5
  SHA512:
6
- metadata.gz: 3a462c34b402670a1b627c5de62147ad08e33db5a014cd37dfa53bb6c6a89ce3cc63e272e8c993a5b28ccae29a1069aa27636127bc594e4e0414d6da22c4e0f5
7
- data.tar.gz: 50ac0441287012f54454e843eab9881f24eeec91d8e7b6b7796f5155dc7b520bd64d8df0e468d52130ad3c68f8d8e560b04e494cd835c8c2a86e689e0ea2523a
6
+ metadata.gz: c2bba3a7ff2c1e8cde53b60fdc49ab579e55eb7064a059a2f5c622088bbadc304db26741c371aa46a3e97a1e6d85e6a942ccd8f3727ca0522972d094f41f72e0
7
+ data.tar.gz: ace0993e371d6365967652e3e8240860a197e736c8f91870341bed2163e940fcc0035ad91598a7581bb0285408c2250c3488890eeb1b722060bf6a0de9ee3495
@@ -1,4 +1,5 @@
1
1
  rvm:
2
2
  - 2.1.6
3
3
  - 2.3.1
4
- - jruby
4
+ - ruby-head
5
+ - jruby-head
@@ -22,7 +22,7 @@ class JsonPath
22
22
  end
23
23
 
24
24
  def parse_exp(exp)
25
- exp = exp.gsub(/@/, '').gsub(/[\(\)]/, '').gsub(/"/, '\'').strip
25
+ exp = exp.sub(/@/, '').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(/\['\w+'\]+/)
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.7'.freeze
2
+ VERSION = '0.8.8'.freeze
3
3
  end
@@ -295,6 +295,56 @@ class TestJsonpath < MiniTest::Unit::TestCase
295
295
  assert_equal([{"type"=>"users", "id"=>"123"}], JsonPath.new("$.foo[?(@.id == '123')]").on(data))
296
296
  end
297
297
 
298
+ def test_at_in_filter
299
+ jsonld = {
300
+ "mentions" => [
301
+ {
302
+ "name" => "Delimara Powerplant",
303
+ "identifier" => "krzana://took/powerstation/Delimara Powerplant",
304
+ "@type" => "Place",
305
+ "geo" => {
306
+ "latitude" => 35.83020073454,
307
+ "longitude" => 14.55602645874
308
+ }
309
+ }
310
+ ]
311
+ }
312
+ assert_equal(['Place'], JsonPath.new("$..mentions[?(@['@type'] == 'Place')].@type").on(jsonld))
313
+ end
314
+
315
+ def test_dollar_in_filter
316
+ jsonld = {
317
+ "mentions" => [
318
+ {
319
+ "name" => "Delimara Powerplant",
320
+ "identifier" => "krzana://took/powerstation/Delimara Powerplant",
321
+ "$type" => "Place",
322
+ "geo" => {
323
+ "latitude" => 35.83020073454,
324
+ "longitude" => 14.55602645874
325
+ }
326
+ }
327
+ ]
328
+ }
329
+ assert_equal(['Place'], JsonPath.new("$..mentions[?(@['$type'] == 'Place')].$type").on(jsonld))
330
+ end
331
+
332
+ def test_at_in_value
333
+ jsonld = {
334
+ "mentions" =>
335
+ {
336
+ "name" => "Delimara Powerplant",
337
+ "identifier" => "krzana://took/powerstation/Delimara Powerplant",
338
+ "type" => "@Place",
339
+ "geo" => {
340
+ "latitude" => 35.83020073454,
341
+ "longitude" => 14.55602645874
342
+ }
343
+ }
344
+ }
345
+ assert_equal(['@Place'], JsonPath.new("$..mentions.type[?(@ == '@Place')]").on(jsonld))
346
+ end
347
+
298
348
  def example_object
299
349
  { 'store' => {
300
350
  '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.7
4
+ version: 0.8.8
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-08-11 00:00:00.000000000 Z
12
+ date: 2017-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json