simple_symbolize 1.0.1 → 2.0.0
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/.github/workflows/ruby.yml +1 -1
- data/.github/workflows/ruby_gem.yml +1 -2
- data/.gitignore +1 -0
- data/.rubocop_todo.yml +19 -14
- data/README.md +28 -0
- data/lib/simple_symbolize/version.rb +1 -1
- data/lib/simple_symbolize.rb +26 -0
- data/simple_symbolize.gemspec +2 -2
- metadata +5 -6
- data/Gemfile.lock +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e23023a3bb1c8d394ba3059e5e72d0fef3480b5c0f09900aa9d00e61d784058
|
4
|
+
data.tar.gz: 557b65ea91d5db0400dd5aa23b66894d9fe5576962bfc7c1bf9895337ccfc093
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67ef8dd2fa3215f422fe90ec76f86da67a61f6801a3f6cc1ef9cfb763136d2fe52ba561ab0339e80eab120c16ab0c03f1841868abc9101a61d8f55d45fd3c123
|
7
|
+
data.tar.gz: e330593b6aae61ad7ed11e6c82a7e9be6b3292d25847e69eafef9218583eaec787b9127e15447f8ca5f0c3d628b459909b5eb46f5a9414ca13f8b7daf0a36acd
|
data/.github/workflows/ruby.yml
CHANGED
@@ -9,7 +9,7 @@ jobs:
|
|
9
9
|
runs-on: ubuntu-latest
|
10
10
|
strategy:
|
11
11
|
matrix:
|
12
|
-
ruby-version: [ '2.
|
12
|
+
ruby-version: [ '2.7', '3.0', '3.1' ]
|
13
13
|
|
14
14
|
steps:
|
15
15
|
- uses: actions/checkout@v2
|
@@ -25,7 +25,6 @@ jobs:
|
|
25
25
|
|
26
26
|
deploy:
|
27
27
|
needs: test
|
28
|
-
name: Build + Publish
|
29
28
|
runs-on: ubuntu-latest
|
30
29
|
permissions:
|
31
30
|
packages: write
|
data/.gitignore
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,13 +1,28 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2022-05-20 09:59:54 UTC using RuboCop version 1.29.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
9
|
# Offense count: 1
|
10
|
-
#
|
10
|
+
# This cop supports safe auto-correction (--auto-correct).
|
11
|
+
# Configuration parameters: Include.
|
12
|
+
# Include: **/*.gemspec
|
13
|
+
Gemspec/RequireMFA:
|
14
|
+
Exclude:
|
15
|
+
- 'simple_symbolize.gemspec'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Configuration parameters: Include.
|
19
|
+
# Include: **/*.gemspec
|
20
|
+
Gemspec/RequiredRubyVersion:
|
21
|
+
Exclude:
|
22
|
+
- 'simple_symbolize.gemspec'
|
23
|
+
|
24
|
+
# Offense count: 1
|
25
|
+
# This cop supports safe auto-correction (--auto-correct).
|
11
26
|
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
|
12
27
|
Lint/UnusedMethodArgument:
|
13
28
|
Exclude:
|
@@ -35,7 +50,7 @@ Style/Documentation:
|
|
35
50
|
- 'lib/simple_symbolize.rb'
|
36
51
|
|
37
52
|
# Offense count: 10
|
38
|
-
#
|
53
|
+
# This cop supports safe auto-correction (--auto-correct).
|
39
54
|
# Configuration parameters: EnforcedStyle.
|
40
55
|
# SupportedStyles: always, always_true, never
|
41
56
|
Style/FrozenStringLiteralComment:
|
@@ -51,17 +66,7 @@ Style/FrozenStringLiteralComment:
|
|
51
66
|
- 'spec/simple_symbolize_spec.rb'
|
52
67
|
- 'spec/spec_helper.rb'
|
53
68
|
|
69
|
+
# Offense count: 1
|
54
70
|
Style/MixinUsage:
|
55
71
|
Exclude:
|
56
72
|
- 'lib/simple_symbolize.rb'
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
data/README.md
CHANGED
@@ -70,6 +70,34 @@ SimpleSymbolize.translate do |trans|
|
|
70
70
|
end
|
71
71
|
```
|
72
72
|
|
73
|
+
## Updates!
|
74
|
+
|
75
|
+
V1.1: SimpleSymbolize has got new friends!
|
76
|
+
|
77
|
+
Introducing `elementize` and `camelize`.
|
78
|
+
|
79
|
+
### Elementize
|
80
|
+
|
81
|
+
Sometimes you just want a simple String obj without all the fuss. Elementize takes your String obj, removes that fuss
|
82
|
+
and returns you a simple-to-use String.
|
83
|
+
|
84
|
+
#### Example
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
elementize('hello world!') # => "hello_world"
|
88
|
+
```
|
89
|
+
|
90
|
+
### Camelize
|
91
|
+
|
92
|
+
Great for working with APIs that require fields in a JSON format. Camelize clears away the clutter and returns you
|
93
|
+
a Symbolized object in camelCase.
|
94
|
+
|
95
|
+
#### Example
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
camelize('hello world!') # => :helloWorld
|
99
|
+
```
|
100
|
+
|
73
101
|
[comment]: <> (## Contributing)
|
74
102
|
|
75
103
|
[comment]: <> (Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/simple_symbolize.)
|
data/lib/simple_symbolize.rb
CHANGED
@@ -34,4 +34,30 @@ module SimpleSymbolize
|
|
34
34
|
str.downcase.tr(SimpleSymbolize.translations.underscore.join, '_')
|
35
35
|
&.tr(SimpleSymbolize.translations.remove.join, '')&.to_sym
|
36
36
|
end
|
37
|
+
|
38
|
+
# Symbolizes a String object and returns it as a String object.
|
39
|
+
#
|
40
|
+
# @param str [String] the String object to be symbolized.
|
41
|
+
#
|
42
|
+
# @example Symbolize a string using the camelize method
|
43
|
+
# elementize("hello world!") #=> "helloWorld"
|
44
|
+
def elementize(str)
|
45
|
+
return str unless str.is_a?(Symbol) || str.is_a?(String)
|
46
|
+
|
47
|
+
symbolize(str).to_s
|
48
|
+
end
|
49
|
+
|
50
|
+
# Turns a String object into a camelCase Symbol.
|
51
|
+
#
|
52
|
+
# @param str [String] the String object to be camelized.
|
53
|
+
#
|
54
|
+
# @example Camelize a string using the camelize method
|
55
|
+
# camelize("hello world!") #=> :helloWorld
|
56
|
+
def camelize(str)
|
57
|
+
return str unless str.is_a?(String) || str.is_a?(Symbol)
|
58
|
+
return str.to_sym if str.is_a?(String) && (str.split(/[_ ]/).size <= 1)
|
59
|
+
|
60
|
+
first, *rest = elementize(str).split('_')
|
61
|
+
rest ? (first << rest.map(&:capitalize).join).to_sym : first.to_sym
|
62
|
+
end
|
37
63
|
end
|
data/simple_symbolize.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = 'https://github.com/dvla/simple-symbolize'
|
15
15
|
|
16
16
|
spec.license = 'MIT'
|
17
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
17
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
|
18
18
|
|
19
19
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
20
20
|
|
@@ -33,5 +33,5 @@ Gem::Specification.new do |spec|
|
|
33
33
|
|
34
34
|
spec.add_development_dependency 'rake', '~> 12.0'
|
35
35
|
spec.add_development_dependency 'rspec', '~> 3.2'
|
36
|
-
spec.add_development_dependency 'rubocop', '~> 1.
|
36
|
+
spec.add_development_dependency 'rubocop', '~> 1.29.0'
|
37
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_symbolize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alexo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.29.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.29.0
|
55
55
|
description: 'simple_symbolize will remove special characters from a String, replacing
|
56
56
|
whitespace with an underscore, down-casing and finally calling the #to_sym String
|
57
57
|
method. Configure this gem to your hearts content!'
|
@@ -68,7 +68,6 @@ files:
|
|
68
68
|
- ".rubocop.yml"
|
69
69
|
- ".rubocop_todo.yml"
|
70
70
|
- Gemfile
|
71
|
-
- Gemfile.lock
|
72
71
|
- LICENSE.txt
|
73
72
|
- README.md
|
74
73
|
- Rakefile
|
@@ -93,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
92
|
requirements:
|
94
93
|
- - ">="
|
95
94
|
- !ruby/object:Gem::Version
|
96
|
-
version: 2.
|
95
|
+
version: 2.7.0
|
97
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
97
|
requirements:
|
99
98
|
- - ">="
|
data/Gemfile.lock
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
simple_symbolize (1.0.1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
ast (2.4.2)
|
10
|
-
diff-lcs (1.4.4)
|
11
|
-
parallel (1.20.1)
|
12
|
-
parser (3.0.1.1)
|
13
|
-
ast (~> 2.4.1)
|
14
|
-
rainbow (3.0.0)
|
15
|
-
rake (12.3.3)
|
16
|
-
regexp_parser (2.1.1)
|
17
|
-
rexml (3.2.5)
|
18
|
-
rspec (3.10.0)
|
19
|
-
rspec-core (~> 3.10.0)
|
20
|
-
rspec-expectations (~> 3.10.0)
|
21
|
-
rspec-mocks (~> 3.10.0)
|
22
|
-
rspec-core (3.10.1)
|
23
|
-
rspec-support (~> 3.10.0)
|
24
|
-
rspec-expectations (3.10.1)
|
25
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
-
rspec-support (~> 3.10.0)
|
27
|
-
rspec-mocks (3.10.2)
|
28
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
-
rspec-support (~> 3.10.0)
|
30
|
-
rspec-support (3.10.2)
|
31
|
-
rubocop (1.18.0)
|
32
|
-
parallel (~> 1.10)
|
33
|
-
parser (>= 3.0.0.0)
|
34
|
-
rainbow (>= 2.2.2, < 4.0)
|
35
|
-
regexp_parser (>= 1.8, < 3.0)
|
36
|
-
rexml
|
37
|
-
rubocop-ast (>= 1.7.0, < 2.0)
|
38
|
-
ruby-progressbar (~> 1.7)
|
39
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
40
|
-
rubocop-ast (1.7.0)
|
41
|
-
parser (>= 3.0.1.1)
|
42
|
-
ruby-progressbar (1.11.0)
|
43
|
-
unicode-display_width (2.0.0)
|
44
|
-
|
45
|
-
PLATFORMS
|
46
|
-
ruby
|
47
|
-
|
48
|
-
DEPENDENCIES
|
49
|
-
rake (~> 12.0)
|
50
|
-
rspec (~> 3.2)
|
51
|
-
rubocop (~> 1.18.0)
|
52
|
-
simple_symbolize!
|
53
|
-
|
54
|
-
BUNDLED WITH
|
55
|
-
2.2.15
|