plissken 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +3 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/plissken.rb +2 -0
- data/lib/plissken/ext/array/to_snake_keys.rb +2 -2
- data/lib/plissken/ext/hash/to_snake_keys.rb +2 -2
- data/lib/plissken/methods.rb +10 -10
- data/lib/plissken/version.rb +4 -1
- metadata +21 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fd6c52b52cd32b976a8d81cb028a167df111ff599edc1e859d6dfc43039bb6df
|
4
|
+
data.tar.gz: c064b14121a74c962c83dbcf0934bbd8dd92295641aa13b5c515c7bfb110b573
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81e31a0d3fa33ea153be0c01e8d6f6595ae7187ce4e996bac550151cae11c15a673e79562d6bea8f4bb6528a32300418bf3471aaaf1521758659b98eed016c51
|
7
|
+
data.tar.gz: d99ceeab78e31e031eeb46f993d8d446da12fdb82f215f2714b9a5bb9fe49826a7f5c8b88f1f58302c3c3980a745290d1a85c04b012f8abda397030b90fbc171
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Plissken
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/plissken.svg)](https://badge.fury.io/rb/plissken)
|
4
|
+
|
3
5
|
Have you ever needed to automatically convert JSON-style `camelBack` or `CamelCase` hash keys into more Rubyish `snake_case`?
|
4
6
|
|
5
7
|
Plissken to the rescue.
|
@@ -62,5 +64,4 @@ the [Awrence](http://github.com/futurechimp/awrence) gem.
|
|
62
64
|
|
63
65
|
## Copyright
|
64
66
|
|
65
|
-
Copyright (c) 2017 Dave Hrycyszyn. See LICENSE.txt for
|
66
|
-
further details.
|
67
|
+
Copyright (c) 2017 Dave Hrycyszyn. See LICENSE.txt for further details.
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/lib/plissken.rb
CHANGED
data/lib/plissken/methods.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Plissken
|
4
4
|
module Methods
|
5
|
-
|
6
5
|
# Recursively converts CamelCase and camelBack JSON-style hash keys to
|
7
6
|
# Rubyish snake_case, suitable for use during instantiation of Ruby
|
8
7
|
# model attributes.
|
@@ -24,27 +23,28 @@ module Plissken
|
|
24
23
|
Hash[value.map { |k, v| [underscore_key(k), to_snake_keys(v)] }]
|
25
24
|
end
|
26
25
|
|
27
|
-
def underscore_key(
|
28
|
-
if
|
29
|
-
underscore(
|
30
|
-
elsif
|
31
|
-
underscore(
|
26
|
+
def underscore_key(key)
|
27
|
+
if key.is_a? Symbol
|
28
|
+
underscore(key.to_s).to_sym
|
29
|
+
elsif key.is_a? String
|
30
|
+
underscore(key)
|
32
31
|
else
|
33
|
-
|
32
|
+
key # Plissken can't snakify anything except strings and symbols
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
37
36
|
def underscore(string)
|
38
37
|
@__memoize_underscore ||= {}
|
38
|
+
|
39
39
|
return @__memoize_underscore[string] if @__memoize_underscore[string]
|
40
|
+
|
40
41
|
@__memoize_underscore[string] =
|
41
|
-
string.tr(
|
42
|
+
string.tr("::", "/")
|
42
43
|
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
43
44
|
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
44
|
-
.tr(
|
45
|
+
.tr("-", "_")
|
45
46
|
.downcase
|
46
47
|
@__memoize_underscore[string]
|
47
48
|
end
|
48
|
-
|
49
49
|
end
|
50
50
|
end
|
data/lib/plissken/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plissken
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Hrycyszyn
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2019-01-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: minitest
|
@@ -18,28 +18,42 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '5.0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '5.0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: minitest-fail-fast
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0.1'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.1'
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
44
|
name: minitest-reporters
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
32
46
|
requirements:
|
33
47
|
- - "~>"
|
34
48
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
49
|
+
version: '1.3'
|
36
50
|
type: :development
|
37
51
|
prerelease: false
|
38
52
|
version_requirements: !ruby/object:Gem::Requirement
|
39
53
|
requirements:
|
40
54
|
- - "~>"
|
41
55
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
56
|
+
version: '1.3'
|
43
57
|
- !ruby/object:Gem::Dependency
|
44
58
|
name: rake
|
45
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
107
|
- !ruby/object:Gem::Version
|
94
108
|
version: '0'
|
95
109
|
requirements: []
|
96
|
-
|
97
|
-
rubygems_version: 2.6.11
|
110
|
+
rubygems_version: 3.0.1
|
98
111
|
signing_key:
|
99
112
|
specification_version: 4
|
100
113
|
summary: Snakify your camel keys when working with JSON APIs
|