hashlation 0.1.1 → 0.1.4
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 +46 -8
- data/hashlation.gemspec +2 -5
- data/lib/hashlation/complex.rb +0 -1
- data/lib/hashlation/simple.rb +0 -1
- data/lib/hashlation/version.rb +1 -1
- metadata +3 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a4749821b8641ec38d5873ef319710ea86068b57dde8691fd2c9ea4d588f5a1f
|
|
4
|
+
data.tar.gz: 1f1ba4280c4b9970fc9e6222712d630309d63c8ed1645746cf4a2abff1b56119
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: faabb932c886ab678c0387150cbfecac339de828cbbbdc1532460baf7883a86ed9273b52930e7aa84a1b8c83d0449280e25914bb010aba1e054445b383ab7492
|
|
7
|
+
data.tar.gz: ced1723b25e56f8426f0cdf1927c12f24b5eae62d4a399821276a572d81495f96509340677a858b57b7b152bd9106b12b1fe02431f69646d25f343eb4c1e7834
|
data/README.md
CHANGED
|
@@ -16,17 +16,51 @@ Or install it yourself as:
|
|
|
16
16
|
|
|
17
17
|
$ gem install hashlation
|
|
18
18
|
|
|
19
|
-
## Usage
|
|
20
19
|
|
|
21
|
-
Hashlation::Simple -> Hashlation::Simple.new(hash)
|
|
22
20
|
|
|
23
|
-
Handles simple string/symbol keys in conversion as well as singleton_methods. Much faster, but cannot hanlde edge cases in response.
|
|
24
|
-
|
|
25
|
-
Hashlation::Complex -> Hashlation::Complex.new(hash)
|
|
26
|
-
|
|
27
|
-
Handles MOST key types in conversion. If you know that your keys will contain leading Integer characters, or ':'.
|
|
28
21
|
|
|
29
|
-
|
|
22
|
+
## Methods
|
|
23
|
+
|
|
24
|
+
The returned `obj` includes the method `.keys` to list the keys on the object at every level.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
### Simple
|
|
29
|
+
|
|
30
|
+
Handles simple string/symbol keys in conversion as well as singleton_methods. Very fast, but cannot handle edge cases in keys.
|
|
31
|
+
|
|
32
|
+
Usage:
|
|
33
|
+
|
|
34
|
+
`obj = Hashlation::Simple.new(hash)`
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### Complex
|
|
40
|
+
|
|
41
|
+
Handles MOST key types in conversion. If you know that your keys will contain leading Integer characters, or ':' use this method.
|
|
42
|
+
|
|
43
|
+
Usage:
|
|
44
|
+
|
|
45
|
+
`obj = Hashlation::Complex.new(hash)`
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
** If `Complex` fails due to inability to read a key, please report in GitHub Issues. Thanks! **
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Translated Keys Format:
|
|
54
|
+
|
|
55
|
+
Keys that cannot be set as-is by attr_accessor will be transformed.
|
|
56
|
+
|
|
57
|
+
### Simple:
|
|
58
|
+
|
|
59
|
+
- `'Test-Name' -> obj.test_name`
|
|
60
|
+
|
|
61
|
+
### Complex:
|
|
62
|
+
|
|
63
|
+
- `'11123:12312' -> obj._11123_12312`
|
|
30
64
|
|
|
31
65
|
## Development
|
|
32
66
|
|
|
@@ -41,3 +75,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/rharri
|
|
|
41
75
|
## License
|
|
42
76
|
|
|
43
77
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
*Naming credit belongs to my wife, who bales out my inability to name stuff..*
|
data/hashlation.gemspec
CHANGED
|
@@ -8,11 +8,8 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.authors = ["rharris389"]
|
|
9
9
|
spec.email = ["56176404+rharris389@users.noreply.github.com"]
|
|
10
10
|
|
|
11
|
-
spec.summary = "
|
|
12
|
-
spec.description = "
|
|
13
|
-
Hashlation::Simple.new(hash_object) will handle most common string and symbol keys.
|
|
14
|
-
Certain characters in a key, such as a leading Integer or a ':' will not translate with Simple.
|
|
15
|
-
These must be processed with the Hashlation::Complex.new(hash_object) method. Name credit to my wife."
|
|
11
|
+
spec.summary = "Lightweight response parsing"
|
|
12
|
+
spec.description = "Lightweight parser for cleaner navigation of large or deeply nested hashes."
|
|
16
13
|
spec.homepage = "https://github.com/rharris389/hashlation"
|
|
17
14
|
spec.license = "MIT"
|
|
18
15
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
data/lib/hashlation/complex.rb
CHANGED
|
@@ -60,7 +60,6 @@ module Hashlation
|
|
|
60
60
|
|
|
61
61
|
def sanatize_key(key)
|
|
62
62
|
# If this is to be responses may contain improper keys, uncomment and implement for all attr names
|
|
63
|
-
# the PrimeTrust API responses only need to be underscored as they do not contain leading integers or dis-allowed characters
|
|
64
63
|
key[0,1] =~ /^[0-9].*/ ? "_#{key.tr(':', '_').underscore}" : key.tr(':', '_').underscore
|
|
65
64
|
end
|
|
66
65
|
|
data/lib/hashlation/simple.rb
CHANGED
|
@@ -58,7 +58,6 @@ module Hashlation
|
|
|
58
58
|
|
|
59
59
|
def sanatize_key(key)
|
|
60
60
|
# If this is to be responses may contain improper keys, uncomment and implement for all attr names
|
|
61
|
-
# the PrimeTrust API responses only need to be underscored as they do not contain leading integers or dis-allowed characters
|
|
62
61
|
key.underscore
|
|
63
62
|
end
|
|
64
63
|
|
data/lib/hashlation/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hashlation
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- rharris389
|
|
@@ -10,11 +10,7 @@ bindir: exe
|
|
|
10
10
|
cert_chain: []
|
|
11
11
|
date: 2022-05-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description:
|
|
14
|
-
Quickly parses hashes into objects for cleaner navigation of large response objects.
|
|
15
|
-
Hashlation::Simple.new(hash_object) will handle most common string and symbol keys.
|
|
16
|
-
Certain characters in a key, such as a leading Integer or a ':' will not translate with Simple.
|
|
17
|
-
These must be processed with the Hashlation::Complex.new(hash_object) method. Name credit to my wife.
|
|
13
|
+
description: Lightweight parser for cleaner navigation of large or deeply nested hashes.
|
|
18
14
|
email:
|
|
19
15
|
- 56176404+rharris389@users.noreply.github.com
|
|
20
16
|
executables: []
|
|
@@ -73,5 +69,5 @@ requirements: []
|
|
|
73
69
|
rubygems_version: 3.1.2
|
|
74
70
|
signing_key:
|
|
75
71
|
specification_version: 4
|
|
76
|
-
summary:
|
|
72
|
+
summary: Lightweight response parsing
|
|
77
73
|
test_files: []
|