cmdlet 0.6.2 → 0.8.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_configuration_defaults.rb +23 -0
- data/.builders/data/categories.json +6 -10
- data/.builders/data/cmdlets/array.json +18 -0
- data/.builders/data/cmdlets/case.json +55 -0
- data/.builders/data/cmdlets/misc.json +30 -0
- data/.builders/director/category_director.rb +18 -1
- data/.builders/director/cmdlet_builder.rb +1 -0
- data/.builders/director/cmdlet_child.rb +4 -0
- data/.builders/director/cmdlet_dao.rb +5 -0
- data/.builders/director/cmdlet_director.rb +0 -10
- data/.builders/generators/20-categories.rb +2 -3
- data/.builders/generators/cmdlets/array.rb +1 -1
- data/.builders/generators/cmdlets/case.rb +11 -0
- data/.builders/generators/cmdlets/comparison.rb +8 -0
- data/.builders/generators/cmdlets/inflection.rb +2 -0
- data/.builders/generators/cmdlets/misc.rb +22 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +21 -0
- data/lib/cmdlet/_.rb +1 -0
- data/lib/cmdlet/misc/safe.rb +17 -0
- data/lib/cmdlet/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +8 -6
- data/.builders/.templates/handlebars_helper_default_configuration.rb +0 -7
- data/.builders/generators/30-commands-bak.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27e7a1e05d48209204f34c1e04f991ed01d3d3eca2ecbe9f841826cadc177df7
|
4
|
+
data.tar.gz: 847c0632e9e33f52b014eb04bd27fcda83dea0e1837d9dcc9d7d515cc2aeb02b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4501a96777d21750f4c1ea03e47305b297605e96cd6f076bfdd8af2953fa47f465ddf0a9847fb5fa87dceecd5c33cb8eee2d421a65d4b08d9047c5e07482f02
|
7
|
+
data.tar.gz: 0dfb170d52bfdbca451e2888be1e2b501a448cd0392ed0931404ce7c166c53f30f860b8fac46e57c8180c8f02958a578d86c322b1f1b2bfe160645ce8daa831b
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Handlebarsjs
|
4
|
+
# Pre-configure default helpers for each category
|
5
|
+
class HandlebarsConfigurationDefaults
|
6
|
+
def add_all_defaults
|
7
|
+
{{#each cmdlet_categories}}
|
8
|
+
add_{{category}}_defaults
|
9
|
+
{{/each}}
|
10
|
+
end
|
11
|
+
|
12
|
+
{{#each cmdlet_categories}}
|
13
|
+
def add_{{category}}_defaults
|
14
|
+
KConfig.configure do |config|
|
15
|
+
{{#each cmdlets}}
|
16
|
+
config.handlebars.helper(:{{name}}, Handlebarsjs::Helpers::{{camel category}}::{{camel name}}.new{{#if aliases}}, aliases: %i[{{#each aliases}}{{#if @first}}{{^}} {{/if}}{{.}}{{/each}}]{{/if}})
|
17
|
+
{{/each}}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
{{/each}}
|
22
|
+
end
|
23
|
+
end
|
@@ -1,5 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"categories": [
|
3
|
+
{
|
4
|
+
"name": "array",
|
5
|
+
"description": "Array handling routines, eg. join, join_prefix, join_post"
|
6
|
+
},
|
3
7
|
{
|
4
8
|
"name": "case",
|
5
9
|
"description": "Tokenize and apply case and/or separator"
|
@@ -13,16 +17,8 @@
|
|
13
17
|
"description": "Inflection handling routines, eg. pluralize, singular, ordinalize"
|
14
18
|
},
|
15
19
|
{
|
16
|
-
"name": "
|
17
|
-
"description": "
|
18
|
-
},
|
19
|
-
{
|
20
|
-
"name": "array",
|
21
|
-
"description": "Array handling routines, eg. join, join_prefix, join_post"
|
22
|
-
},
|
23
|
-
{
|
24
|
-
"name": "transform",
|
25
|
-
"description": "Tokenize and apply case and/or separator"
|
20
|
+
"name": "misc",
|
21
|
+
"description": "Miscellaneous cmdlets"
|
26
22
|
}
|
27
23
|
]
|
28
24
|
}
|
@@ -3,6 +3,12 @@
|
|
3
3
|
"cmdlets": [
|
4
4
|
{
|
5
5
|
"name": "join",
|
6
|
+
"aliases": [
|
7
|
+
|
8
|
+
],
|
9
|
+
"name_and_aliases": [
|
10
|
+
|
11
|
+
],
|
6
12
|
"description": "join an array of values with separator as a string",
|
7
13
|
"result": "new String formed by joining the array elements with seperator",
|
8
14
|
"category": "array",
|
@@ -32,6 +38,12 @@
|
|
32
38
|
},
|
33
39
|
{
|
34
40
|
"name": "join_pre",
|
41
|
+
"aliases": [
|
42
|
+
|
43
|
+
],
|
44
|
+
"name_and_aliases": [
|
45
|
+
|
46
|
+
],
|
35
47
|
"description": "join an array of values with separator as a string and using the separator at the beginning of string",
|
36
48
|
"result": null,
|
37
49
|
"category": "array",
|
@@ -61,6 +73,12 @@
|
|
61
73
|
},
|
62
74
|
{
|
63
75
|
"name": "join_post",
|
76
|
+
"aliases": [
|
77
|
+
|
78
|
+
],
|
79
|
+
"name_and_aliases": [
|
80
|
+
|
81
|
+
],
|
64
82
|
"description": "join an array of values with separator as a string and using the separator at the end of string",
|
65
83
|
"result": null,
|
66
84
|
"category": "array",
|
@@ -3,6 +3,10 @@
|
|
3
3
|
"cmdlets": [
|
4
4
|
{
|
5
5
|
"name": "back_slash",
|
6
|
+
"aliases": [
|
7
|
+
"backward_slash",
|
8
|
+
"slash_backward"
|
9
|
+
],
|
6
10
|
"description": "Convert to back slash notation",
|
7
11
|
"result": "value converted to back_slash case",
|
8
12
|
"category": "case",
|
@@ -25,6 +29,12 @@
|
|
25
29
|
},
|
26
30
|
{
|
27
31
|
"name": "camel",
|
32
|
+
"aliases": [
|
33
|
+
"camel_upper",
|
34
|
+
"camelUpper",
|
35
|
+
"camelU",
|
36
|
+
"pascalcase"
|
37
|
+
],
|
28
38
|
"description": "Camel case the characters in the given 'string'",
|
29
39
|
"result": "value converted to camel case",
|
30
40
|
"category": "case",
|
@@ -47,6 +57,9 @@
|
|
47
57
|
},
|
48
58
|
{
|
49
59
|
"name": "constant",
|
60
|
+
"aliases": [
|
61
|
+
"constantize"
|
62
|
+
],
|
50
63
|
"description": "Constant case the characters in the given 'string'",
|
51
64
|
"result": "value converted to constant case",
|
52
65
|
"category": "case",
|
@@ -69,6 +82,12 @@
|
|
69
82
|
},
|
70
83
|
{
|
71
84
|
"name": "dash",
|
85
|
+
"aliases": [
|
86
|
+
"dasherize",
|
87
|
+
"dashify",
|
88
|
+
"dashcase",
|
89
|
+
"hyphenate"
|
90
|
+
],
|
72
91
|
"description": "Dash case the characters in the given 'string'",
|
73
92
|
"result": "value converted to dash case",
|
74
93
|
"category": "case",
|
@@ -91,6 +110,12 @@
|
|
91
110
|
},
|
92
111
|
{
|
93
112
|
"name": "dot",
|
113
|
+
"aliases": [
|
114
|
+
"dotirize",
|
115
|
+
"dotify",
|
116
|
+
"dotcase",
|
117
|
+
"hyphenate"
|
118
|
+
],
|
94
119
|
"description": "Dot case the characters in the given 'string'",
|
95
120
|
"result": "value converted to dot case",
|
96
121
|
"category": "case",
|
@@ -113,6 +138,9 @@
|
|
113
138
|
},
|
114
139
|
{
|
115
140
|
"name": "double_colon",
|
141
|
+
"aliases": [
|
142
|
+
|
143
|
+
],
|
116
144
|
"description": "Double colon case the characters in the given 'string'",
|
117
145
|
"result": "value converted to double_colon case",
|
118
146
|
"category": "case",
|
@@ -135,6 +163,10 @@
|
|
135
163
|
},
|
136
164
|
{
|
137
165
|
"name": "human",
|
166
|
+
"aliases": [
|
167
|
+
"humanize",
|
168
|
+
"sentence"
|
169
|
+
],
|
138
170
|
"description": "Human case the characters in the given 'string'",
|
139
171
|
"result": "value converted to human case",
|
140
172
|
"category": "case",
|
@@ -157,6 +189,11 @@
|
|
157
189
|
},
|
158
190
|
{
|
159
191
|
"name": "lamel",
|
192
|
+
"aliases": [
|
193
|
+
"camel_lower",
|
194
|
+
"camelLower",
|
195
|
+
"camelL"
|
196
|
+
],
|
160
197
|
"description": "Lower camel case the characters in the given 'string'",
|
161
198
|
"result": "value converted to lower camel case",
|
162
199
|
"category": "case",
|
@@ -179,6 +216,10 @@
|
|
179
216
|
},
|
180
217
|
{
|
181
218
|
"name": "lower",
|
219
|
+
"aliases": [
|
220
|
+
"lowercase",
|
221
|
+
"downcase"
|
222
|
+
],
|
182
223
|
"description": "Lower case the characters in the given 'string'",
|
183
224
|
"result": "value converted to lower case",
|
184
225
|
"category": "case",
|
@@ -201,6 +242,10 @@
|
|
201
242
|
},
|
202
243
|
{
|
203
244
|
"name": "slash",
|
245
|
+
"aliases": [
|
246
|
+
"forward_slash",
|
247
|
+
"slash_forward"
|
248
|
+
],
|
204
249
|
"description": "Slash case the characters in the given 'string'",
|
205
250
|
"result": "value converted to slash case",
|
206
251
|
"category": "case",
|
@@ -223,6 +268,9 @@
|
|
223
268
|
},
|
224
269
|
{
|
225
270
|
"name": "snake",
|
271
|
+
"aliases": [
|
272
|
+
|
273
|
+
],
|
226
274
|
"description": "Snake case the characters in the given 'string'",
|
227
275
|
"result": "value converted to snake case",
|
228
276
|
"category": "case",
|
@@ -245,6 +293,9 @@
|
|
245
293
|
},
|
246
294
|
{
|
247
295
|
"name": "title",
|
296
|
+
"aliases": [
|
297
|
+
"titleize"
|
298
|
+
],
|
248
299
|
"description": "Title case the characters in the given 'string'",
|
249
300
|
"result": "value converted to title case",
|
250
301
|
"category": "case",
|
@@ -267,6 +318,10 @@
|
|
267
318
|
},
|
268
319
|
{
|
269
320
|
"name": "upper",
|
321
|
+
"aliases": [
|
322
|
+
"upcase",
|
323
|
+
"uppercase"
|
324
|
+
],
|
270
325
|
"description": "Upper case the characters in the given 'string'",
|
271
326
|
"result": "value converted to upper case",
|
272
327
|
"category": "case",
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"category_key": "misc",
|
3
|
+
"cmdlets": [
|
4
|
+
{
|
5
|
+
"name": "safe",
|
6
|
+
"aliases": [
|
7
|
+
|
8
|
+
],
|
9
|
+
"description": "pass through the value with <> and single and double quotes left as is",
|
10
|
+
"result": "the value with <> and single and double quotes left as is",
|
11
|
+
"category": "misc",
|
12
|
+
"category_description": "Miscellaneous cmdlets",
|
13
|
+
"base_class_require": null,
|
14
|
+
"base_class": null,
|
15
|
+
"parameters": [
|
16
|
+
{
|
17
|
+
"name": "values",
|
18
|
+
"description": "valure to pass throught",
|
19
|
+
"splat": null,
|
20
|
+
"default": null,
|
21
|
+
"param_type": "String|Int"
|
22
|
+
}
|
23
|
+
],
|
24
|
+
"examples": [
|
25
|
+
|
26
|
+
],
|
27
|
+
"ruby": " value = '' if value.nil?\n value\n"
|
28
|
+
}
|
29
|
+
]
|
30
|
+
}
|
@@ -11,6 +11,7 @@ class CategoryDirector < KDirector::Directors::BaseDirector
|
|
11
11
|
|
12
12
|
def generate
|
13
13
|
generate_require_all_cmdlets
|
14
|
+
run_cop
|
14
15
|
|
15
16
|
self
|
16
17
|
end
|
@@ -39,6 +40,22 @@ class CategoryDirector < KDirector::Directors::BaseDirector
|
|
39
40
|
template_file: 'handlebars_helper_require_all.rb',
|
40
41
|
cmdlets: data_access.cmdlet.all_cmdlets)
|
41
42
|
|
43
|
+
add('handlebarsjs/handlebars_configuration_defaults.rb',
|
44
|
+
template_file: 'handlebars_helper_configuration_defaults.rb',
|
45
|
+
cmdlet_categories: data_access.cmdlet.all_cmdlets_by_category)
|
42
46
|
end
|
43
|
-
|
47
|
+
|
48
|
+
def run_cop
|
49
|
+
Dir.chdir(k_builder.target_folders.get(:lib)) do
|
50
|
+
k_builder.run_cop('**/*.rb', fix_unsafe: true)
|
51
|
+
end
|
52
|
+
|
53
|
+
Dir.chdir(k_builder.target_folders.get(:handlebars_lib)) do
|
54
|
+
k_builder.run_cop('**/*.rb', fix_unsafe: true)
|
55
|
+
end
|
56
|
+
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
60
|
+
|
44
61
|
end
|
@@ -11,6 +11,10 @@ class CmdletChild < KDirector::Directors::ChildDirector
|
|
11
11
|
builder.cmdlet_setting(:name, value)
|
12
12
|
end
|
13
13
|
|
14
|
+
def aliases(value)
|
15
|
+
builder.cmdlet_setting(:aliases, value)
|
16
|
+
end
|
17
|
+
|
14
18
|
def description(value)
|
15
19
|
builder.cmdlet_setting(:description, value)
|
16
20
|
end
|
@@ -16,6 +16,11 @@ class CmdletDao
|
|
16
16
|
.sort_by { |r| [r[:category], r[:name]] }
|
17
17
|
end
|
18
18
|
|
19
|
+
def all_cmdlets_by_category
|
20
|
+
grouped_categories = all_cmdlets.group_by { |cmdlet| cmdlet[:category] }
|
21
|
+
grouped_categories.keys.map { |category_key| { category: category_key, cmdlets: grouped_categories[category_key] } }
|
22
|
+
end
|
23
|
+
|
19
24
|
private
|
20
25
|
|
21
26
|
def read_cmdlets(category_name)
|
@@ -48,16 +48,6 @@ 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
|
-
add(handlebars_category_configuration_file, template_file: 'handlebars_helper_default_configuration.rb', cmdlets: builder.cmdlets)
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
51
|
self
|
62
52
|
end
|
63
53
|
|
@@ -4,12 +4,11 @@ KManager.action :categories do
|
|
4
4
|
action do
|
5
5
|
CategoryDirector
|
6
6
|
.init(k_builder)
|
7
|
+
.category(:array , 'Array handling routines, eg. join, join_prefix, join_post')
|
7
8
|
.category(:case , 'Tokenize and apply case and/or separator')
|
8
9
|
.category(:comparison , 'Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.')
|
9
10
|
.category(:inflection , 'Inflection handling routines, eg. pluralize, singular, ordinalize')
|
10
|
-
.category(:
|
11
|
-
.category(:array , 'Array handling routines, eg. join, join_prefix, join_post')
|
12
|
-
.category(:transform , 'Tokenize and apply case and/or separator')
|
11
|
+
.category(:misc , 'Miscellaneous cmdlets')
|
13
12
|
.save_categories
|
14
13
|
.generate
|
15
14
|
end
|
@@ -6,6 +6,7 @@ KManager.action :case_commands do
|
|
6
6
|
.init(k_builder, category: :case)
|
7
7
|
.cmdlet do
|
8
8
|
name :back_slash
|
9
|
+
aliases %i[backward_slash slash_backward]
|
9
10
|
description 'Convert to back slash notation'
|
10
11
|
result 'value converted to back_slash case'
|
11
12
|
|
@@ -17,6 +18,7 @@ KManager.action :case_commands do
|
|
17
18
|
end
|
18
19
|
.cmdlet do
|
19
20
|
name :camel
|
21
|
+
aliases %i[camel_upper camelUpper camelU pascalcase]
|
20
22
|
description "Camel case the characters in the given 'string'"
|
21
23
|
result 'value converted to camel case'
|
22
24
|
|
@@ -28,6 +30,7 @@ KManager.action :case_commands do
|
|
28
30
|
end
|
29
31
|
.cmdlet do
|
30
32
|
name :constant
|
33
|
+
aliases %i[constantize]
|
31
34
|
description "Constant case the characters in the given 'string'"
|
32
35
|
result 'value converted to constant case'
|
33
36
|
|
@@ -39,6 +42,7 @@ KManager.action :case_commands do
|
|
39
42
|
end
|
40
43
|
.cmdlet do
|
41
44
|
name :dash
|
45
|
+
aliases %i[dasherize dashify dashcase hyphenate]
|
42
46
|
description "Dash case the characters in the given 'string'"
|
43
47
|
result 'value converted to dash case'
|
44
48
|
|
@@ -50,6 +54,7 @@ KManager.action :case_commands do
|
|
50
54
|
end
|
51
55
|
.cmdlet do
|
52
56
|
name :dot
|
57
|
+
aliases %i[dotirize dotify dotcase hyphenate]
|
53
58
|
description "Dot case the characters in the given 'string'"
|
54
59
|
result 'value converted to dot case'
|
55
60
|
|
@@ -72,6 +77,7 @@ KManager.action :case_commands do
|
|
72
77
|
end
|
73
78
|
.cmdlet do
|
74
79
|
name :human
|
80
|
+
aliases %i[humanize sentence]
|
75
81
|
description "Human case the characters in the given 'string'"
|
76
82
|
result 'value converted to human case'
|
77
83
|
|
@@ -87,6 +93,7 @@ KManager.action :case_commands do
|
|
87
93
|
end
|
88
94
|
.cmdlet do
|
89
95
|
name :lamel
|
96
|
+
aliases %i[camel_lower camelLower camelL]
|
90
97
|
description "Lower camel case the characters in the given 'string'"
|
91
98
|
result 'value converted to lower camel case'
|
92
99
|
|
@@ -98,6 +105,7 @@ KManager.action :case_commands do
|
|
98
105
|
end
|
99
106
|
.cmdlet do
|
100
107
|
name :lower
|
108
|
+
aliases %i[lowercase downcase]
|
101
109
|
description "Lower case the characters in the given 'string'"
|
102
110
|
result 'value converted to lower case'
|
103
111
|
|
@@ -111,6 +119,7 @@ KManager.action :case_commands do
|
|
111
119
|
end
|
112
120
|
.cmdlet do
|
113
121
|
name :slash
|
122
|
+
aliases %i[forward_slash slash_forward]
|
114
123
|
description "Slash case the characters in the given 'string'"
|
115
124
|
result 'value converted to slash case'
|
116
125
|
|
@@ -133,6 +142,7 @@ KManager.action :case_commands do
|
|
133
142
|
end
|
134
143
|
.cmdlet do
|
135
144
|
name :title
|
145
|
+
aliases %i[titleize]
|
136
146
|
description "Title case the characters in the given 'string'"
|
137
147
|
result 'value converted to title case'
|
138
148
|
|
@@ -149,6 +159,7 @@ KManager.action :case_commands do
|
|
149
159
|
end
|
150
160
|
.cmdlet do
|
151
161
|
name :upper
|
162
|
+
aliases %i[upcase uppercase]
|
152
163
|
description "Upper case the characters in the given 'string'"
|
153
164
|
result 'value converted to upper case'
|
154
165
|
|
@@ -6,6 +6,7 @@ KManager.action :comparison_commands do
|
|
6
6
|
.init(k_builder, category: :comparison)
|
7
7
|
.cmdlet do
|
8
8
|
name :and
|
9
|
+
aliases %i[all]
|
9
10
|
description 'Return true if **all of** the given values are truthy.'
|
10
11
|
result 'return true when every value is truthy'
|
11
12
|
|
@@ -33,6 +34,7 @@ KManager.action :comparison_commands do
|
|
33
34
|
end
|
34
35
|
.cmdlet do
|
35
36
|
name :eq
|
37
|
+
aliases %i[equal]
|
36
38
|
description 'Return true if two values are equal'
|
37
39
|
result 'return truthy value if left hand side equals right hand side'
|
38
40
|
|
@@ -48,6 +50,7 @@ KManager.action :comparison_commands do
|
|
48
50
|
end
|
49
51
|
.cmdlet do
|
50
52
|
name :gt
|
53
|
+
aliases %i[greater_than]
|
51
54
|
description 'Return true if left hand side GREATER THAN right hand side'
|
52
55
|
result 'truthy value if left hand side GREATER THAN right hand side'
|
53
56
|
|
@@ -60,6 +63,7 @@ KManager.action :comparison_commands do
|
|
60
63
|
end
|
61
64
|
.cmdlet do
|
62
65
|
name :gte
|
66
|
+
aliases %i[greater_than_or_equal_to]
|
63
67
|
description 'Return true if left hand side GREATER THAN or EQUAL TO right hand side'
|
64
68
|
result 'truthy value if left hand side GREATER THAN or EQUAL TO right hand side'
|
65
69
|
|
@@ -72,6 +76,7 @@ KManager.action :comparison_commands do
|
|
72
76
|
end
|
73
77
|
.cmdlet do
|
74
78
|
name :lt
|
79
|
+
aliases %i[less_than]
|
75
80
|
description 'Return true if left hand side LESS THAN right hand side'
|
76
81
|
result 'truthy value if left hand side LESS THAN right hand side'
|
77
82
|
|
@@ -84,6 +89,7 @@ KManager.action :comparison_commands do
|
|
84
89
|
end
|
85
90
|
.cmdlet do
|
86
91
|
name :lte
|
92
|
+
aliases %i[less_than_or_equal_to]
|
87
93
|
description 'Return true if left hand side LESS THAN or EQUAL TO right hand side'
|
88
94
|
result 'truthy value if left hand side LESS THAN or EQUAL TO right hand side'
|
89
95
|
|
@@ -96,6 +102,7 @@ KManager.action :comparison_commands do
|
|
96
102
|
end
|
97
103
|
.cmdlet do
|
98
104
|
name :ne
|
105
|
+
aliases %i[not_equal]
|
99
106
|
description 'Return true if left hand side is NOT equal to right hand side'
|
100
107
|
result 'truthy value if left hand side is NOT equal to right hand side'
|
101
108
|
|
@@ -111,6 +118,7 @@ KManager.action :comparison_commands do
|
|
111
118
|
end
|
112
119
|
.cmdlet do
|
113
120
|
name :or
|
121
|
+
aliases %i[any]
|
114
122
|
description 'Return true if any value is truthy.'
|
115
123
|
result 'return true when first value is truthy'
|
116
124
|
|
@@ -36,6 +36,7 @@ KManager.action :inflection_commands do
|
|
36
36
|
end
|
37
37
|
.cmdlet do
|
38
38
|
name :pluralize
|
39
|
+
aliases %i[plural]
|
39
40
|
description 'Returns the plural form of the word in the string'
|
40
41
|
result 'value in plural form'
|
41
42
|
|
@@ -83,6 +84,7 @@ KManager.action :inflection_commands do
|
|
83
84
|
end
|
84
85
|
.cmdlet do
|
85
86
|
name :singularize
|
87
|
+
aliases %i[singular]
|
86
88
|
description 'The reverse of #pluralize, returns the singular form of a word in a string'
|
87
89
|
result 'plural value turned to singular value'
|
88
90
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
KManager.action :misc_commands do
|
4
|
+
action do
|
5
|
+
CmdletDirector
|
6
|
+
.init(k_builder, category: :misc)
|
7
|
+
.cmdlet do
|
8
|
+
name :safe
|
9
|
+
description 'pass through the value with <> and single and double quotes left as is'
|
10
|
+
result 'the value with <> and single and double quotes left as is'
|
11
|
+
|
12
|
+
parameter :values, 'valure to pass throught', param_type: 'String|Int'
|
13
|
+
|
14
|
+
ruby <<-RUBY
|
15
|
+
value = '' if value.nil?
|
16
|
+
value
|
17
|
+
RUBY
|
18
|
+
end
|
19
|
+
.generate
|
20
|
+
# .debug
|
21
|
+
end
|
22
|
+
end
|
data/.rubocop.yml
CHANGED
@@ -41,7 +41,7 @@ Metrics/MethodLength:
|
|
41
41
|
Layout/LineLength:
|
42
42
|
Max: 200
|
43
43
|
# Ignores annotate output
|
44
|
-
|
44
|
+
AllowedPatterns: ['\A# \*\*'] # this is renamed to AllowedPatterns and I need to come up with a template for this
|
45
45
|
IgnoreCopDirectives: true
|
46
46
|
|
47
47
|
Lint/UnusedMethodArgument:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## [0.7.1](https://github.com/klueless-io/cmdlet/compare/v0.7.0...v0.7.1) (2022-07-15)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* add alias support ([c26a092](https://github.com/klueless-io/cmdlet/commit/c26a092d2c5fdf49ae6b1ebb017f4a6e4399a499))
|
7
|
+
|
8
|
+
# [0.7.0](https://github.com/klueless-io/cmdlet/compare/v0.6.2...v0.7.0) (2022-07-14)
|
9
|
+
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
* bump activesupport gem version ([4833f48](https://github.com/klueless-io/cmdlet/commit/4833f484411a3c308b1682489c591f45d88bee88))
|
14
|
+
|
15
|
+
## [0.6.2](https://github.com/klueless-io/cmdlet/compare/v0.6.1...v0.6.2) (2022-07-13)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* remove alias :parse, :call ([375deb4](https://github.com/klueless-io/cmdlet/commit/375deb4a69f40e56265abaed9b52dd552e7235ef))
|
21
|
+
|
1
22
|
## [0.6.1](https://github.com/klueless-io/cmdlet/compare/v0.6.0...v0.6.1) (2022-07-13)
|
2
23
|
|
3
24
|
|
data/lib/cmdlet/_.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Miscellaneous cmdlets
|
5
|
+
module Misc
|
6
|
+
# Safe: pass through the value with <> and single and double quotes left as is
|
7
|
+
class Safe < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [String|Int] values - valure to pass throught
|
10
|
+
# @return [String] the value with <> and single and double quotes left as is
|
11
|
+
def call(_values)
|
12
|
+
value = '' if value.nil?
|
13
|
+
value
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
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.8.0",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "cmdlet",
|
9
|
-
"version": "0.
|
9
|
+
"version": "0.8.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.8.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-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: k_config
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,7 +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/
|
54
|
+
- ".builders/.templates/handlebars_helper_configuration_defaults.rb"
|
55
55
|
- ".builders/.templates/handlebars_helper_require_all.rb"
|
56
56
|
- ".builders/.templates/handlebars_helper_spec.rb"
|
57
57
|
- ".builders/_.rb"
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- ".builders/data/cmdlets/case.json"
|
62
62
|
- ".builders/data/cmdlets/comparison.json"
|
63
63
|
- ".builders/data/cmdlets/inflection.json"
|
64
|
+
- ".builders/data/cmdlets/misc.json"
|
64
65
|
- ".builders/director/category_builder.rb"
|
65
66
|
- ".builders/director/category_dao.rb"
|
66
67
|
- ".builders/director/category_director.rb"
|
@@ -73,11 +74,11 @@ files:
|
|
73
74
|
- ".builders/documents/x_functions.rb"
|
74
75
|
- ".builders/generators/01-bootstrap.rb"
|
75
76
|
- ".builders/generators/20-categories.rb"
|
76
|
-
- ".builders/generators/30-commands-bak.rb"
|
77
77
|
- ".builders/generators/cmdlets/array.rb"
|
78
78
|
- ".builders/generators/cmdlets/case.rb"
|
79
79
|
- ".builders/generators/cmdlets/comparison.rb"
|
80
80
|
- ".builders/generators/cmdlets/inflection.rb"
|
81
|
+
- ".builders/generators/cmdlets/misc.rb"
|
81
82
|
- ".releaserc.json"
|
82
83
|
- ".rspec"
|
83
84
|
- ".rubocop.yml"
|
@@ -126,6 +127,7 @@ files:
|
|
126
127
|
- lib/cmdlet/inflection/pluralize_number.rb
|
127
128
|
- lib/cmdlet/inflection/pluralize_number_word.rb
|
128
129
|
- lib/cmdlet/inflection/singularize.rb
|
130
|
+
- lib/cmdlet/misc/safe.rb
|
129
131
|
- lib/cmdlet/string_tokenizer.rb
|
130
132
|
- lib/cmdlet/version.rb
|
131
133
|
- package-lock.json
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
KManager.action :commands_bak do
|
4
|
-
action do
|
5
|
-
puts commands.first.function_description
|
6
|
-
# Ruby Gem Bootstrap
|
7
|
-
director = KDirector::Dsls::BasicDsl
|
8
|
-
.init(k_builder,
|
9
|
-
template_base_folder: '',
|
10
|
-
on_exist: :skip, # %i[skip write compare]
|
11
|
-
on_action: :queue # %i[queue execute]
|
12
|
-
)
|
13
|
-
.blueprint(
|
14
|
-
active: true,
|
15
|
-
name: :build_commands,
|
16
|
-
description: 'Build Commandlets',
|
17
|
-
on_exist: :write
|
18
|
-
) do
|
19
|
-
cd(:lib)
|
20
|
-
|
21
|
-
# builder
|
22
|
-
# .add_file('FUNCTIONS.md',
|
23
|
-
# template_file: 'FUNCTIONS.md',
|
24
|
-
# categories: categories.sort_by { |r| r.name },
|
25
|
-
# functions: functions.sort_by { |r| [r.category, r.name] },
|
26
|
-
# on_exist: :write)
|
27
|
-
|
28
|
-
add('all_commands.rb',
|
29
|
-
template_file: 'all_commands.rb',
|
30
|
-
commands: commands.sort_by { |r| [r.category, r.name] },
|
31
|
-
on_exist: :write)
|
32
|
-
|
33
|
-
cmdlets.each do |cmdlet|
|
34
|
-
add("#{cmdlet.category}/#{cmdlet.name}.rb",
|
35
|
-
cmdlet: cmdlet,
|
36
|
-
template_file: 'command.rb',
|
37
|
-
on_exist: :write)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
director.play_actions
|
42
|
-
# director.builder.logit
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
KManager.opts.app_name = 'commands'
|
47
|
-
KManager.opts.sleep = 2
|
48
|
-
KManager.opts.reboot_on_kill = 0
|
49
|
-
KManager.opts.reboot_sleep = 4
|
50
|
-
KManager.opts.exception_style = :short
|
51
|
-
KManager.opts.show.time_taken = true
|
52
|
-
KManager.opts.show.finished = true
|
53
|
-
KManager.opts.show.finished_message = 'FINISHED :)'
|