dry-inflector 1.2.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 +4 -4
- data/CHANGELOG.md +82 -50
- data/LICENSE +1 -1
- data/README.md +8 -13
- data/dry-inflector.gemspec +17 -11
- data/lib/dry/inflector/inflections/defaults.rb +15 -17
- data/lib/dry/inflector/inflections.rb +0 -1
- data/lib/dry/inflector/rules.rb +6 -9
- data/lib/dry/inflector/version.rb +1 -1
- data/lib/dry/inflector.rb +8 -6
- metadata +54 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f34cbe220bca1cd8cf90491f48c23647dccfb1338408dac83ca08db6e69d8b0d
|
|
4
|
+
data.tar.gz: e5302637e13c7dd9cb38e27d21408c0c6ae0e96b5d95fc93cced8bf4295dba0f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b4136666509bb43cbf4e941dd942faecf5dad95929f6d58dcad84d243f7bcb531f2525d5b453773575291ea9bdb581148ad5ba81f1592323684526479785cffe
|
|
7
|
+
data.tar.gz: 75d455f4e237b48298303943118e738b9b1b1dcbce4596593fee8a7fd394ba0bf6edc4f6b2e47616cd9ae5c6319fd574d8b4c3ab12ffe91ee00edacf7151ea54
|
data/CHANGELOG.md
CHANGED
|
@@ -1,112 +1,144 @@
|
|
|
1
|
-
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
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]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
5
11
|
|
|
6
12
|
### Changed
|
|
7
13
|
|
|
8
|
-
- Bumped required Ruby version to 3.1 (@flash-gordon)
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
### Deprecated
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
### Removed
|
|
13
18
|
|
|
19
|
+
### Fixed
|
|
14
20
|
|
|
15
|
-
###
|
|
21
|
+
### Security
|
|
16
22
|
|
|
17
|
-
-
|
|
23
|
+
[Unreleased]: https://github.com/dry-rb/dry-inflector/compare/v1.2.0...main
|
|
18
24
|
|
|
19
|
-
|
|
25
|
+
## [1.3.0] - 2026-01-09
|
|
20
26
|
|
|
21
|
-
|
|
27
|
+
### Changed
|
|
22
28
|
|
|
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
|
-
|
|
34
|
+
### Fixed
|
|
25
35
|
|
|
26
|
-
|
|
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
|
|
28
45
|
|
|
29
46
|
### Changed
|
|
30
47
|
|
|
31
|
-
- Bumped version to 1
|
|
32
|
-
|
|
33
|
-
[Compare v0.3.0...v1.0.0](https://github.com/dry-rb/dry-inflector/compare/v0.3.0...v1.0.0)
|
|
48
|
+
- Bumped required Ruby version to 3.1 (@flash-gordon)
|
|
34
49
|
|
|
35
|
-
|
|
50
|
+
[1.2.0]: https://github.com/dry-rb/dry-inflector/compare/v1.1.0...v1.2.0
|
|
36
51
|
|
|
52
|
+
## [1.1.0] - 2024-07-02
|
|
37
53
|
|
|
38
54
|
### Added
|
|
39
55
|
|
|
40
|
-
-
|
|
56
|
+
- Added "DB" as a default acronym. (@timriley in #49)
|
|
41
57
|
|
|
42
|
-
###
|
|
58
|
+
### Fixed
|
|
43
59
|
|
|
44
|
-
-
|
|
60
|
+
- Fix incorrect inflections on words separated by spaces, underscores or hyphens. (@parndt in #47)
|
|
45
61
|
|
|
46
|
-
[
|
|
62
|
+
[1.1.0]: https://github.com/dry-rb/dry-inflector/compare/v1.0.0...v1.1.0
|
|
47
63
|
|
|
48
|
-
## 0.
|
|
64
|
+
## [1.0.0] - 2022-11-04
|
|
49
65
|
|
|
66
|
+
### Changed
|
|
50
67
|
|
|
51
|
-
|
|
68
|
+
- Bumped version to 1.0.0. (@solnic)
|
|
52
69
|
|
|
53
|
-
|
|
70
|
+
[1.0.0]: https://github.com/dry-rb/dry-inflector/compare/v0.3.0...v1.0.0
|
|
54
71
|
|
|
55
|
-
|
|
72
|
+
## [0.3.0] - 2022-07-12
|
|
56
73
|
|
|
57
|
-
|
|
74
|
+
### Added
|
|
58
75
|
|
|
76
|
+
- Add CSV as default acronym. (@waiting-for-dev in #43)
|
|
59
77
|
|
|
60
|
-
|
|
78
|
+
### Changed
|
|
79
|
+
|
|
80
|
+
- Extra dashes are now omitted when converting to camelcase. (@postmodern in #40)
|
|
61
81
|
|
|
62
|
-
|
|
82
|
+
[0.3.0]: https://github.com/dry-rb/dry-inflector/compare/v0.2.1...v0.3.0
|
|
63
83
|
|
|
84
|
+
## [0.2.1] - 2021-06-30
|
|
64
85
|
|
|
65
86
|
### Added
|
|
66
87
|
|
|
67
|
-
-
|
|
88
|
+
- Add default acronyms: API and CSRF. (@jodosha in #35)
|
|
68
89
|
|
|
69
90
|
### Fixed
|
|
70
91
|
|
|
71
|
-
-
|
|
92
|
+
- Fix singularizing -us suffix. (@cllns in #38)
|
|
72
93
|
|
|
94
|
+
[0.2.1]: https://github.com/dry-rb/dry-inflector/compare/v0.2.0...v0.2.1
|
|
73
95
|
|
|
74
|
-
[
|
|
96
|
+
## [0.2.0] - 2019-10-13
|
|
75
97
|
|
|
76
|
-
|
|
98
|
+
### Added
|
|
77
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)
|
|
78
101
|
|
|
79
|
-
|
|
102
|
+
```ruby
|
|
103
|
+
inflector.camelize_upper("data_mapper") # => "DataMapper"
|
|
104
|
+
inflector.camelize_lower("data_mapper") # => "dataMapper"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Fixed
|
|
80
108
|
|
|
81
|
-
-
|
|
109
|
+
- Fixed singularization rules for words like "alias" or "status". (ecnal)
|
|
82
110
|
|
|
111
|
+
[0.2.0]: https://github.com/dry-rb/dry-inflector/compare/v0.1.2...v0.2.0
|
|
83
112
|
|
|
84
|
-
[
|
|
113
|
+
## [0.1.2] - 2018-04-25
|
|
85
114
|
|
|
86
|
-
|
|
115
|
+
### Added
|
|
87
116
|
|
|
117
|
+
- Added support for acronyms. (Gustavo Caso & Nikita Shilnikov)
|
|
88
118
|
|
|
89
|
-
|
|
119
|
+
[0.1.2]: https://github.com/dry-rb/dry-inflector/compare/v0.1.1...v0.1.2
|
|
90
120
|
|
|
91
|
-
|
|
121
|
+
## [0.1.1] - 2017-11-18
|
|
92
122
|
|
|
123
|
+
### Fixed
|
|
93
124
|
|
|
94
|
-
|
|
125
|
+
- Ensure `Dry::Inflector#ordinalize` to work for all the numbers from 0 to 100. (Luca Guidi & Abinoam P. Marques Jr.)
|
|
95
126
|
|
|
96
|
-
|
|
127
|
+
[0.1.1]: https://github.com/dry-rb/dry-inflector/compare/v0.1.0...v0.1.1
|
|
97
128
|
|
|
129
|
+
## [0.1.0] - 2017-11-17
|
|
98
130
|
|
|
99
131
|
### Added
|
|
100
132
|
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
-
|
|
105
|
-
-
|
|
106
|
-
-
|
|
107
|
-
-
|
|
108
|
-
-
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
-
|
|
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
data/README.md
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
<!---
|
|
2
|
-
|
|
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 [][
|
|
6
|
+
# dry-inflector [][rubygem] [][actions]
|
|
6
7
|
|
|
7
8
|
## Links
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
|
data/dry-inflector.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
#
|
|
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,25 +8,31 @@ require "dry/inflector/version"
|
|
|
8
8
|
|
|
9
9
|
Gem::Specification.new do |spec|
|
|
10
10
|
spec.name = "dry-inflector"
|
|
11
|
-
spec.authors = ["
|
|
12
|
-
spec.email = ["
|
|
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
|
|
|
16
16
|
spec.summary = "String inflections for dry-rb"
|
|
17
17
|
spec.description = spec.summary
|
|
18
18
|
spec.homepage = "https://dry-rb.org/gems/dry-inflector"
|
|
19
|
-
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-inflector.gemspec",
|
|
20
|
-
"lib/**/*"]
|
|
19
|
+
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-inflector.gemspec", "lib/**/*"]
|
|
21
20
|
spec.bindir = "bin"
|
|
22
21
|
spec.executables = []
|
|
23
22
|
spec.require_paths = ["lib"]
|
|
24
23
|
|
|
25
|
-
spec.
|
|
26
|
-
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-inflector/blob/main/CHANGELOG.md"
|
|
27
|
-
spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-inflector"
|
|
28
|
-
spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-inflector/issues"
|
|
29
|
-
spec.metadata["rubygems_mfa_required"] = "true"
|
|
24
|
+
spec.extra_rdoc_files = ["README.md", "CHANGELOG.md", "LICENSE"]
|
|
30
25
|
|
|
31
|
-
spec.
|
|
26
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
27
|
+
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-inflector/blob/main/CHANGELOG.md"
|
|
28
|
+
spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-inflector"
|
|
29
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-inflector/issues"
|
|
30
|
+
spec.metadata["funding_uri"] = "https://github.com/sponsors/hanami"
|
|
31
|
+
|
|
32
|
+
spec.required_ruby_version = ">= 3.2"
|
|
33
|
+
|
|
34
|
+
spec.add_development_dependency "bundler"
|
|
35
|
+
spec.add_development_dependency "rake"
|
|
36
|
+
spec.add_development_dependency "rspec"
|
|
32
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|
|
|
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,
|
|
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
|
|
38
|
-
inflect.plural(/(hive|proof)\z/i, '\1s')
|
|
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(/([
|
|
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(/([
|
|
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
|
data/lib/dry/inflector/rules.rb
CHANGED
|
@@ -16,9 +16,12 @@ module Dry
|
|
|
16
16
|
# @since 0.1.0
|
|
17
17
|
# @api private
|
|
18
18
|
def apply_to(word)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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(&)
|
|
33
|
-
@rules.each(&)
|
|
34
|
-
end
|
|
35
32
|
end
|
|
36
33
|
end
|
|
37
34
|
end
|
data/lib/dry/inflector.rb
CHANGED
|
@@ -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 = /(
|
|
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!(/([
|
|
287
|
-
input.gsub!(/([
|
|
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.
|
|
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!(/^[
|
|
332
|
-
|
|
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,25 +1,65 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dry-inflector
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
8
|
-
- Andrii Savchenko
|
|
9
|
-
- Abinoam P. Marques Jr.
|
|
10
|
-
autorequire:
|
|
7
|
+
- Hanakai team
|
|
11
8
|
bindir: bin
|
|
12
9
|
cert_chain: []
|
|
13
|
-
date:
|
|
14
|
-
dependencies:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: bundler
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :development
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: rake
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: rspec
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
15
54
|
description: String inflections for dry-rb
|
|
16
55
|
email:
|
|
17
|
-
-
|
|
18
|
-
- andrey@aejis.eu
|
|
19
|
-
- abinoam@gmail.com
|
|
56
|
+
- info@hanakai.org
|
|
20
57
|
executables: []
|
|
21
58
|
extensions: []
|
|
22
|
-
extra_rdoc_files:
|
|
59
|
+
extra_rdoc_files:
|
|
60
|
+
- CHANGELOG.md
|
|
61
|
+
- LICENSE
|
|
62
|
+
- README.md
|
|
23
63
|
files:
|
|
24
64
|
- CHANGELOG.md
|
|
25
65
|
- LICENSE
|
|
@@ -40,8 +80,7 @@ metadata:
|
|
|
40
80
|
changelog_uri: https://github.com/dry-rb/dry-inflector/blob/main/CHANGELOG.md
|
|
41
81
|
source_code_uri: https://github.com/dry-rb/dry-inflector
|
|
42
82
|
bug_tracker_uri: https://github.com/dry-rb/dry-inflector/issues
|
|
43
|
-
|
|
44
|
-
post_install_message:
|
|
83
|
+
funding_uri: https://github.com/sponsors/hanami
|
|
45
84
|
rdoc_options: []
|
|
46
85
|
require_paths:
|
|
47
86
|
- lib
|
|
@@ -49,15 +88,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
49
88
|
requirements:
|
|
50
89
|
- - ">="
|
|
51
90
|
- !ruby/object:Gem::Version
|
|
52
|
-
version: '3.
|
|
91
|
+
version: '3.2'
|
|
53
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
93
|
requirements:
|
|
55
94
|
- - ">="
|
|
56
95
|
- !ruby/object:Gem::Version
|
|
57
96
|
version: '0'
|
|
58
97
|
requirements: []
|
|
59
|
-
rubygems_version: 3.
|
|
60
|
-
signing_key:
|
|
98
|
+
rubygems_version: 3.6.9
|
|
61
99
|
specification_version: 4
|
|
62
100
|
summary: String inflections for dry-rb
|
|
63
101
|
test_files: []
|