json_data_extractor 0.0.14 → 0.0.16
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 +4 -4
- data/README.md +2 -0
- data/lib/json_data_extractor.rb +7 -1
- data/lib/src/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb1e531fd36334345d1fdaf9668b1c03c0a65e8f954605c8d4071734d70f7153
|
4
|
+
data.tar.gz: ee96e0f43442b7c1f7a8ca9b43c61a98ebf4a7067b2fe4daf19d14d32aac4088
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e25722f1867eced86d8367f9202f83155363547448876b75ec10c3865f5e6360bbd329fbd3aee7e87cef123324b0b157405b8d36c1ec6af4662309f188d0d85
|
7
|
+
data.tar.gz: 59db96a9ce39007d3bc87bcf242efc07dcf0142f2d997f32c443e86552276abdc29c2c205630944e3023019f446371a041ad334cff92a951fccd3be0c1feeafd
|
data/README.md
CHANGED
@@ -191,6 +191,8 @@ results = extractor.extract(schema)
|
|
191
191
|
|
192
192
|
```
|
193
193
|
|
194
|
+
You can also define any class that implements a `call` method and use it as a modifier.
|
195
|
+
|
194
196
|
Modifiers are called in the order in which they are defined, so keep that in mind when defining your
|
195
197
|
schema. By default JDE raises an ArgumentError if a modifier is not applicable, but this behaviour
|
196
198
|
can be configured to ignore missing modifiers. See Configuration options for details
|
data/lib/json_data_extractor.rb
CHANGED
@@ -36,6 +36,12 @@ class JsonDataExtractor
|
|
36
36
|
case mod
|
37
37
|
when Symbol, Proc
|
38
38
|
mod
|
39
|
+
when Class
|
40
|
+
if mod.respond_to?(:call)
|
41
|
+
mod
|
42
|
+
else
|
43
|
+
raise ArgumentError, "Modifier class must respond to call: #{mod.inspect}"
|
44
|
+
end
|
39
45
|
when String
|
40
46
|
mod.to_sym
|
41
47
|
else
|
@@ -103,7 +109,7 @@ class JsonDataExtractor
|
|
103
109
|
end
|
104
110
|
|
105
111
|
def apply_single_modifier(modifier, value)
|
106
|
-
if modifier.
|
112
|
+
if modifier.respond_to?(:call) # Matches Proc, Lambda, Method, and callable objects
|
107
113
|
modifier.call(value)
|
108
114
|
elsif modifiers.key?(modifier)
|
109
115
|
modifiers[modifier].call(value)
|
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.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Buslaev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,7 +122,7 @@ homepage: https://github.com/austerlitz/json_data_extractor
|
|
122
122
|
licenses:
|
123
123
|
- MIT
|
124
124
|
metadata: {}
|
125
|
-
post_install_message:
|
125
|
+
post_install_message:
|
126
126
|
rdoc_options: []
|
127
127
|
require_paths:
|
128
128
|
- lib
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubygems_version: 3.2.3
|
141
|
-
signing_key:
|
141
|
+
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Transform JSON data structures with the help of a simple schema and JsonPath
|
144
144
|
expressions. Use the JsonDataExtractor gem to extract and modify data from complex
|