hanami-utils 1.3.2 → 1.3.3

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: ab3141a4fd9052c6472d5bfd820eca5be30a9be7e3f8c7a8c5039ca14ff8a44e
4
- data.tar.gz: c6b7581c887b4c7dafe0834a5ee045eaef17d1ed9a82aeffd5e6de2c995093d6
3
+ metadata.gz: 545770be01c79024c33b64bb801b417f3c0b2a40ed88a635eedd43e0516c8824
4
+ data.tar.gz: 0bc96d622a662fc6a469175fcbda2c88f28057fa4018db12218116bface3d02c
5
5
  SHA512:
6
- metadata.gz: e05b9c87e1e3206ba379a7f4d09fcae6602049d36548306ccec1abf89f7a2e2271ab995e2afa9702411062f3fd0f2e13e1bcdcd69868a63e05517fc36bf1c020
7
- data.tar.gz: 55e117ed1367cdd8791531e42b7da858641a6e36f24cd5d440371e006a704ffa53dd0e01d352e306dd6be1eedb4ba0ffd728228e01dfab0a9de9e6e3814cbd04
6
+ metadata.gz: c37c0b42a52d21ad5f1746b56aabc0ebe132ae9479674785066f32d5620e91865d50df375e51a0802de4a0f2280fba5598dfe4044a82e933b46d765695a63395
7
+ data.tar.gz: 0d22487f8f82568cdac873d58562a0cd3bdf8f7d5de7f268791c5cb454f07873a1dca90943967539b7e38e0cda3b852fd52d422e567231c81057191905b523b2
@@ -1,6 +1,10 @@
1
1
  # Hanami::Utils
2
2
  Ruby core extentions and class utilities for Hanami
3
3
 
4
+ ## v1.3.3 - 2019-09-13
5
+ ### Fixed
6
+ - [Mauro Morales] Ensure `Utils::Inflector.pluralize` and `.singularize` to work with words that contain an underscore (`_`)
7
+
4
8
  ## v1.3.2 - 2019-06-21
5
9
  ### Added
6
10
  - [Vladislav Yashin & Luca Guidi] Added `Utils::BasicObject#instance_of?`, `#is_a?`, and `#kind_of`
@@ -27,17 +27,35 @@ module Hanami
27
27
  # @since 0.6.0
28
28
  # @api private
29
29
  def ===(other)
30
- key = other.downcase
30
+ key = extract_last_alphanumeric_token(other)
31
31
  @rules.key?(key) || @rules.value?(key)
32
32
  end
33
33
 
34
34
  # @since 0.6.0
35
35
  # @api private
36
36
  def apply(string)
37
- key = string.downcase
37
+ key = extract_last_alphanumeric_token(string)
38
38
  result = @rules[key] || @rules.rassoc(key).last
39
39
 
40
- string[0] + result[1..-1]
40
+ prefix = if key == string.downcase
41
+ string[0]
42
+ else
43
+ string[0..string.index(key)]
44
+ end
45
+
46
+ prefix + result[1..-1]
47
+ end
48
+
49
+ private
50
+
51
+ # @since 1.3.3
52
+ # @api private
53
+ def extract_last_alphanumeric_token(string)
54
+ if string.downcase =~ /_([[:alpha:]]*)\z/
55
+ Regexp.last_match(1)
56
+ else
57
+ string.downcase
58
+ end
41
59
  end
42
60
  end
43
61
 
@@ -373,15 +391,15 @@ module Hanami
373
391
  $1 + IES
374
392
  when /\A(.*)(ex|ix)\z/
375
393
  $1 + ICES
376
- when /\A(.*)(eau|#{ EAUX })\z/
394
+ when /\A(.*)(eau|#{EAUX})\z/
377
395
  $1 + EAUX
378
396
  when /\A(.*)x\z/
379
397
  $1 + XES
380
398
  when /\A(.*)ma\z/
381
399
  string + TA
382
- when /\A(.*)(um|#{ A })\z/
400
+ when /\A(.*)(um|#{A})\z/
383
401
  $1 + A
384
- when /\A(buffal|domin|ech|embarg|her|mosquit|potat|tomat)#{ O }\z/i
402
+ when /\A(buffal|domin|ech|embarg|her|mosquit|potat|tomat)#{O}\z/i
385
403
  $1 + OES
386
404
  when /\A(.*)(fee)\z/
387
405
  $1 + $2 + S
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '1.3.2'.freeze
6
+ VERSION = '1.3.3'.freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-21 00:00:00.000000000 Z
11
+ date: 2019-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: transproc