simple_symbolize 5.0.0 → 6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1da0a7a552ad0fd3c5901bbf7141a0cb03437b96379df5506690d65f1424592b
4
- data.tar.gz: 4725b7b1c52b62649b683369856d9eb37d66b9569db9e283acfaa426fdad4be9
3
+ metadata.gz: a61b74fb95d9b3e3e76a3256bc88cb1f7b35c684ba6c1ea18fb1eeaee09ace87
4
+ data.tar.gz: e4a37ab07e24568f3434d8725e3fcc63d20b5d2d06e429842bcbfd4109709d7f
5
5
  SHA512:
6
- metadata.gz: ebaeea1ca71fb7532b98e6b9c020ac35432e0c17eeedb908081f6e7dc0656e38471a9bf98f37fee1f87cafb1e4d185d49d51ad6c4f4b7c89b79e985a0b127c3a
7
- data.tar.gz: 5cc276021f11076c11f3ac704388b67e37451acdc0d0eab68bc11f6fcf007c94d321e6d5acf253e5ff7382e943008122a4f9ca835bf709db05b125ad34da7fd6
6
+ metadata.gz: 572ffe34944c55a5f805b05ede3af67c41789f4f2218e4d0a79a242b9d3599dc60a7e9e656590f18ba3fc2215fc4511d33445f3309d3e482cf52c89d8768010e
7
+ data.tar.gz: 48cdddc6da798147b3104bb94f6fa88f2d7752120d7eec66aaca43edfc4c46fcc4728117ec81944c3d592cab210e63f179037b8c3a913a98bad3d2f5b54b18a4
@@ -18,7 +18,7 @@ jobs:
18
18
  runs-on: ubuntu-latest
19
19
  strategy:
20
20
  matrix:
21
- ruby-version: [ '3.2', '3.3', '3.4' ]
21
+ ruby-version: [ '3.4', '4.0' ]
22
22
 
23
23
  steps:
24
24
  - uses: actions/checkout@v4
@@ -9,7 +9,7 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
  strategy:
11
11
  matrix:
12
- ruby-version: [ '3.2', '3.3', '3.4' ]
12
+ ruby-version: [ '3.4', '4.0' ]
13
13
 
14
14
  steps:
15
15
  - uses: actions/checkout@v4
@@ -32,10 +32,10 @@ jobs:
32
32
 
33
33
  steps:
34
34
  - uses: actions/checkout@v4
35
- - name: Set up Ruby 3.4
35
+ - name: Set up Ruby 4.0
36
36
  uses: ruby/setup-ruby@v1
37
37
  with:
38
- ruby-version: 3.4
38
+ ruby-version: 4.0
39
39
  bundler-cache: true
40
40
 
41
41
  - name: Publish to RubyGems
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
3
  SuggestExtensions: false
4
- TargetRubyVersion: 3.2
4
+ TargetRubyVersion: 3.4
5
5
 
6
6
  Gemspec/DevelopmentDependencies:
7
7
  EnforcedStyle: gemspec
@@ -15,4 +15,10 @@ Metrics/BlockLength:
15
15
  - spec/**/*.rb
16
16
 
17
17
  Style/MixinUsage:
18
- Enabled: false
18
+ Enabled: false
19
+
20
+ Metrics/AbcSize:
21
+ Max: 20
22
+
23
+ Metrics/MethodLength:
24
+ Max: 20
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.4.5
1
+ ruby-4.0.5
data/Gemfile CHANGED
@@ -5,7 +5,9 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in simple_symbolize.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rake', '~> 13.3'
8
+ gem 'rake', '~> 13.4'
9
9
  gem 'rspec', '~> 3.13'
10
- gem 'rubocop', '~> 1.80'
10
+ gem 'rubocop', '~> 1.88'
11
11
  gem 'simplecov', '~> 0.22'
12
+
13
+ gem 'irb', '~> 1.18'
data/README.md CHANGED
@@ -111,6 +111,22 @@ end
111
111
 
112
112
  ## Updates!
113
113
 
114
+ ### V6.0.0
115
+
116
+ #### Dropped support for Ruby < 3.4
117
+
118
+ Ruby 3.2 reached EOL in 2026, and Ruby 3.3 will reach EOL in 2027.
119
+ As such this gem no longer supports versions older than 3.4.
120
+
121
+ #### Inline configuration
122
+
123
+ You can now prevent chars being removed inline:
124
+
125
+ ```ruby
126
+ SimpleSymbolize.symbolize('Hello World!', strip_chars: false)
127
+ # => :hello_world!
128
+ ```
129
+
114
130
  ### V5
115
131
 
116
132
  #### Dropped support for Ruby < 3.2
@@ -10,26 +10,26 @@ module SimpleSymbolize
10
10
  module String
11
11
  # @example Symbolize a string using the String object method
12
12
  # "hello world!".symbolize #=> :hello_world
13
- def simple_symbolize
14
- SimpleSymbolize.symbolize(self)
13
+ def simple_symbolize(strip_chars: true)
14
+ SimpleSymbolize.symbolize(self, strip_chars:)
15
15
  end
16
16
 
17
17
  # @example Turns a String into a camelCase Symbol
18
18
  # "Hello World".simple_camelize => :helloWorld
19
- def simple_camelize
20
- SimpleSymbolize.camelize(self)
19
+ def simple_camelize(strip_chars: true)
20
+ SimpleSymbolize.camelize(self, strip_chars:)
21
21
  end
22
22
 
23
23
  # @example Symbolizes a String then calls #to_s
24
24
  # "helloWorld".simple_elementize => 'hello_word'
25
- def simple_elementize
26
- SimpleSymbolize.elementize(self)
25
+ def simple_elementize(strip_chars: true)
26
+ SimpleSymbolize.elementize(self, strip_chars:)
27
27
  end
28
28
 
29
29
  # @example Turns a String into it's snake_case equivalent
30
30
  # "helloWorld".simple_snakeize => 'hello_word'
31
- def simple_snakeize
32
- SimpleSymbolize.snakeize(self)
31
+ def simple_snakeize(strip_chars: true)
32
+ SimpleSymbolize.snakeize(self, strip_chars:)
33
33
  end
34
34
  end
35
35
  end
@@ -10,26 +10,26 @@ module SimpleSymbolize
10
10
  module Symbol
11
11
  # @example Symbolize a string using the String object method
12
12
  # :hello_world!.symbolize #=> :hello_world
13
- def simple_symbolize
14
- SimpleSymbolize.symbolize(self)
13
+ def simple_symbolize(strip_chars: true)
14
+ SimpleSymbolize.symbolize(self, strip_chars:)
15
15
  end
16
16
 
17
17
  # @example Turns a String into a camelCase Symbol
18
18
  # :hello_world.simple_camelize => :helloWorld
19
- def simple_camelize
20
- SimpleSymbolize.camelize(self)
19
+ def simple_camelize(strip_chars: true)
20
+ SimpleSymbolize.camelize(self, strip_chars:)
21
21
  end
22
22
 
23
23
  # @example Symbolizes a String then calls #to_s
24
24
  # :helloWorld!.simple_elementize => 'hello_word'
25
- def simple_elementize
26
- SimpleSymbolize.elementize(self)
25
+ def simple_elementize(strip_chars: true)
26
+ SimpleSymbolize.elementize(self, strip_chars:)
27
27
  end
28
28
 
29
29
  # @example Turns a String into it's snake_case equivalent
30
30
  # :helloWorld.simple_snakeize => :hello_word
31
- def simple_snakeize
32
- SimpleSymbolize.snakeize(self)
31
+ def simple_snakeize(strip_chars: true)
32
+ SimpleSymbolize.snakeize(self, strip_chars:)
33
33
  end
34
34
  end
35
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleSymbolize
4
- VERSION = '5.0.0'
4
+ VERSION = '6.0.0'
5
5
  end
@@ -31,17 +31,20 @@ module SimpleSymbolize
31
31
  #
32
32
  # @example Symbolize a string using the symbolize method
33
33
  # SimpleSymbolize.symbolize("hello world!") #=> :hello_world
34
- def self.symbolize(obj)
34
+ def self.symbolize(obj, strip_chars: true)
35
35
  return obj unless valid_input?(obj)
36
36
 
37
37
  obj = if SimpleSymbolize.translations.handle_camel_case
38
- snakeize(obj)
38
+ snakeize(obj, strip_chars:)
39
39
  else
40
40
  obj.to_s
41
41
  .downcase
42
42
  .gsub(Regexp.union(SimpleSymbolize.translations.underscore), '_')
43
- .gsub(Regexp.union(SimpleSymbolize.translations.remove), '')
43
+ .then do |str|
44
+ strip_chars?(strip_chars) ? str.gsub(Regexp.union(SimpleSymbolize.translations.remove), '') : str
45
+ end
44
46
  end
47
+
45
48
  obj.to_sym
46
49
  end
47
50
 
@@ -51,10 +54,10 @@ module SimpleSymbolize
51
54
  #
52
55
  # @example Elementize a string using the elementize method
53
56
  # SimpleSymbolize.elementize("hello world!") #=> "helloWorld"
54
- def self.elementize(obj)
57
+ def self.elementize(obj, strip_chars: true)
55
58
  return obj unless valid_input?(obj)
56
59
 
57
- symbolize(obj).to_s
60
+ symbolize(obj, strip_chars:).to_s
58
61
  end
59
62
 
60
63
  # Turns a String object into a camelCase Symbol.
@@ -63,10 +66,10 @@ module SimpleSymbolize
63
66
  #
64
67
  # @example Camelize a string using the camelize method
65
68
  # SimpleSymbolize.camelize("hello world!") #=> :helloWorld
66
- def self.camelize(obj)
69
+ def self.camelize(obj, strip_chars: true)
67
70
  return obj unless valid_input?(obj)
68
71
 
69
- first, *rest = elementize(obj).split('_')
72
+ first, *rest = elementize(obj, strip_chars:).split('_')
70
73
  return obj if first.nil?
71
74
 
72
75
  assemble_came_case_string(first, rest)
@@ -78,12 +81,12 @@ module SimpleSymbolize
78
81
  #
79
82
  # @example Snakeize an object using the snakeize method
80
83
  # SimpleSymbolize.snakeize('Hello World!') #=> :hello_world
81
- def self.snakeize(obj)
84
+ def self.snakeize(obj, strip_chars: true)
82
85
  return obj unless valid_input?(obj)
83
86
 
84
87
  obj.to_s
85
88
  .gsub(Regexp.union(SimpleSymbolize.translations.underscore), '_')
86
- .gsub(Regexp.union(SimpleSymbolize.translations.remove), '')
89
+ .then { |str| strip_chars?(strip_chars) ? str.gsub(Regexp.union(SimpleSymbolize.translations.remove), '') : str }
87
90
  .gsub(/([a-z\d])([A-Z])/, '\1_\2')
88
91
  .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
89
92
  .downcase
@@ -125,5 +128,9 @@ module SimpleSymbolize
125
128
  word = first + rest.join
126
129
  word.to_sym
127
130
  end
131
+
132
+ def strip_chars?(obj)
133
+ obj.to_s.downcase == 'true'
134
+ end
128
135
  end
129
136
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.homepage = 'https://github.com/dvla/simple-symbolize'
17
17
 
18
18
  spec.license = 'MIT'
19
- spec.required_ruby_version = Gem::Requirement.new('>= 3.2')
19
+ spec.required_ruby_version = Gem::Requirement.new('>= 3.4')
20
20
 
21
21
  spec.metadata['homepage_uri'] = spec.homepage
22
22
  spec.metadata['source_code_uri'] = spec.homepage
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_symbolize
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexo
@@ -50,14 +50,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '3.2'
53
+ version: '3.4'
54
54
  required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  requirements:
56
56
  - - ">="
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  requirements: []
60
- rubygems_version: 3.6.9
60
+ rubygems_version: 4.0.10
61
61
  specification_version: 4
62
62
  summary: Turns Strings into Symbols.
63
63
  test_files: []