cmdlet 0.4.1 → 0.4.2
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 +4 -4
- data/.builders/data/cmdlets/inflection.json +29 -0
- data/.builders/generators/cmdlets/inflection.rb +16 -0
- data/CHANGELOG.md +7 -0
- data/lib/cmdlet/_.rb +2 -0
- data/lib/cmdlet/inflection/pluralize_number.rb +21 -0
- data/lib/cmdlet/inflection/pluralize_number_word.rb +21 -0
- data/lib/cmdlet/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9506e418e3b6a429f7022e585a9252980d9bb6ddc7a5e63701ffb3500b9388b8
|
4
|
+
data.tar.gz: '038194a239e9fb9e440c6c697837a6172a2aa3cee05ae6f5b6a2104a231a84bc'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8743f42553160393f595bc4d10b486d8ff35faf28b391346cc471ccc11bb4a351552a59f4bc9fa46778d90cc78caae8ea6e255564010303160216309869b757
|
7
|
+
data.tar.gz: d38a9aba60cad381a19bbf1da0e81423116fb07c6ef4e7a88fb1105ea6c6e1522e5be782bd20e6b34a95d98d13f216da2e41895b68f54213423400be90be50c0
|
@@ -103,6 +103,35 @@
|
|
103
103
|
],
|
104
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"
|
105
105
|
},
|
106
|
+
{
|
107
|
+
"name": "pluralize_number_word",
|
108
|
+
"description": "Returns the plural form of the word based on a count with the count prefixed in the format \"3 categories\"",
|
109
|
+
"result": "value and number are used to calculate plural/singular form",
|
110
|
+
"category": "inflection",
|
111
|
+
"category_description": "Inflection handling routines, eg. pluralize, singular, ordinalize",
|
112
|
+
"base_class_require": null,
|
113
|
+
"base_class": null,
|
114
|
+
"parameters": [
|
115
|
+
{
|
116
|
+
"name": "value",
|
117
|
+
"description": "value - value to pluralize",
|
118
|
+
"splat": null,
|
119
|
+
"default": null,
|
120
|
+
"param_type": "String"
|
121
|
+
},
|
122
|
+
{
|
123
|
+
"name": "count",
|
124
|
+
"description": "count used to determine pluralization",
|
125
|
+
"splat": null,
|
126
|
+
"default": null,
|
127
|
+
"param_type": "Int"
|
128
|
+
}
|
129
|
+
],
|
130
|
+
"examples": [
|
131
|
+
|
132
|
+
],
|
133
|
+
"ruby": " return '' if value.nil?\n\n count = count.to_i if count.is_a? String\n\n \"#{count} #{value.pluralize(count)}\"\n"
|
134
|
+
},
|
106
135
|
{
|
107
136
|
"name": "singularize",
|
108
137
|
"description": "The reverse of #pluralize, returns the singular form of a word in a string",
|
@@ -72,6 +72,22 @@ KManager.action :inflection_commands do
|
|
72
72
|
end
|
73
73
|
RUBY
|
74
74
|
end
|
75
|
+
.cmdlet do
|
76
|
+
name :pluralize_number_word
|
77
|
+
description 'Returns the plural form of the word based on a count with the count prefixed in the format "3 categories"'
|
78
|
+
result 'value and number are used to calculate plural/singular form'
|
79
|
+
|
80
|
+
parameter :value, 'value - value to pluralize', param_type: 'String'
|
81
|
+
parameter :count, 'count used to determine pluralization', param_type: 'Int'
|
82
|
+
|
83
|
+
ruby <<-'RUBY'
|
84
|
+
return '' if value.nil?
|
85
|
+
|
86
|
+
count = count.to_i if count.is_a? String
|
87
|
+
|
88
|
+
"#{count} #{value.pluralize(count)}"
|
89
|
+
RUBY
|
90
|
+
end
|
75
91
|
.cmdlet do
|
76
92
|
name :singularize
|
77
93
|
description 'The reverse of #pluralize, returns the singular form of a word in a string'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [0.4.1](https://github.com/klueless-io/cmdlet/compare/v0.4.0...v0.4.1) (2022-07-12)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* add spec for singularlize ([ae1fc2d](https://github.com/klueless-io/cmdlet/commit/ae1fc2d144caa3ed1eda94fb7e4ee5520c12eaa8))
|
7
|
+
|
1
8
|
# [0.4.0](https://github.com/klueless-io/cmdlet/compare/v0.3.0...v0.4.0) (2022-07-12)
|
2
9
|
|
3
10
|
|
data/lib/cmdlet/_.rb
CHANGED
@@ -29,4 +29,6 @@ require_relative 'inflection/ordinal'
|
|
29
29
|
require_relative 'inflection/ordinalize'
|
30
30
|
require_relative 'inflection/pluralize'
|
31
31
|
require_relative 'inflection/pluralize_by_number'
|
32
|
+
require_relative 'inflection/pluralize_number'
|
33
|
+
require_relative 'inflection/pluralize_number_word'
|
32
34
|
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 "categories"
|
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 "3 categories"
|
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
|
data/lib/cmdlet/version.rb
CHANGED
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "cmdlet",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.2",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "cmdlet",
|
9
|
-
"version": "0.4.
|
9
|
+
"version": "0.4.2",
|
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
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.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
@@ -123,6 +123,8 @@ files:
|
|
123
123
|
- lib/cmdlet/inflection/ordinalize.rb
|
124
124
|
- lib/cmdlet/inflection/pluralize.rb
|
125
125
|
- lib/cmdlet/inflection/pluralize_by_number.rb
|
126
|
+
- lib/cmdlet/inflection/pluralize_number.rb
|
127
|
+
- lib/cmdlet/inflection/pluralize_number_word.rb
|
126
128
|
- lib/cmdlet/inflection/singularize.rb
|
127
129
|
- lib/cmdlet/string_tokenizer.rb
|
128
130
|
- lib/cmdlet/version.rb
|