dry-inflector 0.1.2 → 0.2.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: 7cccc4cd092473c4c5dfefd8830e97c987fbb6cd6039b6253fd973a0b4d5b8ac
4
- data.tar.gz: 6aca715e9ab5497c0f325691783e92a10035b27a3e6fdf483df38b7fb306d6ad
3
+ metadata.gz: 91485a1eac7b8b76f5a017b6eb04d567b54ae0685fd30ba1e3378450343de3f4
4
+ data.tar.gz: ee1e2b939347eda2577ddff9d3d454cc1e3115d2ac298260ea6215d26d5b78ec
5
5
  SHA512:
6
- metadata.gz: 2c9c21e1611fe3bafd8cf7e303b5030c1ba3f777fd397a58f2dfba77f8be05b49fdece384e49d82d43043e388ca3fc1f1c6c84508fdfdac02ce9851edfee1dba
7
- data.tar.gz: c83c9d597c611194642fe6aed04b3c5f6e37ec9fa212b3501a13c93010305f9c339875a09ba123b8a97fa89f567e90c110af9ac76317f4c16749a5e91601b57e
6
+ metadata.gz: 3d6f9a7fb8249866c30008a11b93715040e5b24106e83e731be32e15dc10c5e8b06d90072d21670e33b44dec41a5ceb075f076dc038d1dfb6424e6185a4ee283
7
+ data.tar.gz: e238694af29c1611b54630b9aecfa8b8c1b1096596393f811a9a8430a82d83f71e39e27b72337f504870f4122559ceb8cea7c9a4ffa05b8310dc616b7fa21282
@@ -1,23 +1,43 @@
1
- # Dry::Inflector
1
+ # dry-inflector
2
2
 
3
3
  Inflector for Ruby
4
4
 
5
- ## v0.1.2 - to be released
5
+ ## v0.2.0 - 2019-10-13
6
+
7
+ ### Added
8
+
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
+ ```
14
+
15
+ ### Fixed
16
+
17
+ - [ecnal] Fixed singularization rules for words like "alias" or "status"
18
+
19
+ [Compare v0.1.2...v0.2.0](https://github.com/dry-rb/dry-inflector/compare/v0.1.2...v0.2.0)
20
+
21
+ ## v0.1.2 - 2018-04-25
6
22
 
7
23
  ### Added
8
24
 
9
25
  - [Gustavo Caso & Nikita Shilnikov] Added support for acronyms
10
26
 
11
- [Compare v0.1.1...master](https://github.com/dry-rb/dry-inflector/compare/v0.1.1...master)
27
+ [Compare v0.1.1...v0.1.2](https://github.com/dry-rb/dry-inflector/compare/v0.1.1...v0.1.2)
12
28
 
13
29
  ## v0.1.1 - 2017-11-18
30
+
14
31
  ### Fixed
32
+
15
33
  - [Luca Guidi & Abinoam P. Marques Jr.] Ensure `Dry::Inflector#ordinalize` to work for all the numbers from 0 to 100
16
34
 
17
35
  [Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-inflector/compare/v0.1.0...v0.1.1)
18
36
 
19
37
  ## v0.1.0 - 2017-11-17
38
+
20
39
  ### Added
40
+
21
41
  - [Luca Guidi] Introduced `Dry::Inflector#pluralize`
22
42
  - [Luca Guidi] Introduced `Dry::Inflector#singularize`
23
43
  - [Luca Guidi] Introduced `Dry::Inflector#camelize`
data/README.md CHANGED
@@ -1,16 +1,13 @@
1
- [gitter]: https://gitter.im/dry-rb/chat
2
1
  [gem]: https://img.shields.io/gem/v/dry-inflector.svg
3
2
  [travis]: https://travis-ci.org/dry-rb/dry-inflector
4
- [gemnasium]: https://gemnasium.com/dry-rb/dry-inflector
5
3
  [codeclimate]: https://codeclimate.com/github/dry-rb/dry-inflector
6
- [coveralls]: https://coveralls.io/r/dry-rb/dry-inflector
4
+ [chat]: https://dry-rb.zulipchat.com
7
5
  [inchpages]: http://inch-ci.org/github/dry-rb/dry-inflector
8
6
 
9
- # dry-inflector [![Join the chat at https://gitter.im/dry-rb/chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dry-rb/chat)
7
+ # dry-inflector [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
10
8
 
11
9
  [![Gem Version](https://badge.fury.io/rb/dry-inflector.svg)][gem]
12
10
  [![Build Status](https://travis-ci.org/dry-rb/dry-inflector.svg?branch=master)][travis]
13
- [![Dependency Status](https://gemnasium.com/dry-rb/dry-inflector.svg)][gemnasium]
14
11
  [![Code Climate](https://codeclimate.com/github/dry-rb/dry-inflector/badges/gpa.svg)][codeclimate]
15
12
  [![Test Coverage](https://codeclimate.com/github/dry-rb/dry-inflector/badges/coverage.svg)][codeclimate]
16
13
  [![Inline docs](http://inch-ci.org/github/dry-rb/dry-inflector.svg?branch=master)][inchpages]
@@ -13,10 +13,13 @@ Gem::Specification.new do |spec|
13
13
 
14
14
  spec.summary = "DRY Inflector"
15
15
  spec.description = "String inflections for dry-rb"
16
- spec.homepage = "http://dry-rb.org"
16
+ spec.homepage = "https://dry-rb.org"
17
17
  spec.license = "MIT"
18
18
 
19
19
  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"
20
23
 
21
24
  spec.bindir = "exe"
22
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -24,8 +27,9 @@ Gem::Specification.new do |spec|
24
27
 
25
28
  spec.files = `git ls-files -- lib/* CHANGELOG.md LICENSE.md README.md dry-inflector.gemspec`.split($INPUT_RECORD_SEPARATOR)
26
29
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
30
+ spec.required_ruby_version = '>= 2.4'
27
31
 
28
- spec.add_development_dependency "bundler", "~> 1.16"
32
+ spec.add_development_dependency "bundler"
29
33
  spec.add_development_dependency "rake", "~> 12.0"
30
34
  spec.add_development_dependency "rspec", "~> 3.7"
31
35
  spec.add_development_dependency "rubocop", "~> 0.50.0"
@@ -0,0 +1 @@
1
+ require 'dry/inflector'
@@ -34,30 +34,42 @@ module Dry
34
34
  @inflections = Inflections.build(&blk)
35
35
  end
36
36
 
37
- # Camelize a string
37
+ # Lower camelize a string
38
38
  #
39
39
  # @param input [String,Symbol] the input
40
- # @return [String] the camelized string
40
+ # @return [String] the lower camelized string
41
41
  #
42
- # @since 0.1.0
42
+ # @since 0.1.3
43
43
  #
44
44
  # @example
45
45
  # require "dry/inflector"
46
46
  #
47
47
  # inflector = Dry::Inflector.new
48
- # inflector.camelize("dry/inflector") # => "Dry::Inflector"
49
- def camelize(input)
50
- input = input.to_s.dup
51
- input.sub!(/^[a-z\d]*/) { |match| inflections.acronyms.apply_to(match) }
52
- input.gsub!(%r{(?:_|(/))([a-z\d]*)}i) do
53
- m1 = Regexp.last_match(1)
54
- m2 = Regexp.last_match(2)
55
- "#{m1}#{inflections.acronyms.apply_to(m2)}"
56
- end
57
- input.gsub!("/", "::")
58
- input
48
+ # inflector.camelize_lower("data_mapper") # => "dataMapper"
49
+ def camelize_lower(input)
50
+ internal_camelize(input, false)
51
+ end
52
+
53
+ # Upper camelize a string
54
+ #
55
+ # @param input [String,Symbol] the input
56
+ # @return [String] the upper camelized string
57
+ #
58
+ # @since 0.1.3
59
+ #
60
+ # @example
61
+ # require "dry/inflector"
62
+ #
63
+ # inflector = Dry::Inflector.new
64
+ # inflector.camelize_upper("data_mapper") # => "DataMapper"
65
+ # inflector.camelize_upper("dry/inflector") # => "Dry::Inflector"
66
+ def camelize_upper(input)
67
+ internal_camelize(input, true)
59
68
  end
60
69
 
70
+ alias :camelize :camelize_upper
71
+
72
+
61
73
  # Find a constant with the name specified in the argument string
62
74
  #
63
75
  # The name is assumed to be the one of a top-level constant,
@@ -288,6 +300,15 @@ module Dry
288
300
  !(input =~ /\A[[:space:]]*\z/).nil? || inflections.uncountables.include?(input.downcase)
289
301
  end
290
302
 
303
+ # @return [String]
304
+ #
305
+ # @since 0.2.0
306
+ # @api public
307
+ def to_s
308
+ '#<Dry::Inflector>'
309
+ end
310
+ alias inspect to_s
311
+
291
312
  private
292
313
 
293
314
  # @since 0.1.0
@@ -298,8 +319,21 @@ module Dry
298
319
  # @api private
299
320
  DEFAULT_SEPARATOR = " "
300
321
 
301
- # @since 0.1.0
302
- # @api private
303
322
  attr_reader :inflections
323
+
324
+ # @since 0.1.3
325
+ # @api private
326
+ def internal_camelize(input, upper)
327
+ input = input.to_s.dup
328
+ input.sub!(/^[a-z\d]*/) { |match| inflections.acronyms.apply_to(match, upper) }
329
+ input.gsub!(%r{(?:_|(/))([a-z\d]*)}i) do
330
+ m1 = Regexp.last_match(1)
331
+ m2 = Regexp.last_match(2)
332
+ "#{m1}#{inflections.acronyms.apply_to(m2)}"
333
+ end
334
+ input.gsub!("/", "::")
335
+ input
336
+ end
337
+
304
338
  end
305
339
  end
@@ -57,8 +57,8 @@ module Dry
57
57
  inflect.singular(/s\z/i, "")
58
58
  inflect.singular(/(n)ews\z/i, '\1ews')
59
59
  inflect.singular(/([ti])a\z/i, '\1um')
60
- inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses\z/i, '\1\2sis')
61
- inflect.singular(/(^analy)ses\z/i, '\1sis')
60
+ inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)\z/i, '\1\2sis')
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')
64
64
  inflect.singular(/(tive)s\z/i, '\1')
@@ -69,12 +69,12 @@ 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(/(bus)(es)?\z/i, '\1')
73
73
  inflect.singular(/(o)es\z/i, '\1')
74
74
  inflect.singular(/(shoe)s\z/i, '\1')
75
- inflect.singular(/(cris|ax|test)es\z/i, '\1is')
76
- inflect.singular(/(octop|vir)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')
@@ -3,6 +3,6 @@
3
3
  module Dry
4
4
  class Inflector
5
5
  # @since 0.1.0
6
- VERSION = "0.1.2"
6
+ VERSION = "0.2.0"
7
7
  end
8
8
  end
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.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2018-04-25 00:00:00.000000000 Z
13
+ date: 2019-10-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '1.16'
21
+ version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - "~>"
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '1.16'
28
+ version: '0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rake
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -81,17 +81,21 @@ files:
81
81
  - LICENSE.md
82
82
  - README.md
83
83
  - dry-inflector.gemspec
84
+ - lib/dry-inflector.rb
84
85
  - lib/dry/inflector.rb
85
86
  - lib/dry/inflector/acronyms.rb
86
87
  - lib/dry/inflector/inflections.rb
87
88
  - lib/dry/inflector/inflections/defaults.rb
88
89
  - lib/dry/inflector/rules.rb
89
90
  - lib/dry/inflector/version.rb
90
- homepage: http://dry-rb.org
91
+ homepage: https://dry-rb.org
91
92
  licenses:
92
93
  - MIT
93
94
  metadata:
94
95
  allowed_push_host: https://rubygems.org
96
+ changelog_uri: https://github.com/dry-rb/dry-inflector/blob/master/CHANGELOG.md
97
+ source_code_uri: https://github.com/dry-rb/dry-inflector
98
+ bug_tracker_uri: https://github.com/dry-rb/dry-inflector/issues
95
99
  post_install_message:
96
100
  rdoc_options: []
97
101
  require_paths:
@@ -100,15 +104,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
104
  requirements:
101
105
  - - ">="
102
106
  - !ruby/object:Gem::Version
103
- version: '0'
107
+ version: '2.4'
104
108
  required_rubygems_version: !ruby/object:Gem::Requirement
105
109
  requirements:
106
110
  - - ">="
107
111
  - !ruby/object:Gem::Version
108
112
  version: '0'
109
113
  requirements: []
110
- rubyforge_project:
111
- rubygems_version: 2.7.6
114
+ rubygems_version: 3.0.3
112
115
  signing_key:
113
116
  specification_version: 4
114
117
  summary: DRY Inflector