cmdlet 0.4.1 → 0.6.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 +4 -4
- data/.builders/.templates/handlebars_helper_default_configuration.rb +7 -0
- data/.builders/data/cmdlets/array.json +0 -29
- data/.builders/data/cmdlets/inflection.json +28 -6
- data/.builders/director/cmdlet_director.rb +10 -0
- data/.builders/generators/cmdlets/array.rb +0 -15
- data/.builders/generators/cmdlets/inflection.rb +20 -11
- data/CHANGELOG.md +21 -0
- data/lib/cmdlet/_.rb +2 -1
- 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 +5 -3
- data/lib/cmdlet/inflection/pluralize_by_number.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2f90c89d289ef06c536a7d11f99415ce7edd32e81dafa7b4886ba9bc54a87ac
|
4
|
+
data.tar.gz: 26d34c6d9a0d54be7cdcf403a92096919391dc14e547f6971e18aab22601ee6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eed56d8e114624213419b305e1c5b609ed39a67d88749a9bc676a4d96b72e0cfceba6301102ecba142837834b18421d5e19ae73a3537e56636b6cac8411668db
|
7
|
+
data.tar.gz: d5e22d7073e0edb2b781a69a15b861f572b85602e22dea4e8736eea72228db6f696b368a3ce402a48b53eebe8610b0076c6d5f71e9191941a68011e4ea4d8b86
|
@@ -59,35 +59,6 @@
|
|
59
59
|
],
|
60
60
|
"ruby": " return '' if values.nil? || !values.is_a?(::Array)\n values = values.reject(&:blank?)\n return '' if values.length.zero?\n\n \"#{separator}#{values.join(separator)}\"\n"
|
61
61
|
},
|
62
|
-
{
|
63
|
-
"name": "join_pre",
|
64
|
-
"description": "join an array of values with separator as a string and using the separator at the beginning of string",
|
65
|
-
"result": null,
|
66
|
-
"category": "array",
|
67
|
-
"category_description": "Array handling routines, eg. join, join_prefix, join_post",
|
68
|
-
"base_class_require": null,
|
69
|
-
"base_class": null,
|
70
|
-
"parameters": [
|
71
|
-
{
|
72
|
-
"name": "values",
|
73
|
-
"description": "array of values to join",
|
74
|
-
"splat": null,
|
75
|
-
"default": null,
|
76
|
-
"param_type": "String|Int"
|
77
|
-
},
|
78
|
-
{
|
79
|
-
"name": "separator",
|
80
|
-
"description": "separator between values, defaults to comma",
|
81
|
-
"splat": null,
|
82
|
-
"default": "','",
|
83
|
-
"param_type": "String"
|
84
|
-
}
|
85
|
-
],
|
86
|
-
"examples": [
|
87
|
-
|
88
|
-
],
|
89
|
-
"ruby": " return '' if values.nil? || !values.is_a?(::Array)\n values = values.reject(&:blank?)\n return '' if values.length.zero?\n\n \"#{separator}#{values.join(separator)}\"\n"
|
90
|
-
},
|
91
62
|
{
|
92
63
|
"name": "join_post",
|
93
64
|
"description": "join an array of values with separator as a string and using the separator at the end of string",
|
@@ -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": "
|
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": "
|
95
|
-
"description": "
|
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
|
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",
|
@@ -48,6 +48,16 @@ class CmdletDirector < KDirector::Directors::BaseDirector
|
|
48
48
|
add(handlebars_spec_file, template_file: 'handlebars_helper_spec.rb', cmdlet: cmdlet, on_exist: :skip)
|
49
49
|
end
|
50
50
|
|
51
|
+
if builder.cmdlets.length.positive?
|
52
|
+
cd(:handlebars_lib)
|
53
|
+
|
54
|
+
category = builder.cmdlets.first[:category]
|
55
|
+
handlebars_category_configuration_file = "handlebarsjs/helpers/#{category}/default_configuration.rb"
|
56
|
+
|
57
|
+
oadd(handlebars_category_configuration_file, template_file: 'handlebars_helper_default_configuration.rb', cmdlets: builder.cmdlets)
|
58
|
+
end
|
59
|
+
|
60
|
+
|
51
61
|
self
|
52
62
|
end
|
53
63
|
|
@@ -35,21 +35,6 @@ KManager.action :array_commands do
|
|
35
35
|
"#{separator}#{values.join(separator)}"
|
36
36
|
RUBY
|
37
37
|
end
|
38
|
-
.cmdlet do
|
39
|
-
name :join_pre
|
40
|
-
description 'join an array of values with separator as a string and using the separator at the beginning of string'
|
41
|
-
|
42
|
-
parameter :values, 'array of values to join', param_type: 'String|Int'
|
43
|
-
parameter :separator, 'separator between values, defaults to comma', default: "','"
|
44
|
-
|
45
|
-
ruby <<-'RUBY'
|
46
|
-
return '' if values.nil? || !values.is_a?(::Array)
|
47
|
-
values = values.reject(&:blank?)
|
48
|
-
return '' if values.length.zero?
|
49
|
-
|
50
|
-
"#{separator}#{values.join(separator)}"
|
51
|
-
RUBY
|
52
|
-
end
|
53
38
|
.cmdlet do
|
54
39
|
name :join_post
|
55
40
|
description 'join an array of values with separator as a string and using the separator at the end of string'
|
@@ -50,26 +50,35 @@ KManager.action :inflection_commands do
|
|
50
50
|
RUBY
|
51
51
|
end
|
52
52
|
.cmdlet do
|
53
|
-
name :
|
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
|
-
|
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.5.0](https://github.com/klueless-io/cmdlet/compare/v0.4.2...v0.5.0) (2022-07-12)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* add inflection: pluralize_number and pluralize_number_word ([53b1d00](https://github.com/klueless-io/cmdlet/commit/53b1d00fa44da710a480935d41f26966702d1ae6))
|
7
|
+
|
8
|
+
## [0.4.2](https://github.com/klueless-io/cmdlet/compare/v0.4.1...v0.4.2) (2022-07-12)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* add inflection: pluralize_number and pluralize_number_word ([a97bbe1](https://github.com/klueless-io/cmdlet/commit/a97bbe1a7960d1dfc26ee37dbf93804ba571fe0d))
|
14
|
+
|
15
|
+
## [0.4.1](https://github.com/klueless-io/cmdlet/compare/v0.4.0...v0.4.1) (2022-07-12)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* add spec for singularlize ([ae1fc2d](https://github.com/klueless-io/cmdlet/commit/ae1fc2d144caa3ed1eda94fb7e4ee5520c12eaa8))
|
21
|
+
|
1
22
|
# [0.4.0](https://github.com/klueless-io/cmdlet/compare/v0.3.0...v0.4.0) (2022-07-12)
|
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/
|
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 "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.
|
3
|
+
"version": "0.6.0",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "cmdlet",
|
9
|
-
"version": "0.
|
9
|
+
"version": "0.6.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
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmdlet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- ".builders/.templates/cmdlet_spec.rb"
|
52
52
|
- ".builders/.templates/cmdlets_require_all.rb"
|
53
53
|
- ".builders/.templates/handlebars_helper.rb"
|
54
|
+
- ".builders/.templates/handlebars_helper_default_configuration.rb"
|
54
55
|
- ".builders/.templates/handlebars_helper_require_all.rb"
|
55
56
|
- ".builders/.templates/handlebars_helper_spec.rb"
|
56
57
|
- ".builders/_.rb"
|
@@ -122,7 +123,8 @@ files:
|
|
122
123
|
- lib/cmdlet/inflection/ordinal.rb
|
123
124
|
- lib/cmdlet/inflection/ordinalize.rb
|
124
125
|
- lib/cmdlet/inflection/pluralize.rb
|
125
|
-
- lib/cmdlet/inflection/
|
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
|
@@ -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
|