simple_symbolize 1.0.0 → 2.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00aee90791b358af5b1a734d538f40bdd1a200b59888ca23efd18b1ceb40593a
4
- data.tar.gz: a7e7e1087d2becd6181bf87243e823ce361dd8b40b3b25d04265ba589b6b4637
3
+ metadata.gz: 59e6e0627c56ba92e83ade0f7da175a6900efb94239e7d090cf3021ceecc2c36
4
+ data.tar.gz: c38a440d4feca6c293e39ddd44241f78c1b0096933a60d0929abb254ffe77497
5
5
  SHA512:
6
- metadata.gz: 8f44009fa310ff0c0ad1595b5ece9f99c64168f3ca4bf5c4d50bce8edd198507d6761fe577894891aab26fbedb30e2d78bbcfcc9405ac6334c45060325d1cd09
7
- data.tar.gz: 4468a0ebbe074887e985416a9c8abda90d688290c62d3c3e0faef0bd8ccddf52851848e896e57ed5835d05d9146cfe15852df6c285b47ea1c59e444afe4f6a57
6
+ metadata.gz: 6242fbdc38514b7eed4b3931eb5391abc5e7d6b833ccb8bd5dc982c4eb301b4606b256139233ab5f07efec72de2f6fc8964cc38a99a33d4ddd5e734f77382c1e
7
+ data.tar.gz: bf26933555776d4b25f32c3bc2df40e385ad38f45c599b2129a981aae677f38156dbbec63351968e217478c4ea600063a08c02fe6c83320764afa49ef19cdbdc
@@ -0,0 +1,33 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches-ignore:
13
+ - 'main'
14
+
15
+ jobs:
16
+ test:
17
+
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ matrix:
21
+ ruby-version: ['2.7', '3.0', '3.1']
22
+
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+ - name: Set up Ruby
26
+ uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby-version }}
29
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
30
+ - name: Rubocop
31
+ run: bundle exec rubocop
32
+ - name: Run tests
33
+ run: bundle exec rake
@@ -0,0 +1,50 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ ruby-version: [ '2.7', '3.0', '3.1' ]
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby-version }}
20
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
21
+ - name: Rubocop
22
+ run: bundle exec rubocop
23
+ - name: Run tests
24
+ run: bundle exec rake
25
+
26
+ deploy:
27
+ needs: test
28
+ runs-on: ubuntu-latest
29
+ permissions:
30
+ packages: write
31
+ contents: read
32
+
33
+ steps:
34
+ - uses: actions/checkout@v2
35
+ - name: Set up Ruby 3.0.1
36
+ uses: ruby/setup-ruby@v1
37
+ with:
38
+ ruby-version: 3.0.1
39
+ bundler-cache: true
40
+
41
+ - name: Publish to RubyGems
42
+ run: |
43
+ mkdir -p $HOME/.gem
44
+ touch $HOME/.gem/credentials
45
+ chmod 0600 $HOME/.gem/credentials
46
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
47
+ gem build *.gemspec
48
+ gem push *.gem
49
+ env:
50
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  *.gem
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
+ Gemfile.lock
data/.rubocop_todo.yml CHANGED
@@ -1,13 +1,28 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2021-06-29 14:23:53 UTC using RuboCop version 1.18.0.
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
- # Cop supports --auto-correct.
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
- # Cop supports --auto-correct.
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/Gemfile CHANGED
@@ -2,6 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in simple_symbolize.gemspec
4
4
  gemspec
5
-
6
- gem 'rake', '~> 12.0'
7
- gem 'rspec', '~> 3.0'
data/README.md CHANGED
@@ -8,7 +8,7 @@ Wait, doesn't String already have a `to_sym` method?
8
8
  Correct! However, this gem takes it one step further by transforming special characters and whitespace to give you a
9
9
  simple easy to work with Symbol.
10
10
 
11
- It works by transforming special characters in a String like `'!'` into underscores and removing whitespace.
11
+ It works by removing special characters in a String like `'!'` and underscoring any whitespace.
12
12
 
13
13
  #### Example
14
14
 
@@ -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/bin/console CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'bundler/setup'
4
4
  require 'simple_symbolize'
5
+ require 'pry'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -1,3 +1,3 @@
1
1
  module SimpleSymbolize
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '2.0.1'.freeze
3
3
  end
@@ -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 Elementize a string using the elementize 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 symbolize(str) 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 : symbolize(first)
62
+ end
37
63
  end
@@ -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.5.0')
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
 
@@ -31,6 +31,8 @@ Gem::Specification.new do |spec|
31
31
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
32
  spec.require_paths = ['lib']
33
33
 
34
+ spec.add_development_dependency 'pry', '~> 0.14'
35
+ spec.add_development_dependency 'rake', '~> 12.0'
34
36
  spec.add_development_dependency 'rspec', '~> 3.2'
35
- spec.add_development_dependency 'rubocop', '~> 1.18.0'
37
+ spec.add_development_dependency 'rubocop', '~> 1.29.0'
36
38
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_symbolize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-30 00:00:00.000000000 Z
11
+ date: 2022-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: rspec
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -30,14 +58,14 @@ dependencies:
30
58
  requirements:
31
59
  - - "~>"
32
60
  - !ruby/object:Gem::Version
33
- version: 1.18.0
61
+ version: 1.29.0
34
62
  type: :development
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
66
  - - "~>"
39
67
  - !ruby/object:Gem::Version
40
- version: 1.18.0
68
+ version: 1.29.0
41
69
  description: 'simple_symbolize will remove special characters from a String, replacing
42
70
  whitespace with an underscore, down-casing and finally calling the #to_sym String
43
71
  method. Configure this gem to your hearts content!'
@@ -47,13 +75,13 @@ executables: []
47
75
  extensions: []
48
76
  extra_rdoc_files: []
49
77
  files:
50
- - ".drone.yml"
78
+ - ".github/workflows/ruby.yml"
79
+ - ".github/workflows/ruby_gem.yml"
51
80
  - ".gitignore"
52
81
  - ".rspec"
53
82
  - ".rubocop.yml"
54
83
  - ".rubocop_todo.yml"
55
84
  - Gemfile
56
- - Gemfile.lock
57
85
  - LICENSE.txt
58
86
  - README.md
59
87
  - Rakefile
@@ -70,7 +98,7 @@ licenses:
70
98
  metadata:
71
99
  homepage_uri: https://github.com/dvla/simple-symbolize
72
100
  source_code_uri: https://github.com/dvla/simple-symbolize
73
- post_install_message:
101
+ post_install_message:
74
102
  rdoc_options: []
75
103
  require_paths:
76
104
  - lib
@@ -78,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
106
  requirements:
79
107
  - - ">="
80
108
  - !ruby/object:Gem::Version
81
- version: 2.5.0
109
+ version: 2.7.0
82
110
  required_rubygems_version: !ruby/object:Gem::Requirement
83
111
  requirements:
84
112
  - - ">="
@@ -86,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
114
  version: '0'
87
115
  requirements: []
88
116
  rubygems_version: 3.2.15
89
- signing_key:
117
+ signing_key:
90
118
  specification_version: 4
91
119
  summary: Turns Strings into Symbols.
92
120
  test_files: []
data/.drone.yml DELETED
@@ -1,32 +0,0 @@
1
- ---
2
- kind: pipeline
3
- name: default
4
-
5
- platform:
6
- os: linux
7
- arch: amd64
8
-
9
- steps:
10
- - name: unit tests
11
- pull: if-not-exists
12
- image: ecr.tooling.dvla.gov.uk/base-images/qe-ruby:2.7.0-1
13
- commands:
14
- - bundle --jobs 5 --quiet
15
- - bundle exec rspec
16
- when:
17
- event:
18
- - push
19
-
20
- - name: build and deploy
21
- pull: if-not-exists
22
- image: ecr.tooling.dvla.gov.uk/base-images/qe-ruby:2.7.0-1
23
- commands:
24
- - apk add --update git unzip alpine-sdk jq --no-cache
25
- - gem install bundler
26
- - gem install nexus
27
- - bundle --jobs 5 --quiet
28
- - gem build simple_symbolize.gemspec
29
- - gem nexus --url https://nexus.tooling.dvla.gov.uk/repository/gem-private/ simple_symbolize*gem
30
- when:
31
- branch:
32
- - master
data/Gemfile.lock DELETED
@@ -1,55 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- simple_symbolize (1.0.0)
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.0)
51
- rubocop (~> 1.18.0)
52
- simple_symbolize!
53
-
54
- BUNDLED WITH
55
- 2.2.15