json_data_extractor 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/json_data_extractor.rb +3 -4
- data/lib/src/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cb00933d27049f27e48ce4ad2cb134d9b06a92980bd7671db6fc05cd4403735
|
4
|
+
data.tar.gz: c1f95628a4649757d0b43231100d106c509aa735bb033a70fb63457f21cfbc1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78a85dde7ffef115d49797c4eeebbd794061a02141e07e7f86c4297e7361bf5e77b6da99fa9a529e9064fd33a1bc2981f5e14eeae35878f0b2be6f0e2b3ea54d
|
7
|
+
data.tar.gz: 17100164f78a48b3cfbeee7b1b3cf694c1807f7cfa27536316bf45e422c7a031dc86368e1d14ce64dc7795b6b944451ac499f89b02472e9339f2ee7a026cc53e
|
data/lib/json_data_extractor.rb
CHANGED
@@ -5,7 +5,7 @@ class JsonDataExtractor
|
|
5
5
|
attr_reader :data, :modifiers
|
6
6
|
|
7
7
|
def initialize(json_data, modifiers = {})
|
8
|
-
@data = json_data
|
8
|
+
@data = json_data.is_a?(Hash) ? json_data.to_json : json_data # hopefully it's a string; maybe we'll add some validation here
|
9
9
|
@modifiers = modifiers.transform_keys(&:to_sym) # todo address this later
|
10
10
|
end
|
11
11
|
|
@@ -24,14 +24,13 @@ class JsonDataExtractor
|
|
24
24
|
path = val[:path]
|
25
25
|
modifiers = Array(val[:modifiers] || val[:modifier]).map(&:to_sym)
|
26
26
|
array_type = 'array' == val[:type]
|
27
|
-
nested = val.delete(:schema)
|
27
|
+
nested = val.dup.delete(:schema)
|
28
28
|
else
|
29
29
|
path = val
|
30
30
|
modifiers = []
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
extracted_data = json_path.on(@data)
|
33
|
+
extracted_data = JsonPath.on(@data, path)
|
35
34
|
|
36
35
|
if extracted_data.empty?
|
37
36
|
results[key] = nil
|
data/lib/src/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_data_extractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Buslaev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|