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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 900265f2ab694f6f2bad9365934d726747c42ab6161abd89cee954c1b8cc09b5
4
- data.tar.gz: 73d2574fc410ed737df045d9933f69d3f9049323342c521db97be1e6c07ab213
3
+ metadata.gz: 0cb00933d27049f27e48ce4ad2cb134d9b06a92980bd7671db6fc05cd4403735
4
+ data.tar.gz: c1f95628a4649757d0b43231100d106c509aa735bb033a70fb63457f21cfbc1d
5
5
  SHA512:
6
- metadata.gz: 6f07161d8a3d53022dc387031349f486b731024d18beb1bd1e8522971f08194cc1e5e47863555539e263351a567b83d29e78920a24e9fb339e71c68e84ac3593
7
- data.tar.gz: 739d2626d2092b3d72ee3c287ea4f9d6e9353f46c52d6f2256c56301939cff112cb059a4a1321b1b4ef576bc9841f09b4f7598edd855f1cd3c5491a521de5957
6
+ metadata.gz: 78a85dde7ffef115d49797c4eeebbd794061a02141e07e7f86c4297e7361bf5e77b6da99fa9a529e9064fd33a1bc2981f5e14eeae35878f0b2be6f0e2b3ea54d
7
+ data.tar.gz: 17100164f78a48b3cfbeee7b1b3cf694c1807f7cfa27536316bf45e422c7a031dc86368e1d14ce64dc7795b6b944451ac499f89b02472e9339f2ee7a026cc53e
@@ -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
- json_path = JsonPath.new(path)
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
@@ -1,3 +1,3 @@
1
1
  class JsonDataExtractor
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.6'
3
3
  end
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
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-03-28 00:00:00.000000000 Z
11
+ date: 2023-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler