cmdlet 0.4.1 → 0.4.2

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: e35da0dc6c2ae3fd9ccab71c7a964d8e5e3c66e703e51f5710b6cea7867554b5
4
- data.tar.gz: 37d37aa86e3b75dc60d7f17fa34cd652571698b5dbe7fbeb4baf431c8a70d2e6
3
+ metadata.gz: 9506e418e3b6a429f7022e585a9252980d9bb6ddc7a5e63701ffb3500b9388b8
4
+ data.tar.gz: '038194a239e9fb9e440c6c697837a6172a2aa3cee05ae6f5b6a2104a231a84bc'
5
5
  SHA512:
6
- metadata.gz: bee6e91c0894c7f902826d62572a94d88a5b361bb7d438c159ff0c5e548f21f1ccb693f4d09796bfe8ea1ffb9f87fa86828092c7bd6de271ddba68864a87aaba
7
- data.tar.gz: 570220da94644b05c3c8fb685dfe034da565c520d9c7e20e52756861d6ea18508d69098c1cc8c09715cbee14bc5955bd7d5e9eaa01abb2c167ddc4cd9ae7a3f8
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 &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.1'
4
+ VERSION = '0.4.2'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.4.1",
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.1",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
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.1
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