dry-inflector 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91485a1eac7b8b76f5a017b6eb04d567b54ae0685fd30ba1e3378450343de3f4
4
- data.tar.gz: ee1e2b939347eda2577ddff9d3d454cc1e3115d2ac298260ea6215d26d5b78ec
3
+ metadata.gz: 6db17e7fbcdc21a6c06f9763e9267d78045ffa2772272cd93abfc22d54ae80a2
4
+ data.tar.gz: bd47f925d3d558782192d3ce47cde9c9fb059163967a975e5d6298cd527e9912
5
5
  SHA512:
6
- metadata.gz: 3d6f9a7fb8249866c30008a11b93715040e5b24106e83e731be32e15dc10c5e8b06d90072d21670e33b44dec41a5ceb075f076dc038d1dfb6424e6185a4ee283
7
- data.tar.gz: e238694af29c1611b54630b9aecfa8b8c1b1096596393f811a9a8430a82d83f71e39e27b72337f504870f4122559ceb8cea7c9a4ffa05b8310dc616b7fa21282
6
+ metadata.gz: b97888420794db32aa69dbad0b168089a4be99d1c68f7411cefeabba1027e42d1f161147af435740e775ee6836dd5a48dad981c0f825b430c77c3e7eeade8091
7
+ data.tar.gz: bf81663b753f1e370d4c8c8b84c844de54a7fce16613e8acbc8a0dcfc7302391f8a92edd51cdfb73fd163215aec9ff65db324d28b7df479a102b3f223ac64573
data/CHANGELOG.md CHANGED
@@ -1,40 +1,55 @@
1
- # dry-inflector
1
+ <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
- Inflector for Ruby
3
+ ## unreleased
4
+
5
+
6
+ ### Fixed
7
+
8
+ - Fix singularizing -us suffix (issue #33 via #38) (@cllns)
9
+
10
+
11
+ [Compare v0.2.0...master](https://github.com/dry-rb/dry-inflector/compare/v0.2.0...master)
12
+
13
+ ## 0.2.0 2019-10-13
4
14
 
5
- ## v0.2.0 - 2019-10-13
6
15
 
7
16
  ### Added
8
17
 
9
- - [Abinoam P. Marques Jr. & Andrii Savchenko] Introduced `Dry::Inflector#upper_camelize` and `Dry::Inflector#lower_camelize`. `Dry::Inflector#camelize` is now an alias for `Dry::Inflector#upper_camelize` and may be deprecated later.
10
- ```ruby
11
- inflector.camelize_upper("data_mapper") # => "DataMapper"
12
- inflector.camelize_lower("data_mapper") # => "dataMapper"
13
- ```
18
+ - [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`.
19
+ - ```ruby
20
+ - inflector.camelize_upper("data_mapper") # => "DataMapper"
21
+ - inflector.camelize_lower("data_mapper") # => "dataMapper"
22
+ - ```
14
23
 
15
24
  ### Fixed
16
25
 
17
26
  - [ecnal] Fixed singularization rules for words like "alias" or "status"
18
27
 
28
+
19
29
  [Compare v0.1.2...v0.2.0](https://github.com/dry-rb/dry-inflector/compare/v0.1.2...v0.2.0)
20
30
 
21
- ## v0.1.2 - 2018-04-25
31
+ ## 0.1.2 2018-04-25
32
+
22
33
 
23
34
  ### Added
24
35
 
25
36
  - [Gustavo Caso & Nikita Shilnikov] Added support for acronyms
26
37
 
38
+
27
39
  [Compare v0.1.1...v0.1.2](https://github.com/dry-rb/dry-inflector/compare/v0.1.1...v0.1.2)
28
40
 
29
- ## v0.1.1 - 2017-11-18
41
+ ## 0.1.1 2017-11-18
42
+
30
43
 
31
44
  ### Fixed
32
45
 
33
46
  - [Luca Guidi & Abinoam P. Marques Jr.] Ensure `Dry::Inflector#ordinalize` to work for all the numbers from 0 to 100
34
47
 
48
+
35
49
  [Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-inflector/compare/v0.1.0...v0.1.1)
36
50
 
37
- ## v0.1.0 - 2017-11-17
51
+ ## 0.1.0 2017-11-17
52
+
38
53
 
39
54
  ### Added
40
55
 
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-2021 dry-rb team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,106 +1,30 @@
1
- [gem]: https://img.shields.io/gem/v/dry-inflector.svg
2
- [travis]: https://travis-ci.org/dry-rb/dry-inflector
3
- [codeclimate]: https://codeclimate.com/github/dry-rb/dry-inflector
1
+ <!--- this file is synced from dry-rb/template-gem project -->
2
+ [gem]: https://rubygems.org/gems/dry-inflector
3
+ [actions]: https://github.com/dry-rb/dry-inflector/actions
4
+ [codacy]: https://www.codacy.com/gh/dry-rb/dry-inflector
4
5
  [chat]: https://dry-rb.zulipchat.com
5
6
  [inchpages]: http://inch-ci.org/github/dry-rb/dry-inflector
6
7
 
7
8
  # dry-inflector [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
8
9
 
9
10
  [![Gem Version](https://badge.fury.io/rb/dry-inflector.svg)][gem]
10
- [![Build Status](https://travis-ci.org/dry-rb/dry-inflector.svg?branch=master)][travis]
11
- [![Code Climate](https://codeclimate.com/github/dry-rb/dry-inflector/badges/gpa.svg)][codeclimate]
12
- [![Test Coverage](https://codeclimate.com/github/dry-rb/dry-inflector/badges/coverage.svg)][codeclimate]
11
+ [![CI Status](https://github.com/dry-rb/dry-inflector/workflows/ci/badge.svg)][actions]
12
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/00339f2fb77840149f999cac6110c8a8)][codacy]
13
+ [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/00339f2fb77840149f999cac6110c8a8)][codacy]
13
14
  [![Inline docs](http://inch-ci.org/github/dry-rb/dry-inflector.svg?branch=master)][inchpages]
14
15
 
15
- dry-inflector is an inflector gem for Ruby.
16
+ ## Links
16
17
 
17
- ## Installation
18
+ * [User documentation](https://dry-rb.org/gems/dry-inflector)
19
+ * [API documentation](http://rubydoc.info/gems/dry-inflector)
18
20
 
19
- Add this line to your application's `Gemfile`:
21
+ ## Supported Ruby versions
20
22
 
21
- ```ruby
22
- gem 'dry-inflector'
23
- ```
23
+ This library officially supports the following Ruby versions:
24
24
 
25
- And then execute:
25
+ * MRI `>= 2.6.0`
26
+ * ~~jruby~~ `>= 9.3` (we are waiting for [2.6 support](https://github.com/jruby/jruby/issues/6161))
26
27
 
27
- ```shell
28
- $ bundle
29
- ```
28
+ ## License
30
29
 
31
- Or install it yourself as:
32
-
33
- ```shell
34
- $ gem install dry-inflector
35
- ```
36
-
37
- ## Usage
38
-
39
- ### Basic usage
40
-
41
- ```ruby
42
- require "dry/inflector"
43
-
44
- inflector = Dry::Inflector.new
45
-
46
- inflector.pluralize("book") # => "books"
47
- inflector.singularize("books") # => "book"
48
-
49
- inflector.camelize("dry/inflector") # => "Dry::Inflector"
50
- inflector.classify("books") # => "Book"
51
- inflector.tableize("Book") # => "books"
52
-
53
- inflector.dasherize("dry_inflector") # => "dry-inflector"
54
- inflector.underscore("dry-inflector") # => "dry_inflector"
55
-
56
- inflector.demodulize("Dry::Inflector") # => "Inflector"
57
-
58
- inflector.humanize("dry_inflector") # => "Dry inflector"
59
- inflector.humanize("author_id") # => "Author"
60
-
61
- inflector.ordinalize(1) # => "1st"
62
- inflector.ordinalize(2) # => "2nd"
63
- inflector.ordinalize(3) # => "3rd"
64
- inflector.ordinalize(10) # => "10th"
65
- inflector.ordinalize(23) # => "23rd"
66
- ```
67
-
68
- ### Custom inflection rules
69
-
70
- ```ruby
71
- require "dry/inflector"
72
-
73
- inflector = Dry::Inflector.new do |inflections|
74
- inflections.plural "virus", "viruses" # specify a rule for #pluralize
75
- inflections.singular "thieves", "thief" # specify a rule for #singularize
76
- inflections.uncountable "dry-inflector" # add an exception for an uncountable word
77
- end
78
-
79
- inflector.pluralize("virus") # => "viruses"
80
- inflector.singularize("thieves") # => "thief"
81
-
82
- inflector.pluralize("dry-inflector") # => "dry-inflector"
83
- ```
84
-
85
- ## Credits
86
-
87
- This gem is the cumulative effort of the Ruby community.
88
- It started with the extlib inflecto originated from [active_support](https://github.com/rails/rails), then dm-core inflector originated from [extlib](https://github.com/datamapper/extlib).
89
- Later, [`inflecto`](https://github.com/mbj/inflecto) was extracted from [dm-core](https://github.com/datamapper/dm-core) as a standalone inflector.
90
- Now, we resurrect `inflecto` and merged [`flexus`](https://github.com/Ptico/flexus), with some inflection rules from [`hanami-utils`](https://github.com/hanami/utils).
91
-
92
- This is `dry-inflector`.
93
-
94
- ## Development
95
-
96
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
97
-
98
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
99
-
100
- ## Contributing
101
-
102
- Bug reports and pull requests are welcome on GitHub at https://github.com/dry-rb/dry-inflector.
103
-
104
- ## Copyright
105
-
106
- Copyright © The Dry, Rails, Merb, Datamapper, Inflecto, Flexus, and Hanami teams - Released under the MIT License
30
+ See `LICENSE` file.
@@ -1,36 +1,36 @@
1
-
2
1
  # frozen_string_literal: true
3
2
 
4
- lib = File.expand_path("../lib", __FILE__)
3
+ # this file is synced from dry-rb/template-gem project
4
+
5
+ lib = File.expand_path("lib", __dir__)
5
6
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
7
  require "dry/inflector/version"
7
8
 
8
9
  Gem::Specification.new do |spec|
9
10
  spec.name = "dry-inflector"
10
- spec.version = Dry::Inflector::VERSION
11
11
  spec.authors = ["Luca Guidi", "Andrii Savchenko", "Abinoam P. Marques Jr."]
12
12
  spec.email = ["me@lucaguidi.com", "andrey@aejis.eu", "abinoam@gmail.com"]
13
-
14
- spec.summary = "DRY Inflector"
15
- spec.description = "String inflections for dry-rb"
16
- spec.homepage = "https://dry-rb.org"
17
13
  spec.license = "MIT"
14
+ spec.version = Dry::Inflector::VERSION.dup
15
+
16
+ spec.summary = "String inflections for dry-rb"
17
+ spec.description = spec.summary
18
+ spec.homepage = "https://dry-rb.org/gems/dry-inflector"
19
+ spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-inflector.gemspec", "lib/**/*"]
20
+ spec.bindir = "bin"
21
+ spec.executables = []
22
+ spec.require_paths = ["lib"]
18
23
 
19
24
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
20
- spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-inflector/blob/master/CHANGELOG.md"
21
- spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-inflector"
22
- spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-inflector/issues"
25
+ spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-inflector/blob/master/CHANGELOG.md"
26
+ spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-inflector"
27
+ spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-inflector/issues"
23
28
 
24
- spec.bindir = "exe"
25
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
- spec.require_paths = ["lib"]
29
+ spec.required_ruby_version = ">= 2.6.0"
27
30
 
28
- spec.files = `git ls-files -- lib/* CHANGELOG.md LICENSE.md README.md dry-inflector.gemspec`.split($INPUT_RECORD_SEPARATOR)
29
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
30
- spec.required_ruby_version = '>= 2.4'
31
+ # to update dependencies edit project.yml
31
32
 
32
33
  spec.add_development_dependency "bundler"
33
- spec.add_development_dependency "rake", "~> 12.0"
34
- spec.add_development_dependency "rspec", "~> 3.7"
35
- spec.add_development_dependency "rubocop", "~> 0.50.0"
34
+ spec.add_development_dependency "rake"
35
+ spec.add_development_dependency "rspec"
36
36
  end
data/lib/dry-inflector.rb CHANGED
@@ -1 +1,3 @@
1
- require 'dry/inflector'
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/inflector"
data/lib/dry/inflector.rb CHANGED
@@ -67,8 +67,7 @@ module Dry
67
67
  internal_camelize(input, true)
68
68
  end
69
69
 
70
- alias :camelize :camelize_upper
71
-
70
+ alias_method :camelize, :camelize_upper
72
71
 
73
72
  # Find a constant with the name specified in the argument string
74
73
  #
@@ -87,7 +86,7 @@ module Dry
87
86
  # inflector.constantize("Module") # => Module
88
87
  # inflector.constantize("Dry::Inflector") # => Dry::Inflector
89
88
  def constantize(input)
90
- Object.const_get(input)
89
+ Object.const_get(input, false)
91
90
  end
92
91
 
93
92
  # Classify a string
@@ -159,7 +158,7 @@ module Dry
159
158
  match = /(?<separator>\W)/.match(result)
160
159
  separator = match ? match[:separator] : DEFAULT_SEPARATOR
161
160
  result.split(separator).map.with_index { |word, index|
162
- inflections.acronyms.apply_to(word, index.zero?)
161
+ inflections.acronyms.apply_to(word, capitalize: index.zero?)
163
162
  }.join(separator)
164
163
  end
165
164
 
@@ -193,7 +192,7 @@ module Dry
193
192
  # inflector.ordinalize(3) # => "3rd"
194
193
  # inflector.ordinalize(10) # => "10th"
195
194
  # inflector.ordinalize(23) # => "23rd"
196
- def ordinalize(number) # rubocop:disable Metrics/MethodLength
195
+ def ordinalize(number)
197
196
  abs_value = number.abs
198
197
 
199
198
  if ORDINALIZE_TH.key?(abs_value % 100)
@@ -224,6 +223,7 @@ module Dry
224
223
  def pluralize(input)
225
224
  input = input.to_s
226
225
  return input if uncountable?(input)
226
+
227
227
  inflections.plurals.apply_to(input)
228
228
  end
229
229
 
@@ -243,6 +243,7 @@ module Dry
243
243
  def singularize(input)
244
244
  input = input.to_s
245
245
  return input if uncountable?(input)
246
+
246
247
  inflections.singulars.apply_to(input)
247
248
  end
248
249
 
@@ -280,7 +281,7 @@ module Dry
280
281
  input.gsub!(inflections.acronyms.regex) do
281
282
  m1 = Regexp.last_match(1)
282
283
  m2 = Regexp.last_match(2)
283
- "#{m1 ? '_' : '' }#{m2.downcase}"
284
+ "#{m1 ? "_" : ""}#{m2.downcase}"
284
285
  end
285
286
  input.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
286
287
  input.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
@@ -305,9 +306,9 @@ module Dry
305
306
  # @since 0.2.0
306
307
  # @api public
307
308
  def to_s
308
- '#<Dry::Inflector>'
309
+ "#<Dry::Inflector>"
309
310
  end
310
- alias inspect to_s
311
+ alias_method :inspect, :to_s
311
312
 
312
313
  private
313
314
 
@@ -325,7 +326,7 @@ module Dry
325
326
  # @api private
326
327
  def internal_camelize(input, upper)
327
328
  input = input.to_s.dup
328
- input.sub!(/^[a-z\d]*/) { |match| inflections.acronyms.apply_to(match, upper) }
329
+ input.sub!(/^[a-z\d]*/) { |match| inflections.acronyms.apply_to(match, capitalize: upper) }
329
330
  input.gsub!(%r{(?:_|(/))([a-z\d]*)}i) do
330
331
  m1 = Regexp.last_match(1)
331
332
  m2 = Regexp.last_match(2)
@@ -334,6 +335,5 @@ module Dry
334
335
  input.gsub!("/", "::")
335
336
  input
336
337
  end
337
-
338
338
  end
339
339
  end
@@ -18,7 +18,7 @@ module Dry
18
18
 
19
19
  # @since 0.1.2
20
20
  # @api private
21
- def apply_to(word, capitalize = true)
21
+ def apply_to(word, capitalize: true)
22
22
  @rules[word.downcase] || (capitalize ? word.capitalize : word)
23
23
  end
24
24
 
@@ -87,7 +87,9 @@ module Dry
87
87
  #
88
88
  # Specifies a new pluralization rule and its replacement.
89
89
  # The rule can either be a string or a regular expression.
90
- # The replacement should always be a string that may include references to the matched data from the rule.
90
+ #
91
+ # The replacement should always be a string that may include
92
+ # references to the matched data from the rule.
91
93
  #
92
94
  # @param rule [String, Regexp] the rule
93
95
  # @param replacement [String] the replacement
@@ -108,7 +110,9 @@ module Dry
108
110
  #
109
111
  # Specifies a new singularization rule and its replacement.
110
112
  # The rule can either be a string or a regular expression.
111
- # The replacement should always be a string that may include references to the matched data from the rule.
113
+ #
114
+ # The replacement should always be a string that may include
115
+ # references to the matched data from the rule.
112
116
  #
113
117
  # @param rule [String, Regexp] the rule
114
118
  # @param replacement [String] the replacement
@@ -127,7 +131,9 @@ module Dry
127
131
 
128
132
  # Add a custom pluralization rule
129
133
  #
130
- # Specifies a new irregular that applies to both pluralization and singularization at the same time.
134
+ # Specifies a new irregular that applies to both pluralization
135
+ # and singularization at the same time.
136
+ #
131
137
  # This can only be used for strings, not regular expressions.
132
138
  # You simply pass the irregular in singular and plural form.
133
139
  #
@@ -194,9 +200,14 @@ module Dry
194
200
 
195
201
  # Add a custom humanize rule
196
202
  #
197
- # Specifies a humanized form of a string by a regular expression rule or by a string mapping.
198
- # When using a regular expression based replacement, the normal humanize formatting is called after the replacement.
199
- # When a string is used, the human form should be specified as desired (example: `"The name"`, not `"the_name"`)
203
+ # Specifies a humanized form of a string by a regular expression rule or
204
+ # by a string mapping.
205
+ #
206
+ # When using a regular expression based replacement, the normal humanize
207
+ # formatting is called after the replacement.
208
+ #
209
+ # When a string is used, the human form should be specified as desired
210
+ # (example: `"The name"`, not `"the_name"`)
200
211
  #
201
212
  # @param rule [String, Regexp] the rule
202
213
  # @param replacement [String] the replacement
@@ -227,7 +238,7 @@ module Dry
227
238
  # @api private
228
239
  def add_irregular(rule, replacement, target)
229
240
  head, *tail = rule.chars.to_a
230
- rule(/(#{head})#{tail.join}\z/i, '\1' + replacement[1..-1], target)
241
+ rule(/(#{head})#{tail.join}\z/i, "\\1#{replacement[1..]}", target)
231
242
  end
232
243
 
233
244
  # Add a new rule
@@ -9,7 +9,6 @@ module Dry
9
9
  # @api private
10
10
  #
11
11
  # rubocop:disable Metrics/AbcSize
12
- # rubocop:disable Metrics/MethodLength
13
12
  module Defaults
14
13
  # @since 0.1.0
15
14
  # @api private
@@ -35,7 +34,7 @@ module Dry
35
34
  inflect.plural(/(?<!b)um\z/i, '\1a')
36
35
  inflect.plural(/([ti])a\z/i, '\1a')
37
36
  inflect.plural(/sis\z/i, "ses")
38
- inflect.plural(/(.*)(?:([^f]))f[e]*\z/i, '\1\2ves')
37
+ inflect.plural(/(.*)(?:([^f]))fe*\z/i, '\1\2ves')
39
38
  inflect.plural(/(hive|proof)\z/i, '\1s') # TODO: proof can be moved in the above regexp
40
39
  inflect.plural(/([^aeiouy]|qu)y\z/i, '\1ies')
41
40
  inflect.plural(/(x|ch|ss|sh)\z/i, '\1es')
@@ -57,7 +56,8 @@ module Dry
57
56
  inflect.singular(/s\z/i, "")
58
57
  inflect.singular(/(n)ews\z/i, '\1ews')
59
58
  inflect.singular(/([ti])a\z/i, '\1um')
60
- inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)\z/i, '\1\2sis')
59
+ inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)\z/i,
60
+ '\1\2sis')
61
61
  inflect.singular(/(^analy)(sis|ses)\z/i, '\1sis')
62
62
  inflect.singular(/([^f])ves\z/i, '\1fe')
63
63
  inflect.singular(/(hive)s\z/i, '\1')
@@ -69,7 +69,7 @@ module Dry
69
69
  inflect.singular(/(ss)\z/i, '\1')
70
70
  inflect.singular(/(x|ch|ss|sh)es\z/i, '\1')
71
71
  inflect.singular(/([m|l])ice\z/i, '\1ouse')
72
- inflect.singular(/(bus)(es)?\z/i, '\1')
72
+ inflect.singular(/(us)(es)?\z/i, '\1')
73
73
  inflect.singular(/(o)es\z/i, '\1')
74
74
  inflect.singular(/(shoe)s\z/i, '\1')
75
75
  inflect.singular(/(cris|ax|test)(is|es)\z/i, '\1is')
@@ -87,30 +87,34 @@ module Dry
87
87
  def self.irregular(inflect)
88
88
  inflect.irregular("person", "people")
89
89
  inflect.irregular("man", "men")
90
- inflect.irregular("human", "humans") # NOTE: this is here only to override the previous rule
90
+
91
+ # NOTE: this is here only to override the previous rule
92
+ inflect.irregular("human", "humans")
91
93
  inflect.irregular("child", "children")
92
94
  inflect.irregular("sex", "sexes")
93
95
  inflect.irregular("foot", "feet")
94
96
  inflect.irregular("tooth", "teeth")
95
97
  inflect.irregular("goose", "geese")
96
- inflect.irregular("forum", "forums") # FIXME: this is here because I need to fix the "um" regexp
98
+
99
+ # FIXME: this is here because I need to fix the "um" regexp
100
+ inflect.irregular("forum", "forums")
97
101
  end
98
102
 
99
103
  # @since 0.1.0
100
104
  # @api private
101
105
  def self.uncountable(inflect)
102
- inflect.uncountable(%w[hovercraft moose deer milk rain Swiss grass equipment information rice money species series fish sheep jeans])
106
+ inflect.uncountable(%w[hovercraft moose deer milk rain Swiss grass equipment information
107
+ rice money species series fish sheep jeans])
103
108
  end
104
109
 
105
110
  # @since 0.1.2
106
111
  # @api private
107
112
  def self.acronyms(inflect)
108
- inflect.acronym(*%w[JSON HTTP OpenSSL HMAC])
113
+ inflect.acronym(*%w[JSON HTTP OpenSSL HMAC CSRF API])
109
114
  end
110
115
 
111
116
  private_class_method :plural, :singular, :irregular, :uncountable, :acronyms
112
117
  end
113
- # rubocop:enable Metrics/MethodLength
114
118
  # rubocop:enable Metrics/AbcSize
115
119
  end
116
120
  end
@@ -3,6 +3,6 @@
3
3
  module Dry
4
4
  class Inflector
5
5
  # @since 0.1.0
6
- VERSION = "0.2.0"
6
+ VERSION = "0.2.1"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-inflector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  - Andrii Savchenko
9
9
  - Abinoam P. Marques Jr.
10
10
  autorequire:
11
- bindir: exe
11
+ bindir: bin
12
12
  cert_chain: []
13
- date: 2019-10-13 00:00:00.000000000 Z
13
+ date: 2021-06-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -30,44 +30,30 @@ dependencies:
30
30
  name: rake
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - "~>"
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: '12.0'
35
+ version: '0'
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - "~>"
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: '12.0'
42
+ version: '0'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: rspec
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '3.7'
50
- type: :development
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - "~>"
55
- - !ruby/object:Gem::Version
56
- version: '3.7'
57
- - !ruby/object:Gem::Dependency
58
- name: rubocop
59
- requirement: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - "~>"
47
+ - - ">="
62
48
  - !ruby/object:Gem::Version
63
- version: 0.50.0
49
+ version: '0'
64
50
  type: :development
65
51
  prerelease: false
66
52
  version_requirements: !ruby/object:Gem::Requirement
67
53
  requirements:
68
- - - "~>"
54
+ - - ">="
69
55
  - !ruby/object:Gem::Version
70
- version: 0.50.0
56
+ version: '0'
71
57
  description: String inflections for dry-rb
72
58
  email:
73
59
  - me@lucaguidi.com
@@ -78,7 +64,7 @@ extensions: []
78
64
  extra_rdoc_files: []
79
65
  files:
80
66
  - CHANGELOG.md
81
- - LICENSE.md
67
+ - LICENSE
82
68
  - README.md
83
69
  - dry-inflector.gemspec
84
70
  - lib/dry-inflector.rb
@@ -88,7 +74,7 @@ files:
88
74
  - lib/dry/inflector/inflections/defaults.rb
89
75
  - lib/dry/inflector/rules.rb
90
76
  - lib/dry/inflector/version.rb
91
- homepage: https://dry-rb.org
77
+ homepage: https://dry-rb.org/gems/dry-inflector
92
78
  licenses:
93
79
  - MIT
94
80
  metadata:
@@ -104,15 +90,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
90
  requirements:
105
91
  - - ">="
106
92
  - !ruby/object:Gem::Version
107
- version: '2.4'
93
+ version: 2.6.0
108
94
  required_rubygems_version: !ruby/object:Gem::Requirement
109
95
  requirements:
110
96
  - - ">="
111
97
  - !ruby/object:Gem::Version
112
98
  version: '0'
113
99
  requirements: []
114
- rubygems_version: 3.0.3
100
+ rubygems_version: 3.1.6
115
101
  signing_key:
116
102
  specification_version: 4
117
- summary: DRY Inflector
103
+ summary: String inflections for dry-rb
118
104
  test_files: []
data/LICENSE.md DELETED
@@ -1,22 +0,0 @@
1
- Copyright © The Dry, Rails, Merb, Datamapper, Inflecto, Flexus, and Hanami teams
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.