jsonpath 0.8.3 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dcbbacec3f46ae20e35ed77388c04a88ad1ef71
4
- data.tar.gz: 57aa1fec4c9556b8553521050c36bf8b18da6426
3
+ metadata.gz: 458f8cfb291930dcf500cb378da87a4c5ea08ada
4
+ data.tar.gz: 28cc08dea7e072cf946bd2384be4781abeb214f5
5
5
  SHA512:
6
- metadata.gz: 17d51a6fefe97232268f2fd393de4a2df23bd777a80207fbab5a5acce2259348e0683500b9e38c911f60fcf9dc55200c943c388a5c61044fc15e0c337838851d
7
- data.tar.gz: 62a738bdde2652f8c8936c11fe1ed300f87bd6d9b758b3d79f190370bd04cb91c7336a8e9bc8e2268a258782f6e12badfe1a5647fd98eed00f4fa30cd807136a
6
+ metadata.gz: 32b2d7550e5676ea6b1a4403633ffe8da9fd73638ca7ec87b556ab263e05788adf78a023fb488fddb22c14733d0f504abda74c9f26890037a635864908a8e146
7
+ data.tar.gz: 35ac4056bc5d22ddc3192824d7e228f212aff357e2ae789908b7d855601c78c64a4678c188983873e173201b02c227651bdc7cca7fe86b608f53e5ce83d1d35c
@@ -22,7 +22,7 @@ class JsonPath
22
22
  end
23
23
 
24
24
  def parse_exp(exp)
25
- exp = exp.gsub(/@/, '').gsub(/[\(\)]/, '')
25
+ exp = exp.gsub(/@/, '').gsub(/[\(\)]/, '').gsub(/"/, '\'').strip
26
26
  scanner = StringScanner.new(exp)
27
27
  elements = []
28
28
  until scanner.eos?
@@ -34,9 +34,9 @@ class JsonPath
34
34
  end
35
35
  if t = scanner.scan(/\['\w+'\]+/)
36
36
  elements << t.gsub(/\[|\]|'|\s+/, '')
37
- elsif t = scanner.scan(/\s+[<>=][<>=]?\s+?/)
37
+ elsif t = scanner.scan(/(\s+)?[<>=][<>=]?(\s+)?/)
38
38
  operator = t
39
- elsif t = scanner.scan(/(\s+)?'?(\w+)?[.,]?(\w+)?'?(\s+)?/) # @TODO: At this point I should trim somewhere...
39
+ elsif t = scanner.scan(/(\s+)?'?.*'?(\s+)?/)
40
40
  operand = t.delete("'").strip
41
41
  elsif t = scanner.scan(/.*/)
42
42
  raise "Could not process symbol: #{t}"
@@ -45,6 +45,7 @@ class JsonPath
45
45
  el = dig(elements, @_current_node)
46
46
  return false unless el
47
47
  return true if operator.nil? && el
48
+
48
49
  operand = operand.to_f if operand.to_i.to_s == operand || operand.to_f.to_s == operand
49
50
  el.send(operator.strip, operand)
50
51
  end
@@ -1,3 +1,3 @@
1
1
  class JsonPath
2
- VERSION = '0.8.3'.freeze
2
+ VERSION = '0.8.4'.freeze
3
3
  end
@@ -257,6 +257,16 @@ class TestJsonpath < MiniTest::Unit::TestCase
257
257
 
258
258
  def test_dig_return_string
259
259
  assert_equal ['asdf'], JsonPath.new("$.store.book..tags[?(@ == 'asdf')]").on(@object)
260
+ assert_equal [], JsonPath.new("$.store.book..tags[?(@ == 'not_asdf')]").on(@object)
261
+ end
262
+
263
+ def test_slash_in_value
264
+ data = {
265
+ 'data' => {
266
+ 'type' => 'mps/awesome'
267
+ }
268
+ }
269
+ assert_equal [{ 'type' => 'mps/awesome' }], JsonPath.new("$.data[?(@.type == \"mps/awesome\")]").on(data)
260
270
  end
261
271
 
262
272
  def example_object
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.3
4
+ version: 0.8.4
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-05-29 00:00:00.000000000 Z
12
+ date: 2017-06-10 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.5.1
146
+ rubygems_version: 2.6.10
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Ruby implementation of http://goessner.net/articles/JsonPath/