payload-translator 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/payload_translator/field_resolver.rb +1 -8
- data/lib/payload_translator/payload.rb +16 -0
- data/lib/payload_translator.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1daf169454e82e6d9ad3687a000be711b8ec35aa8301241da1a9b367f440364f
|
4
|
+
data.tar.gz: 9cd34aac2ed951140dfbb9be2f0e4eefb449b3b58aa5e48dbfcf30023d748f71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86e80c6da904c003d38e46dd8d142f460be0bf233fc9466d11aca7904cf127ad1917df38c8642a7a1aec50259b85389b31f8807442fc5644ecf4df7ec0e49979
|
7
|
+
data.tar.gz: f512af0bfa4c7639bd6335e1ad8d0b312b1457c180231ecc023e77989358ad89f98c806a034adb9fb18770c4084a0f3aaccb66403d287d80bff8e4d32363e5cd
|
@@ -51,14 +51,7 @@ module PayloadTranslator
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def search_value(field_or_fields)
|
54
|
-
|
55
|
-
field = field_or_fields.find { |field| payload[field] }
|
56
|
-
payload.fetch(field) { config["$default"] }
|
57
|
-
elsif field_or_fields =~ /\./
|
58
|
-
payload.dig(*field_or_fields.split(".")) || config["$default"]
|
59
|
-
else
|
60
|
-
payload.fetch(field_or_fields) { config["$default"] }
|
61
|
-
end
|
54
|
+
Payload.search_value(payload, field_or_fields, config["$default"])
|
62
55
|
end
|
63
56
|
|
64
57
|
def with_formatter
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module PayloadTranslator
|
2
|
+
class Payload
|
3
|
+
def self.fetch_field(payload, field_or_fields)
|
4
|
+
return field_or_fields unless field_or_fields.is_a?(Array)
|
5
|
+
|
6
|
+
field_or_fields.find { |field| search_value(payload, field) }
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.search_value(payload, field, default = nil)
|
10
|
+
field = fetch_field(payload, field)
|
11
|
+
return payload.dig(*field.split(".")) if field =~ /\./
|
12
|
+
|
13
|
+
payload.fetch(field, default)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/payload_translator.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: payload-translator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Savignano
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- lib/payload_translator.rb
|
36
36
|
- lib/payload_translator/config.rb
|
37
37
|
- lib/payload_translator/field_resolver.rb
|
38
|
+
- lib/payload_translator/payload.rb
|
38
39
|
- lib/payload_translator/service.rb
|
39
40
|
homepage: https://github.com/devmasx/payload-translator
|
40
41
|
licenses:
|