dry-inflector 0.2.1 → 1.0.0

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: 6db17e7fbcdc21a6c06f9763e9267d78045ffa2772272cd93abfc22d54ae80a2
4
- data.tar.gz: bd47f925d3d558782192d3ce47cde9c9fb059163967a975e5d6298cd527e9912
3
+ metadata.gz: 3a76b37b2022509e4cfedeec51993ceb9b86a6f1958cdd2e622c96c3e58bde25
4
+ data.tar.gz: c84af6c67bd4719d933c7e6eb7844fe8730486368a6202a2999e0d526bc71837
5
5
  SHA512:
6
- metadata.gz: b97888420794db32aa69dbad0b168089a4be99d1c68f7411cefeabba1027e42d1f161147af435740e775ee6836dd5a48dad981c0f825b430c77c3e7eeade8091
7
- data.tar.gz: bf81663b753f1e370d4c8c8b84c844de54a7fce16613e8acbc8a0dcfc7302391f8a92edd51cdfb73fd163215aec9ff65db324d28b7df479a102b3f223ac64573
6
+ metadata.gz: 1ed59c92bee7388db944360a6df90d0de35996fb197d74fbf7127ccf34adef3415c4dfc4ede88a43c433fdec8a4aee88a2d419682a608dcc45101411cbb7f3d9
7
+ data.tar.gz: b0c27e24e5e5b23d4a075b33682079ea441121e9c5514f3e98fa7e875162873e1b3c3478ae0809e33d6e84ae7d0017c208355172ca4a84de0d06c657f45a0e70
data/CHANGELOG.md CHANGED
@@ -1,25 +1,47 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
- ## unreleased
3
+ ## 1.0.0 2022-11-04
4
4
 
5
5
 
6
+ ### Changed
7
+
8
+ - Bumped version to 1.0.0 (@solnic)
9
+
10
+ [Compare v0.3.0...v1.0.0](https://github.com/dry-rb/dry-inflector/compare/v0.3.0...v1.0.0)
11
+
12
+ ## 0.3.0 2022-07-12
13
+
14
+
15
+ ### Added
16
+
17
+ - Add CSV as default acronym (via #43) (@waiting-for-dev)
18
+
19
+ ### Changed
20
+
21
+ - Extra dashes are now omitted when converting to camelcase (via #40) (@postmodern)
22
+
23
+ [Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-inflector/compare/v0.2.1...v0.3.0)
24
+
25
+ ## 0.2.1 2021-06-30
26
+
27
+
28
+ ### Added
29
+
30
+ - Add default acronyms: API and CSRF (#35) (@jodosha)
31
+
6
32
  ### Fixed
7
33
 
8
34
  - Fix singularizing -us suffix (issue #33 via #38) (@cllns)
9
35
 
10
36
 
11
- [Compare v0.2.0...master](https://github.com/dry-rb/dry-inflector/compare/v0.2.0...master)
37
+ [Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-inflector/compare/v0.2.0...v0.2.1)
12
38
 
13
39
  ## 0.2.0 2019-10-13
14
40
 
15
41
 
16
42
  ### Added
17
43
 
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
- - ```
44
+ - [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"' ```
23
45
 
24
46
  ### Fixed
25
47
 
data/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  [![CI Status](https://github.com/dry-rb/dry-inflector/workflows/ci/badge.svg)][actions]
12
12
  [![Codacy Badge](https://api.codacy.com/project/badge/Grade/00339f2fb77840149f999cac6110c8a8)][codacy]
13
13
  [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/00339f2fb77840149f999cac6110c8a8)][codacy]
14
- [![Inline docs](http://inch-ci.org/github/dry-rb/dry-inflector.svg?branch=master)][inchpages]
14
+ [![Inline docs](http://inch-ci.org/github/dry-rb/dry-inflector.svg?branch=main)][inchpages]
15
15
 
16
16
  ## Links
17
17
 
@@ -22,8 +22,8 @@
22
22
 
23
23
  This library officially supports the following Ruby versions:
24
24
 
25
- * MRI `>= 2.6.0`
26
- * ~~jruby~~ `>= 9.3` (we are waiting for [2.6 support](https://github.com/jruby/jruby/issues/6161))
25
+ * MRI `>= 2.7.0`
26
+ * jruby `>= 9.3` (postponed until 2.7 is supported)
27
27
 
28
28
  ## License
29
29
 
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-inflector"
27
27
  spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-inflector/issues"
28
28
 
29
- spec.required_ruby_version = ">= 2.6.0"
29
+ spec.required_ruby_version = ">= 2.7.0"
30
30
 
31
31
  # to update dependencies edit project.yml
32
32
 
@@ -110,7 +110,7 @@ module Dry
110
110
  # @since 0.1.2
111
111
  # @api private
112
112
  def self.acronyms(inflect)
113
- inflect.acronym(*%w[JSON HTTP OpenSSL HMAC CSRF API])
113
+ inflect.acronym(*%w[JSON HTTP OpenSSL HMAC CSRF API CSV])
114
114
  end
115
115
 
116
116
  private_class_method :plural, :singular, :irregular, :uncountable, :acronyms
@@ -3,6 +3,6 @@
3
3
  module Dry
4
4
  class Inflector
5
5
  # @since 0.1.0
6
- VERSION = "0.2.1"
6
+ VERSION = "1.0.0"
7
7
  end
8
8
  end
data/lib/dry/inflector.rb CHANGED
@@ -102,7 +102,7 @@ module Dry
102
102
  # inflector = Dry::Inflector.new
103
103
  # inflector.classify("books") # => "Book"
104
104
  def classify(input)
105
- camelize(singularize(input.to_s.sub(/.*\./, "")))
105
+ camelize(singularize(input.to_s.split(".").last))
106
106
  end
107
107
 
108
108
  # Dasherize a string
@@ -153,10 +153,10 @@ module Dry
153
153
  def humanize(input)
154
154
  input = input.to_s
155
155
  result = inflections.humans.apply_to(input)
156
- result.chomp!("_id")
156
+ result.delete_suffix!("_id")
157
157
  result.tr!("_", " ")
158
- match = /(?<separator>\W)/.match(result)
159
- separator = match ? match[:separator] : DEFAULT_SEPARATOR
158
+ match = /(\W)/.match(result)
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?)
162
162
  }.join(separator)
@@ -195,7 +195,7 @@ module Dry
195
195
  def ordinalize(number)
196
196
  abs_value = number.abs
197
197
 
198
- if ORDINALIZE_TH.key?(abs_value % 100)
198
+ if ORDINALIZE_TH[abs_value % 100]
199
199
  "#{number}th"
200
200
  else
201
201
  case abs_value % 10
@@ -260,7 +260,7 @@ module Dry
260
260
  # inflector = Dry::Inflector.new
261
261
  # inflector.tableize("Book") # => "books"
262
262
  def tableize(input)
263
- input = input.to_s.gsub(/::/, "_")
263
+ input = input.to_s.gsub("::", "_")
264
264
  pluralize(underscore(input))
265
265
  end
266
266
 
@@ -298,7 +298,7 @@ module Dry
298
298
  # @since 0.1.0
299
299
  # @api private
300
300
  def uncountable?(input)
301
- !(input =~ /\A[[:space:]]*\z/).nil? || inflections.uncountables.include?(input.downcase)
301
+ input.match?(/\A[[:space:]]*\z/) || inflections.uncountables.include?(input.downcase)
302
302
  end
303
303
 
304
304
  # @return [String]
@@ -314,7 +314,7 @@ module Dry
314
314
 
315
315
  # @since 0.1.0
316
316
  # @api private
317
- ORDINALIZE_TH = (11..13).each_with_object({}) { |n, ret| ret[n] = true }.freeze
317
+ ORDINALIZE_TH = {11 => true, 12 => true, 13 => true}.freeze
318
318
 
319
319
  # @since 0.1.2
320
320
  # @api private
@@ -327,7 +327,7 @@ module Dry
327
327
  def internal_camelize(input, upper)
328
328
  input = input.to_s.dup
329
329
  input.sub!(/^[a-z\d]*/) { |match| inflections.acronyms.apply_to(match, capitalize: upper) }
330
- input.gsub!(%r{(?:_|(/))([a-z\d]*)}i) do
330
+ input.gsub!(%r{(?:[_-]|(/))([a-z\d]*)}i) do
331
331
  m1 = Regexp.last_match(1)
332
332
  m2 = Regexp.last_match(2)
333
333
  "#{m1}#{inflections.acronyms.apply_to(m2)}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-inflector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-06-30 00:00:00.000000000 Z
13
+ date: 2022-11-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -90,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
90
  requirements:
91
91
  - - ">="
92
92
  - !ruby/object:Gem::Version
93
- version: 2.6.0
93
+ version: 2.7.0
94
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - ">="