json_data_extractor 0.0.13 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/json_data_extractor.rb +2 -2
- 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: e6c3dff84f5c9b6ce630ff1973dc3e657ebfb93cf96306c9941e63bc9fb4fde5
|
4
|
+
data.tar.gz: cb83044ea64e5d560e24d6be3d0e37413eb8302c7987e18131767ad9cdd477d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd67bb3c81f02873642daefc1b1289edbaa682612348ae3f74d057e6d419ad851f927801e1f0be3b3f9b4784fa7dcfa8adac7755e046624f77994ee518040256
|
7
|
+
data.tar.gz: 7b32c1b8e626752a5fb1c92be92a8ff436be825f57862d16104425cd0b4224206f5a4be009b42660a57e10bde154a45f8ed995dbe8d42246db8d54f841b11ca7
|
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
@@ -103,14 +103,14 @@ class JsonDataExtractor
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def apply_single_modifier(modifier, value)
|
106
|
-
if modifier.
|
106
|
+
if modifier.respond_to?(:call) # Matches Proc, Lambda, Method, and callable objects
|
107
107
|
modifier.call(value)
|
108
108
|
elsif modifiers.key?(modifier)
|
109
109
|
modifiers[modifier].call(value)
|
110
110
|
elsif value.respond_to?(modifier)
|
111
111
|
value.send(modifier)
|
112
112
|
elsif self.class.configuration.strict_modifiers
|
113
|
-
raise ArgumentError, "
|
113
|
+
raise ArgumentError, "Modifier: <:#{modifier}> cannot be applied to value <#{value.inspect}>"
|
114
114
|
else
|
115
115
|
value
|
116
116
|
end
|
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.15
|
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
|