dry-inflector 1.1.0 → 1.3.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: 1392cfaa8284e7014f1c22ce07c413a3ce6789164fceabdd0654cf58b4149e85
4
- data.tar.gz: db2dbba0b25cbb788f5b252ea879cccd8b0a3fec460766ac85ff44aaa3fa4dd9
3
+ metadata.gz: f34cbe220bca1cd8cf90491f48c23647dccfb1338408dac83ca08db6e69d8b0d
4
+ data.tar.gz: e5302637e13c7dd9cb38e27d21408c0c6ae0e96b5d95fc93cced8bf4295dba0f
5
5
  SHA512:
6
- metadata.gz: 6aec1c63a80251c78be05c751d8534dd0f1a4e076dc65073833ea1daab8a4f67045fe07322e283b01ef3753501ce0962d149252aa0d2e9cf1d690b9ea7b70bc0
7
- data.tar.gz: 4d6ed796f9fe3e99ce77b93e7ee15e12230cf859912c199d8d5dcef1f3727d42d9f7f187e96399dd9825197da0a0e8329f6566ad748066a7ec7ab7f6ebb6bc5a
6
+ metadata.gz: b4136666509bb43cbf4e941dd942faecf5dad95929f6d58dcad84d243f7bcb531f2525d5b453773575291ea9bdb581148ad5ba81f1592323684526479785cffe
7
+ data.tar.gz: 75d455f4e237b48298303943118e738b9b1b1dcbce4596593fee8a7fd394ba0bf6edc4f6b2e47616cd9ae5c6319fd574d8b4c3ab12ffe91ee00edacf7151ea54
data/CHANGELOG.md CHANGED
@@ -1,103 +1,144 @@
1
- <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
1
+ # Changelog
2
2
 
3
- ## 1.1.0 2024-07-02
3
+ All notable changes to this project will be documented in this file.
4
4
 
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Break Versioning](https://www.taoensso.com/break-versioning).
7
+
8
+ ## [Unreleased]
5
9
 
6
10
  ### Added
7
11
 
8
- - Added "DB" as a default acronym (#49) (@timriley)
12
+ ### Changed
9
13
 
10
- ### Fixed
11
14
 
12
- - Fix incorrect inflections on words separated by spaces, underscores or hyphens (#47) (@parndt)
15
+ ### Deprecated
13
16
 
17
+ ### Removed
14
18
 
15
- [Compare v1.0.0...v1.1.0](https://github.com/dry-rb/dry-inflector/compare/v1.0.0...v1.1.0)
19
+ ### Fixed
16
20
 
17
- ## 1.0.0 2022-11-04
21
+ ### Security
18
22
 
23
+ [Unreleased]: https://github.com/dry-rb/dry-inflector/compare/v1.2.0...main
24
+
25
+ ## [1.3.0] - 2026-01-09
19
26
 
20
27
  ### Changed
21
28
 
22
- - Bumped version to 1.0.0 (@solnic)
29
+ - Require Ruby 3.2 or later. (@alassek)
30
+ - Support characters with diacritics. (@cllns in #51)
31
+ - Improve performance of #singularize. (@sandbergja in #53)
32
+ - Remove redundant regexps for default inflections. (@hmaddocks in #59)
23
33
 
24
- [Compare v0.3.0...v1.0.0](https://github.com/dry-rb/dry-inflector/compare/v0.3.0...v1.0.0)
34
+ ### Fixed
25
35
 
26
- ## 0.3.0 2022-07-12
36
+ - Correctly handle pluralized aconyms in `#underscore`. For example, underscoring "CustomerAPIs" now gives "customer_apis". (@hmaddocks in #54)
37
+ - Correctly singularize "uses" and pluralize "use". (@hmaddocks in #55)
38
+ - Fix singularization of plurals ending in a vowel and "xes", such as "taxes" -> "tax". (@hmaddocks in #56)
39
+ - Fix pluralization of words ending in "ee", such as "fee" -> "fees". (@hmaddocks in #57)
40
+ - Fix singularizing of words like "leaves" and "thieves". (@hmaddocks in #58)
41
+ - Fix pluralization of words ending in "f" that should _not_ have their ending turn into "ves", e.g. "roof"->"roofs" and "chief"->"chiefs". (@hmaddocks in #59)
42
+ - Fix pluralization of "virus" into "viruses". (@hmaddocks in #59)
27
43
 
44
+ ## [1.2.0] - 2025-01-04
45
+
46
+ ### Changed
47
+
48
+ - Bumped required Ruby version to 3.1 (@flash-gordon)
49
+
50
+ [1.2.0]: https://github.com/dry-rb/dry-inflector/compare/v1.1.0...v1.2.0
51
+
52
+ ## [1.1.0] - 2024-07-02
28
53
 
29
54
  ### Added
30
55
 
31
- - Add CSV as default acronym (via #43) (@waiting-for-dev)
56
+ - Added "DB" as a default acronym. (@timriley in #49)
32
57
 
33
- ### Changed
58
+ ### Fixed
34
59
 
35
- - Extra dashes are now omitted when converting to camelcase (via #40) (@postmodern)
60
+ - Fix incorrect inflections on words separated by spaces, underscores or hyphens. (@parndt in #47)
36
61
 
37
- [Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-inflector/compare/v0.2.1...v0.3.0)
62
+ [1.1.0]: https://github.com/dry-rb/dry-inflector/compare/v1.0.0...v1.1.0
38
63
 
39
- ## 0.2.1 2021-06-30
64
+ ## [1.0.0] - 2022-11-04
40
65
 
66
+ ### Changed
41
67
 
42
- ### Added
68
+ - Bumped version to 1.0.0. (@solnic)
43
69
 
44
- - Add default acronyms: API and CSRF (#35) (@jodosha)
70
+ [1.0.0]: https://github.com/dry-rb/dry-inflector/compare/v0.3.0...v1.0.0
45
71
 
46
- ### Fixed
72
+ ## [0.3.0] - 2022-07-12
47
73
 
48
- - Fix singularizing -us suffix (issue #33 via #38) (@cllns)
74
+ ### Added
49
75
 
76
+ - Add CSV as default acronym. (@waiting-for-dev in #43)
50
77
 
51
- [Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-inflector/compare/v0.2.0...v0.2.1)
78
+ ### Changed
79
+
80
+ - Extra dashes are now omitted when converting to camelcase. (@postmodern in #40)
52
81
 
53
- ## 0.2.0 2019-10-13
82
+ [0.3.0]: https://github.com/dry-rb/dry-inflector/compare/v0.2.1...v0.3.0
54
83
 
84
+ ## [0.2.1] - 2021-06-30
55
85
 
56
86
  ### Added
57
87
 
58
- - [Abinoam P. Marques Jr. & Andrii Savchenko] Introduced `Dry::Inflector#camelize_upper` and `Dry::Inflector#camelize_lower`. `Dry::Inflector#camelize` is now an alias for `Dry::Inflector#camelize_upper`. ```ruby inflector.camelize_upper("data_mapper") # => "DataMapper"' inflector.camelize_lower("data_mapper") # => "dataMapper"' ```
88
+ - Add default acronyms: API and CSRF. (@jodosha in #35)
59
89
 
60
90
  ### Fixed
61
91
 
62
- - [ecnal] Fixed singularization rules for words like "alias" or "status"
92
+ - Fix singularizing -us suffix. (@cllns in #38)
63
93
 
94
+ [0.2.1]: https://github.com/dry-rb/dry-inflector/compare/v0.2.0...v0.2.1
64
95
 
65
- [Compare v0.1.2...v0.2.0](https://github.com/dry-rb/dry-inflector/compare/v0.1.2...v0.2.0)
96
+ ## [0.2.0] - 2019-10-13
66
97
 
67
- ## 0.1.2 2018-04-25
98
+ ### Added
68
99
 
100
+ - Introduced `Dry::Inflector#camelize_upper` and `Dry::Inflector#camelize_lower`. `Dry::Inflector#camelize` is now an alias for `Dry::Inflector#camelize_upper`. (Abinoam P. Marques Jr. & Andrii Savchenko)
69
101
 
70
- ### Added
102
+ ```ruby
103
+ inflector.camelize_upper("data_mapper") # => "DataMapper"
104
+ inflector.camelize_lower("data_mapper") # => "dataMapper"
105
+ ```
106
+
107
+ ### Fixed
71
108
 
72
- - [Gustavo Caso & Nikita Shilnikov] Added support for acronyms
109
+ - Fixed singularization rules for words like "alias" or "status". (ecnal)
73
110
 
111
+ [0.2.0]: https://github.com/dry-rb/dry-inflector/compare/v0.1.2...v0.2.0
74
112
 
75
- [Compare v0.1.1...v0.1.2](https://github.com/dry-rb/dry-inflector/compare/v0.1.1...v0.1.2)
113
+ ## [0.1.2] - 2018-04-25
76
114
 
77
- ## 0.1.1 2017-11-18
115
+ ### Added
78
116
 
117
+ - Added support for acronyms. (Gustavo Caso & Nikita Shilnikov)
79
118
 
80
- ### Fixed
119
+ [0.1.2]: https://github.com/dry-rb/dry-inflector/compare/v0.1.1...v0.1.2
81
120
 
82
- - [Luca Guidi & Abinoam P. Marques Jr.] Ensure `Dry::Inflector#ordinalize` to work for all the numbers from 0 to 100
121
+ ## [0.1.1] - 2017-11-18
83
122
 
123
+ ### Fixed
84
124
 
85
- [Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-inflector/compare/v0.1.0...v0.1.1)
125
+ - Ensure `Dry::Inflector#ordinalize` to work for all the numbers from 0 to 100. (Luca Guidi & Abinoam P. Marques Jr.)
86
126
 
87
- ## 0.1.0 2017-11-17
127
+ [0.1.1]: https://github.com/dry-rb/dry-inflector/compare/v0.1.0...v0.1.1
88
128
 
129
+ ## [0.1.0] - 2017-11-17
89
130
 
90
131
  ### Added
91
132
 
92
- - [Luca Guidi] Introduced `Dry::Inflector#pluralize`
93
- - [Luca Guidi] Introduced `Dry::Inflector#singularize`
94
- - [Luca Guidi] Introduced `Dry::Inflector#camelize`
95
- - [Luca Guidi] Introduced `Dry::Inflector#classify`
96
- - [Luca Guidi] Introduced `Dry::Inflector#tableize`
97
- - [Luca Guidi] Introduced `Dry::Inflector#dasherize`
98
- - [Luca Guidi] Introduced `Dry::Inflector#underscore`
99
- - [Luca Guidi] Introduced `Dry::Inflector#demodulize`
100
- - [Luca Guidi] Introduced `Dry::Inflector#humanize`
101
- - [Luca Guidi] Introduced `Dry::Inflector#ordinalize`
102
- - [Abinoam P. Marques Jr.] Introduced `Dry::Inflector#foreign_key`
103
- - [Abinoam P. Marques Jr.] Introduced `Dry::Inflector#constantize`
133
+ - Introduced `Dry::Inflector#pluralize`. (Luca Guidi)
134
+ - Introduced `Dry::Inflector#singularize`. (Luca Guidi)
135
+ - Introduced `Dry::Inflector#camelize`. (Luca Guidi)
136
+ - Introduced `Dry::Inflector#classify`. (Luca Guidi)
137
+ - Introduced `Dry::Inflector#tableize`. (Luca Guidi)
138
+ - Introduced `Dry::Inflector#dasherize`. (Luca Guidi)
139
+ - Introduced `Dry::Inflector#underscore`. (Luca Guidi)
140
+ - Introduced `Dry::Inflector#demodulize`. (Luca Guidi)
141
+ - Introduced `Dry::Inflector#humanize`. (Luca Guidi)
142
+ - Introduced `Dry::Inflector#ordinalize`. (Luca Guidi)
143
+ - Introduced `Dry::Inflector#foreign_key`. (Abinoam P. Marques Jr.)
144
+ - Introduced `Dry::Inflector#constantize`. (Abinoam P. Marques Jr.)
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2023 dry-rb team
3
+ Copyright (c) 2015-2026 Hanakai team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,22 +1,17 @@
1
- <!--- this file is synced from dry-rb/template-gem project -->
2
- [gem]: https://rubygems.org/gems/dry-inflector
1
+ <!--- This file is synced from hanakai-rb/repo-sync -->
2
+
3
+ [rubygem]: https://rubygems.org/gems/dry-inflector
3
4
  [actions]: https://github.com/dry-rb/dry-inflector/actions
4
5
 
5
- # dry-inflector [![Gem Version](https://badge.fury.io/rb/dry-inflector.svg)][gem] [![CI Status](https://github.com/dry-rb/dry-inflector/workflows/ci/badge.svg)][actions]
6
+ # dry-inflector [![Gem Version](https://badge.fury.io/rb/dry-inflector.svg)][rubygem] [![CI Status](https://github.com/dry-rb/dry-inflector/workflows/CI/badge.svg)][actions]
6
7
 
7
8
  ## Links
8
9
 
9
- * [User documentation](https://dry-rb.org/gems/dry-inflector)
10
- * [API documentation](http://rubydoc.info/gems/dry-inflector)
11
- * [Forum](https://discourse.dry-rb.org)
12
-
13
- ## Supported Ruby versions
14
-
15
- This library officially supports the following Ruby versions:
16
-
17
- * MRI `>= 3.0.0`
18
- * jruby `>= 9.4` (not tested on CI)
10
+ - [User documentation](https://dry-rb.org/gems/dry-inflector)
11
+ - [API documentation](http://rubydoc.info/gems/dry-inflector)
12
+ - [Forum](https://discourse.dry-rb.org)
19
13
 
20
14
  ## License
21
15
 
22
16
  See `LICENSE` file.
17
+
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # this file is synced from dry-rb/template-gem project
3
+ # This file is synced from hanakai-rb/repo-sync. To update it, edit repo-sync.yml.
4
4
 
5
5
  lib = File.expand_path("lib", __dir__)
6
6
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -8,8 +8,8 @@ require "dry/inflector/version"
8
8
 
9
9
  Gem::Specification.new do |spec|
10
10
  spec.name = "dry-inflector"
11
- spec.authors = ["Luca Guidi", "Andrii Savchenko", "Abinoam P. Marques Jr."]
12
- spec.email = ["me@lucaguidi.com", "andrey@aejis.eu", "abinoam@gmail.com"]
11
+ spec.authors = ["Hanakai team"]
12
+ spec.email = ["info@hanakai.org"]
13
13
  spec.license = "MIT"
14
14
  spec.version = Dry::Inflector::VERSION.dup
15
15
 
@@ -21,16 +21,18 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = []
22
22
  spec.require_paths = ["lib"]
23
23
 
24
+ spec.extra_rdoc_files = ["README.md", "CHANGELOG.md", "LICENSE"]
25
+
24
26
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
25
27
  spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-inflector/blob/main/CHANGELOG.md"
26
28
  spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-inflector"
27
29
  spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-inflector/issues"
30
+ spec.metadata["funding_uri"] = "https://github.com/sponsors/hanami"
28
31
 
29
- spec.required_ruby_version = ">= 2.7"
30
-
31
- # to update dependencies edit project.yml
32
+ spec.required_ruby_version = ">= 3.2"
32
33
 
33
34
  spec.add_development_dependency "bundler"
34
35
  spec.add_development_dependency "rake"
35
36
  spec.add_development_dependency "rspec"
36
37
  end
38
+
@@ -27,23 +27,20 @@ module Dry
27
27
  inflect.plural(/s\z/i, "s")
28
28
  inflect.plural(/(ax|test)is\z/i, '\1es')
29
29
  inflect.plural(/(.*)us\z/i, '\1uses')
30
- inflect.plural(/(octop|vir|cact)us\z/i, '\1i')
31
- inflect.plural(/(octop|vir)i\z/i, '\1i')
30
+ inflect.plural(/(octop|cact)us\z/i, '\1i')
32
31
  inflect.plural(/(alias|status)\z/i, '\1es')
33
32
  inflect.plural(/(buffal|domin|ech|embarg|her|mosquit|potat|tomat)o\z/i, '\1oes')
34
- inflect.plural(/(?<!b)um\z/i, '\1a')
33
+ inflect.plural(/(?<!b|for)um\z/i, "a")
35
34
  inflect.plural(/([ti])a\z/i, '\1a')
36
35
  inflect.plural(/sis\z/i, "ses")
37
- inflect.plural(/(.*)(?:([^f]))fe*\z/i, '\1\2ves')
38
- inflect.plural(/(hive|proof)\z/i, '\1s') # TODO: proof can be moved in the above regexp
36
+ inflect.plural(/(.*)(?:([^f]))fe?\z/i, '\1\2ves')
37
+ inflect.plural(/(roof|chief|ee|hive|proof)\z/i, '\1s')
39
38
  inflect.plural(/([^aeiouy]|qu)y\z/i, '\1ies')
40
39
  inflect.plural(/(x|ch|ss|sh)\z/i, '\1es')
41
40
  inflect.plural(/(stoma|epo)ch\z/i, '\1chs')
42
41
  inflect.plural(/(matr|vert|ind)(?:ix|ex)\z/i, '\1ices')
43
- inflect.plural(/([m|l])ouse\z/i, '\1ice')
44
- inflect.plural(/([m|l])ice\z/i, '\1ice')
42
+ inflect.plural(/([ml])ouse\z/i, '\1ice')
45
43
  inflect.plural(/^(ox)\z/i, '\1en')
46
- inflect.plural(/^(oxen)\z/i, '\1')
47
44
  inflect.plural(/(quiz)\z/i, '\1zes')
48
45
  inflect.plural(/(.*)non\z/i, '\1na')
49
46
  inflect.plural(/(.*)ma\z/i, '\1mata')
@@ -60,26 +57,30 @@ module Dry
60
57
  '\1\2sis')
61
58
  inflect.singular(/(^analy)(sis|ses)\z/i, '\1sis')
62
59
  inflect.singular(/([^f])ves\z/i, '\1fe')
60
+ inflect.singular(/([lr])ves\z/i, '\1f')
61
+ inflect.singular(/(ea)ves\z/i, '\1f')
62
+ inflect.singular(/(ie)ves\z/i, '\1f')
63
63
  inflect.singular(/(hive)s\z/i, '\1')
64
64
  inflect.singular(/(tive)s\z/i, '\1')
65
- inflect.singular(/([lr])ves\z/i, '\1f')
66
65
  inflect.singular(/([^aeiouy]|qu)ies\z/i, '\1y')
67
66
  inflect.singular(/(s)eries\z/i, '\1eries')
68
67
  inflect.singular(/(m)ovies\z/i, '\1ovie')
69
68
  inflect.singular(/(ss)\z/i, '\1')
70
69
  inflect.singular(/(x|ch|ss|sh)es\z/i, '\1')
71
- inflect.singular(/([m|l])ice\z/i, '\1ouse')
72
- inflect.singular(/(us)(es)?\z/i, '\1')
70
+ inflect.singular(/([ml])ice\z/i, '\1ouse')
71
+ inflect.singular(/(us)(?:es)?\z/i, '\1')
72
+ inflect.singular(/(\b|_|-)([eou])ses\z/i, '\1\2se')
73
73
  inflect.singular(/(o)es\z/i, '\1')
74
74
  inflect.singular(/(shoe)s\z/i, '\1')
75
- inflect.singular(/(cris|ax|test)(is|es)\z/i, '\1is')
76
- inflect.singular(/(octop|vir)(us|i)\z/i, '\1us')
77
- inflect.singular(/(alias|status)(es)?\z/i, '\1')
75
+ inflect.singular(/(cris|ax|test)(?:is|es)\z/i, '\1is')
76
+ inflect.singular(/(octop|vir)(?:us|i)\z/i, '\1us')
77
+ inflect.singular(/(alias|status)(?:es)?\z/i, '\1')
78
78
  inflect.singular(/(ox)en/i, '\1')
79
79
  inflect.singular(/(vert|ind)ices\z/i, '\1ex')
80
80
  inflect.singular(/(matr)ices\z/i, '\1ix')
81
81
  inflect.singular(/(quiz)zes\z/i, '\1')
82
82
  inflect.singular(/(database)s\z/i, '\1')
83
+ inflect.singular(/([a-hj-z][aeiou])xes\z/i, '\1x')
83
84
  end
84
85
 
85
86
  # @since 0.1.0
@@ -95,9 +96,6 @@ module Dry
95
96
  inflect.irregular("foot", "feet")
96
97
  inflect.irregular("tooth", "teeth")
97
98
  inflect.irregular("goose", "geese")
98
-
99
- # FIXME: this is here because I need to fix the "um" regexp
100
- inflect.irregular("forum", "forums")
101
99
  end
102
100
 
103
101
  # @since 0.1.0
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "set"
4
3
  require "dry/inflector/rules"
5
4
  require "dry/inflector/acronyms"
6
5
 
@@ -16,9 +16,12 @@ module Dry
16
16
  # @since 0.1.0
17
17
  # @api private
18
18
  def apply_to(word)
19
- result = word.dup
20
- each { |rule, replacement| break if result.gsub!(rule, replacement) }
21
- result
19
+ matching_rule = @rules.find { |rule, _replacement| rule.match? word }
20
+ if matching_rule
21
+ word.gsub(matching_rule[0], matching_rule[1])
22
+ else
23
+ word
24
+ end.dup
22
25
  end
23
26
 
24
27
  # @since 0.1.0
@@ -26,12 +29,6 @@ module Dry
26
29
  def insert(index, array)
27
30
  @rules.insert(index, array)
28
31
  end
29
-
30
- # @since 0.1.0
31
- # @api private
32
- def each(&blk)
33
- @rules.each(&blk)
34
- end
35
32
  end
36
33
  end
37
34
  end
@@ -3,6 +3,6 @@
3
3
  module Dry
4
4
  class Inflector
5
5
  # @since 0.1.0
6
- VERSION = "1.1.0"
6
+ VERSION = "1.3.0"
7
7
  end
8
8
  end
data/lib/dry/inflector.rb CHANGED
@@ -30,8 +30,8 @@ module Dry
30
30
  # inflections.singular "thieves", "thief" # specify a rule for #singularize
31
31
  # inflections.uncountable "dry-inflector" # add an exception for an uncountable word
32
32
  # end
33
- def initialize(&blk)
34
- @inflections = Inflections.build(&blk)
33
+ def initialize(&)
34
+ @inflections = Inflections.build(&)
35
35
  end
36
36
 
37
37
  # Lower camelize a string
@@ -155,7 +155,7 @@ module Dry
155
155
  result = inflections.humans.apply_to(input)
156
156
  result.delete_suffix!("_id")
157
157
  result.tr!("_", " ")
158
- match = /(\W)/.match(result)
158
+ match = /([^[:alnum:]])/.match(result)
159
159
  separator = match ? match[0] : DEFAULT_SEPARATOR
160
160
  result.split(separator).map.with_index { |word, index|
161
161
  inflections.acronyms.apply_to(word, capitalize: index.zero?)
@@ -283,8 +283,8 @@ module Dry
283
283
  m2 = Regexp.last_match(2)
284
284
  "#{m1 ? "_" : ""}#{m2.downcase}"
285
285
  end
286
- input.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
287
- input.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
286
+ input.gsub!(/([[:upper:][:digit:]]+)([[:upper:]][[:lower:]])(?=[[:lower:]])/, '\1_\2')
287
+ input.gsub!(/([[:lower:][:digit:]])([[:upper:]])/, '\1_\2')
288
288
  input.tr!("-", "_")
289
289
  input.downcase!
290
290
  input
@@ -300,7 +300,7 @@ module Dry
300
300
  def uncountable?(input)
301
301
  input.match?(/\A[[:space:]]*\z/) ||
302
302
  inflections.uncountables.include?(input.downcase) ||
303
- inflections.uncountables.include?(input.split(/_|\b/).last.downcase)
303
+ inflections.uncountables.include?(input.rpartition(/_|\b(?!\z)/).last.downcase)
304
304
  end
305
305
 
306
306
  # @return [String]
@@ -328,8 +328,10 @@ module Dry
328
328
  # @api private
329
329
  def internal_camelize(input, upper)
330
330
  input = input.to_s.dup
331
- input.sub!(/^[a-z\d]*/) { |match| inflections.acronyms.apply_to(match, capitalize: upper) }
332
- input.gsub!(%r{(?:[_-]|(/))([a-z\d]*)}i) do
331
+ input.sub!(/^[[:lower:][:digit:]]*/) do |match|
332
+ inflections.acronyms.apply_to(match, capitalize: upper)
333
+ end
334
+ input.gsub!(%r{(?:[_-]|(/))([[:lower:][:digit:]]*)}i) do
333
335
  m1 = Regexp.last_match(1)
334
336
  m2 = Regexp.last_match(2)
335
337
  "#{m1}#{inflections.acronyms.apply_to(m2)}"
metadata CHANGED
@@ -1,16 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-inflector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - Luca Guidi
8
- - Andrii Savchenko
9
- - Abinoam P. Marques Jr.
10
- autorequire:
7
+ - Hanakai team
11
8
  bindir: bin
12
9
  cert_chain: []
13
- date: 2024-07-02 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
14
11
  dependencies:
15
12
  - !ruby/object:Gem::Dependency
16
13
  name: bundler
@@ -56,12 +53,13 @@ dependencies:
56
53
  version: '0'
57
54
  description: String inflections for dry-rb
58
55
  email:
59
- - me@lucaguidi.com
60
- - andrey@aejis.eu
61
- - abinoam@gmail.com
56
+ - info@hanakai.org
62
57
  executables: []
63
58
  extensions: []
64
- extra_rdoc_files: []
59
+ extra_rdoc_files:
60
+ - CHANGELOG.md
61
+ - LICENSE
62
+ - README.md
65
63
  files:
66
64
  - CHANGELOG.md
67
65
  - LICENSE
@@ -82,7 +80,7 @@ metadata:
82
80
  changelog_uri: https://github.com/dry-rb/dry-inflector/blob/main/CHANGELOG.md
83
81
  source_code_uri: https://github.com/dry-rb/dry-inflector
84
82
  bug_tracker_uri: https://github.com/dry-rb/dry-inflector/issues
85
- post_install_message:
83
+ funding_uri: https://github.com/sponsors/hanami
86
84
  rdoc_options: []
87
85
  require_paths:
88
86
  - lib
@@ -90,15 +88,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
88
  requirements:
91
89
  - - ">="
92
90
  - !ruby/object:Gem::Version
93
- version: '2.7'
91
+ version: '3.2'
94
92
  required_rubygems_version: !ruby/object:Gem::Requirement
95
93
  requirements:
96
94
  - - ">="
97
95
  - !ruby/object:Gem::Version
98
96
  version: '0'
99
97
  requirements: []
100
- rubygems_version: 3.3.27
101
- signing_key:
98
+ rubygems_version: 3.6.9
102
99
  specification_version: 4
103
100
  summary: String inflections for dry-rb
104
101
  test_files: []