cmdlet 0.4.0 → 0.5.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: ee471d453193e6c2530ef1728dd97225d9bc1e02f5fefe725e7d1ec4b2d37bff
4
- data.tar.gz: c661a29c3a9493d65724c704d2adf0b925236f98179d685067733b7bca0173bf
3
+ metadata.gz: 7858e7b563b7d8fd9ed449d7d21de54eb3f6816d28fb80b7b46deb2fb741101f
4
+ data.tar.gz: 92fddb23254d18ab8ae07bfe00c3d593845aadd1243e2e1bfee78b7c4628da4b
5
5
  SHA512:
6
- metadata.gz: bc94edaa20e1dc9ab4ce5b1fc4ec20479fa3f3744ca34ca0c878835d00df85a4fdf7fec4efbf412d26239b98387fec5f1402226278bed4ecea70f8ec0c4db647
7
- data.tar.gz: 1cb05dc779c98bb1bed4c86cd7da6755b3e5b864ba9409e5605476ac9e9efe544d2d66a3f48936d358227d2d12a11e215100b2ce169439edef5f940a8d7eee7d
6
+ metadata.gz: 40f58c5d81364fb22291245f52b5b6e457f123f36a88a380e74e9dd7102d42f2afd63888165570849a4502dd25a90fd37bca056decaa3edd4de0f3747d9500e9
7
+ data.tar.gz: c3058b29c7f59a80c2bc58f237a05fa8a690b5d7444a04afcd8451919476d0dc0c00c599425502971b9e2b55c6166b51cef3049d6aca903700329b66997cff38
@@ -68,8 +68,8 @@
68
68
  "ruby": " return '' if value.nil?\n\n value = value.to_s if value.is_a?(Symbol)\n\n value.pluralize\n"
69
69
  },
70
70
  {
71
- "name": "pluralize_by_number",
72
- "description": "Returns the plural form of the word based on a count",
71
+ "name": "pluralize_number",
72
+ "description": "Returns the plural form of the word based on a count in the format \"categories\"",
73
73
  "result": "value and number are used to calculate plural/singular form",
74
74
  "category": "inflection",
75
75
  "category_description": "Inflection handling routines, eg. pluralize, singular, ordinalize",
@@ -89,19 +89,41 @@
89
89
  "splat": null,
90
90
  "default": null,
91
91
  "param_type": "Int"
92
- },
92
+ }
93
+ ],
94
+ "examples": [
95
+
96
+ ],
97
+ "ruby": " return '' if value.nil?\n\n count = count.to_i if count.is_a? String\n\n value.pluralize(count)\n"
98
+ },
99
+ {
100
+ "name": "pluralize_number_word",
101
+ "description": "Returns the plural form of the word based on a count with the count prefixed in the format \"3 categories\"",
102
+ "result": "value and number are used to calculate plural/singular form",
103
+ "category": "inflection",
104
+ "category_description": "Inflection handling routines, eg. pluralize, singular, ordinalize",
105
+ "base_class_require": null,
106
+ "base_class": null,
107
+ "parameters": [
93
108
  {
94
- "name": "format",
95
- "description": "(Optional) what format should output be. :word, :number_word",
109
+ "name": "value",
110
+ "description": "value - value to pluralize",
96
111
  "splat": null,
97
112
  "default": null,
98
113
  "param_type": "String"
114
+ },
115
+ {
116
+ "name": "count",
117
+ "description": "count used to determine pluralization",
118
+ "splat": null,
119
+ "default": null,
120
+ "param_type": "Int"
99
121
  }
100
122
  ],
101
123
  "examples": [
102
124
 
103
125
  ],
104
- "ruby": " return '' if value.nil?\n\n count = count.to_i if count.is_a? String\n format = :word if format.nil?\n\n case format.to_sym\n when :number_word, :number_and_word\n \"#{count} #{value.pluralize(count)}\"\n else # aka :word\n value.pluralize(count)\n end\n"
126
+ "ruby": " return '' if value.nil?\n\n count = count.to_i if count.is_a? String\n\n \"#{count} #{value.pluralize(count)}\"\n"
105
127
  },
106
128
  {
107
129
  "name": "singularize",
@@ -50,26 +50,35 @@ KManager.action :inflection_commands do
50
50
  RUBY
51
51
  end
52
52
  .cmdlet do
53
- name :pluralize_by_number
54
- description 'Returns the plural form of the word based on a count'
53
+ name :pluralize_number
54
+ description 'Returns the plural form of the word based on a count in the format "categories"'
55
+ result 'value and number are used to calculate plural/singular form'
56
+
57
+ parameter :value, 'value - value to pluralize', param_type: 'String'
58
+ parameter :count, 'count used to determine pluralization', param_type: 'Int'
59
+
60
+ ruby <<-'RUBY'
61
+ return '' if value.nil?
62
+
63
+ count = count.to_i if count.is_a? String
64
+
65
+ value.pluralize(count)
66
+ RUBY
67
+ end
68
+ .cmdlet do
69
+ name :pluralize_number_word
70
+ description 'Returns the plural form of the word based on a count with the count prefixed in the format "3 categories"'
55
71
  result 'value and number are used to calculate plural/singular form'
56
72
 
57
73
  parameter :value, 'value - value to pluralize', param_type: 'String'
58
74
  parameter :count, 'count used to determine pluralization', param_type: 'Int'
59
- parameter :format, '(Optional) what format should output be. :word, :number_word'
60
75
 
61
76
  ruby <<-'RUBY'
62
77
  return '' if value.nil?
63
78
 
64
79
  count = count.to_i if count.is_a? String
65
- format = :word if format.nil?
66
-
67
- case format.to_sym
68
- when :number_word, :number_and_word
69
- "#{count} #{value.pluralize(count)}"
70
- else # aka :word
71
- value.pluralize(count)
72
- end
80
+
81
+ "#{count} #{value.pluralize(count)}"
73
82
  RUBY
74
83
  end
75
84
  .cmdlet do
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [0.4.2](https://github.com/klueless-io/cmdlet/compare/v0.4.1...v0.4.2) (2022-07-12)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add inflection: pluralize_number and pluralize_number_word ([a97bbe1](https://github.com/klueless-io/cmdlet/commit/a97bbe1a7960d1dfc26ee37dbf93804ba571fe0d))
7
+
8
+ ## [0.4.1](https://github.com/klueless-io/cmdlet/compare/v0.4.0...v0.4.1) (2022-07-12)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add spec for singularlize ([ae1fc2d](https://github.com/klueless-io/cmdlet/commit/ae1fc2d144caa3ed1eda94fb7e4ee5520c12eaa8))
14
+
15
+ # [0.4.0](https://github.com/klueless-io/cmdlet/compare/v0.3.0...v0.4.0) (2022-07-12)
16
+
17
+
18
+ ### Features
19
+
20
+ * remove sentence ([20961b8](https://github.com/klueless-io/cmdlet/commit/20961b89efae5f9738e24959010318eb284e2af4))
21
+
1
22
  # [0.3.0](https://github.com/klueless-io/cmdlet/compare/v0.2.1...v0.3.0) (2022-07-11)
2
23
 
3
24
 
data/lib/cmdlet/_.rb CHANGED
@@ -28,5 +28,6 @@ require_relative 'comparison/or'
28
28
  require_relative 'inflection/ordinal'
29
29
  require_relative 'inflection/ordinalize'
30
30
  require_relative 'inflection/pluralize'
31
- require_relative 'inflection/pluralize_by_number'
31
+ require_relative 'inflection/pluralize_number'
32
+ require_relative 'inflection/pluralize_number_word'
32
33
  require_relative 'inflection/singularize'
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Inflection handling routines, eg. pluralize, singular, ordinalize
5
+ module Inflection
6
+ # PluralizeNumber: Returns the plural form of the word based on a count in the format &quot;categories&quot;
7
+ class PluralizeNumber < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String] value - value - value to pluralize
10
+ # @param [Int] count - count used to determine pluralization
11
+ # @return [String] value and number are used to calculate plural/singular form
12
+ def call(value, count)
13
+ return '' if value.nil?
14
+
15
+ count = count.to_i if count.is_a? String
16
+
17
+ value.pluralize(count)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Inflection handling routines, eg. pluralize, singular, ordinalize
5
+ module Inflection
6
+ # PluralizeNumberWord: Returns the plural form of the word based on a count with the count prefixed in the format &quot;3 categories&quot;
7
+ class PluralizeNumberWord < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String] value - value - value to pluralize
10
+ # @param [Int] count - count used to determine pluralization
11
+ # @return [String] value and number are used to calculate plural/singular form
12
+ def call(value, count)
13
+ return '' if value.nil?
14
+
15
+ count = count.to_i if count.is_a? String
16
+
17
+ "#{count} #{value.pluralize(count)}"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cmdlet
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "cmdlet",
9
- "version": "0.4.0",
9
+ "version": "0.5.0",
10
10
  "devDependencies": {
11
11
  "@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
12
12
  "@semantic-release/changelog": "^6.0.1",
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Cmdlet provides a set of functions (wrapped in the command pattern) that perform simple actions",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmdlet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
@@ -122,7 +122,8 @@ files:
122
122
  - lib/cmdlet/inflection/ordinal.rb
123
123
  - lib/cmdlet/inflection/ordinalize.rb
124
124
  - lib/cmdlet/inflection/pluralize.rb
125
- - lib/cmdlet/inflection/pluralize_by_number.rb
125
+ - lib/cmdlet/inflection/pluralize_number.rb
126
+ - lib/cmdlet/inflection/pluralize_number_word.rb
126
127
  - lib/cmdlet/inflection/singularize.rb
127
128
  - lib/cmdlet/string_tokenizer.rb
128
129
  - lib/cmdlet/version.rb
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cmdlet
4
- # Inflection handling routines, eg. pluralize, singular, ordinalize
5
- module Inflection
6
- # PluralizeByNumber: Returns the plural form of the word based on a count
7
- class PluralizeByNumber < Cmdlet::BaseCmdlet
8
- #
9
- # @param [String] value - value - value to pluralize
10
- # @param [Int] count - count used to determine pluralization
11
- # @param [String] format - (Optional) what format should output be. :word, :number_word
12
- # @return [String] value and number are used to calculate plural/singular form
13
- def call(value, count, format)
14
- return '' if value.nil?
15
-
16
- count = count.to_i if count.is_a? String
17
- format = :word if format.nil?
18
-
19
- case format.to_sym
20
- when :number_word, :number_and_word
21
- "#{count} #{value.pluralize(count)}"
22
- else # aka :word
23
- value.pluralize(count)
24
- end
25
- end
26
- end
27
- end
28
- end