poller-json 0.1.6 → 0.2.0
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 +8 -8
- data/lib/matchers/json/json_path.rb +1 -2
- data/lib/matchers/json/json_path_has_array.rb +2 -7
- data/lib/matchers/json/json_path_has_object.rb +2 -7
- data/lib/matchers/json/json_path_has_thing.rb +22 -0
- data/lib/poller/json/version.rb +1 -1
- data/lib/poller/poller_json.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODM1YTM4NzhlY2NmMGZjMTJlM2Q1NGE5NmY3ZGM5ZTAyYzI4Mjg5Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjBkZjYzNWU3NzgwZDYzZDVjYWYyYzE4MzM4YmY1YmI3MDgwYmNlNA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTgzZDQwNmE2MjZmMmM3MDE2ZDdiNTU0NDdhMjhlODYwNzllYWM1ZDAyMWIx
|
10
|
+
ZDYzYzU3ZTAxZDRmODg2NGE5ZWE3N2NhYTcxMzA3NDcyYThhNGIxZTA0YTRk
|
11
|
+
Y2U0M2E4MTE5ZjNhMDQwOGNjYzcwOGY1MDNjNDQzMjQ0NjI1NTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODk5ZDM1NjJlZDBkMmE4NDEyZjY4YzYwNmJiNWU2Y2ZhZTlhNzJlMzJhN2Nl
|
14
|
+
MDdmMmI3MjZiMDljOGNmNWMwZDYzZmZhYjJjYjBiZTNjYjhlNjMzYzM4OGFk
|
15
|
+
Mzk4MTI2OTU5NGM0MThkNDM3NmZjODZlY2U1N2E2NDZkZjY1MTA=
|
@@ -26,8 +26,7 @@ module Matchers
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# TODO: the regular expressions below will catch very few errors
|
29
|
-
def json_path_valid?(path)
|
30
|
-
# TODO: figure out how groups could be extracted and then looked at individually (each do)
|
29
|
+
def json_path_valid?(path)
|
31
30
|
notation = path.include?('[\'') ? :bracket : :dot
|
32
31
|
path_regex = /^\$[a-zA-Z0-9_(\[\d\])\.]*[^\.]$/ if notation == :dot
|
33
32
|
path_regex = /^\$[a-zA-Z0-9_(\[\d\])\.\']*[^\.]$/ if notation == :bracket
|
@@ -2,15 +2,10 @@ module Matchers
|
|
2
2
|
module JSON
|
3
3
|
class JSONPathHasArray
|
4
4
|
include JSONPath
|
5
|
+
include JSONPathHasThing
|
5
6
|
|
6
7
|
def initialize(json_path, json_array)
|
7
|
-
|
8
|
-
@json_array = json_array.is_a?(Array) ? json_array : ::JSON.parse(json_array)
|
9
|
-
end
|
10
|
-
|
11
|
-
def matches?(document_s)
|
12
|
-
json_hash = ::JSON.parse(document_s)
|
13
|
-
value_on_path(json_hash, @json_path) == @json_array
|
8
|
+
super(json_path, json_array)
|
14
9
|
end
|
15
10
|
end
|
16
11
|
end
|
@@ -2,15 +2,10 @@ module Matchers
|
|
2
2
|
module JSON
|
3
3
|
class JSONPathHasObject
|
4
4
|
include JSONPath
|
5
|
+
include JSONPathHasThing
|
5
6
|
|
6
7
|
def initialize(json_path, json_object)
|
7
|
-
|
8
|
-
@json_object = json_object.is_a?(Hash) ? json_object : ::JSON.parse(json_object)
|
9
|
-
end
|
10
|
-
|
11
|
-
def matches?(document_s)
|
12
|
-
json_hash = ::JSON.parse(document_s)
|
13
|
-
value_on_path(json_hash, @json_path) == @json_object
|
8
|
+
super(json_path, json_object)
|
14
9
|
end
|
15
10
|
end
|
16
11
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Matchers
|
2
|
+
module JSON
|
3
|
+
module JSONPathHasThing
|
4
|
+
|
5
|
+
def initialize(json_path, json_thing)
|
6
|
+
@json_path = json_path
|
7
|
+
@json_thing = discriminate json_thing
|
8
|
+
end
|
9
|
+
|
10
|
+
def matches?(document_s)
|
11
|
+
json_doc_hash = ::JSON.parse document_s
|
12
|
+
value_on_path(json_doc_hash, @json_path) == @json_thing
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def discriminate(thing)
|
17
|
+
return thing if [Array, Hash].include? thing.class
|
18
|
+
::JSON.parse thing
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/poller/json/version.rb
CHANGED
data/lib/poller/poller_json.rb
CHANGED
@@ -2,6 +2,7 @@ require 'json'
|
|
2
2
|
require 'poller'
|
3
3
|
require 'matchers/json/json_path'
|
4
4
|
require 'matchers/json/document_contains_json_path'
|
5
|
+
require 'matchers/json/json_path_has_thing'
|
5
6
|
require 'matchers/json/json_path_has_value'
|
6
7
|
require 'matchers/json/json_path_has_object'
|
7
8
|
require 'matchers/json/json_path_has_array'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poller-json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Krogemann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: poller
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: multi_json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- lib/matchers/json/json_path.rb
|
78
78
|
- lib/matchers/json/json_path_has_array.rb
|
79
79
|
- lib/matchers/json/json_path_has_object.rb
|
80
|
+
- lib/matchers/json/json_path_has_thing.rb
|
80
81
|
- lib/matchers/json/json_path_has_value.rb
|
81
82
|
- lib/poller/json/version.rb
|
82
83
|
- lib/poller/poller_json.rb
|