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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fde01f6be61447c2fc968aeafceea47285f0d22a
4
- data.tar.gz: 2ed836cb7a1d7d6becf05b9be74fc77b21138b44
2
+ SHA256:
3
+ metadata.gz: fd6c52b52cd32b976a8d81cb028a167df111ff599edc1e859d6dfc43039bb6df
4
+ data.tar.gz: c064b14121a74c962c83dbcf0934bbd8dd92295641aa13b5c515c7bfb110b573
5
5
  SHA512:
6
- metadata.gz: 9d623c90c8468a670de0cc2911e728c072b88069f47510f07688747d460507476c7c38e071cf660803772b017d748c0e3180f638a38a6468a88fb6477c2ed7fd
7
- data.tar.gz: 7c6aa0a92878a03792cec6f503859e43902e5c2d2676e6b2680688a431c5fed6797fed043deee9c15d43e18dab4f26ce2687345e3613f04bcb46b22aecd218bd
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
@@ -8,7 +8,7 @@ require "rdoc/task"
8
8
 
9
9
  RDoc::Task.new(:rdoc) do |rdoc|
10
10
  rdoc.rdoc_dir = "rdoc"
11
- rdoc.title = "Filta"
11
+ rdoc.title = "Plissken"
12
12
  rdoc.options << "--line-numbers"
13
13
  rdoc.rdoc_files.include("README.md")
14
14
  rdoc.rdoc_files.include("lib/**/*.rb")
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.3.0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "plissken/methods"
2
4
  require "plissken/ext/array/to_snake_keys"
3
5
  require "plissken/ext/hash/to_snake_keys"
@@ -1,5 +1,5 @@
1
- class Array
1
+ # frozen_string_literal: true
2
2
 
3
+ class Array
3
4
  include Plissken::Methods
4
-
5
5
  end
@@ -1,5 +1,5 @@
1
- class Hash
1
+ # frozen_string_literal: true
2
2
 
3
+ class Hash
3
4
  include Plissken::Methods
4
-
5
5
  end
@@ -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(k)
28
- if k.is_a? Symbol
29
- underscore(k.to_s).to_sym
30
- elsif k.is_a? String
31
- underscore(k)
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
- k # Plissken can't snakify anything except strings and symbols
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
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Plissken
2
- VERSION = File.read("VERSION").split("\n").first
4
+ version_file = File.join(File.dirname(__FILE__), "../../VERSION")
5
+ VERSION = File.read(version_file).split("\n").first
3
6
  end
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.2.0
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: 2017-07-19 00:00:00.000000000 Z
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: '3.0'
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: '3.0'
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: '0.14'
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: '0.14'
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
- rubyforge_project:
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