cmdlet 0.1.2 → 0.3.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/{require_all_cmdlets.rb → cmdlets_require_all.rb} +0 -0
- data/.builders/.templates/handlebars_helper.rb +17 -0
- data/.builders/.templates/handlebars_helper_require_all.rb +5 -0
- data/.builders/.templates/handlebars_helper_spec.rb +26 -0
- data/.builders/boot.rb +4 -0
- data/.builders/data/cmdlets/case.json +313 -0
- data/.builders/data/cmdlets/inflection.json +129 -0
- data/.builders/director/category_director.rb +6 -1
- data/.builders/director/cmdlet_director.rb +8 -0
- data/.builders/generators/cmdlets/array.rb +0 -38
- data/.builders/generators/cmdlets/case.rb +184 -0
- data/.builders/generators/cmdlets/comparison.rb +1 -39
- data/.builders/generators/cmdlets/inflection.rb +93 -0
- data/CHANGELOG.md +22 -0
- data/lib/cmdlet/_.rb +19 -0
- data/lib/cmdlet/base_cmdlet.rb +1 -1
- data/lib/cmdlet/case/back_slash.rb +16 -0
- data/lib/cmdlet/case/camel.rb +16 -0
- data/lib/cmdlet/case/constant.rb +16 -0
- data/lib/cmdlet/case/dash.rb +16 -0
- data/lib/cmdlet/case/dot.rb +16 -0
- data/lib/cmdlet/case/double_colon.rb +16 -0
- data/lib/cmdlet/case/human.rb +20 -0
- data/lib/cmdlet/case/lamel.rb +16 -0
- data/lib/cmdlet/case/lower.rb +18 -0
- data/lib/cmdlet/case/sentence.rb +20 -0
- data/lib/cmdlet/case/slash.rb +16 -0
- data/lib/cmdlet/case/snake.rb +16 -0
- data/lib/cmdlet/case/title.rb +21 -0
- data/lib/cmdlet/case/upper.rb +18 -0
- data/lib/cmdlet/inflection/ordinal.rb +20 -0
- data/lib/cmdlet/inflection/ordinalize.rb +20 -0
- data/lib/cmdlet/inflection/pluralize.rb +20 -0
- data/lib/cmdlet/inflection/pluralize_by_number.rb +28 -0
- data/lib/cmdlet/inflection/singularize.rb +20 -0
- data/lib/cmdlet/version.rb +1 -1
- data/lib/cmdlet.rb +2 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +29 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49c3beb9fd9aff2b68b44e39e8fcda09b7d54c28413f5295d9bb797c674cf357
|
4
|
+
data.tar.gz: 0c3ecef6805fa262aa2869a5375791ba1ff6db080748519977d5c24509d5159d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7785377593e33ed05090b16277252be0ca0f8893fdcda9a70b6a996b2c77d5e8f2dac2b36f952632a11293630f6db697cad854b8edea2104870edcea7af8646c
|
7
|
+
data.tar.gz: 6f9183a77a87c437dd6dbcdac568075fb05b184be5f6970ff7205df4b209a1201272870224a3b458f2017c93f175d987f429150fa98acc223c2a8dbfd19f7600
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Handlebarsjs
|
4
|
+
module Helpers
|
5
|
+
# {{cmdlet.category_description}}
|
6
|
+
module {{camel cmdlet.category}}
|
7
|
+
# {{camel cmdlet.name}}: {{cmdlet.description}}
|
8
|
+
class {{camel cmdlet.name}} < Handlebarsjs::BaseHelper
|
9
|
+
register_cmdlet(Cmdlet::{{camel cmdlet.category}}::{{camel cmdlet.name}})
|
10
|
+
|
11
|
+
def to_proc
|
12
|
+
->({{#each cmdlet.parameters}}{{#if ./splat}}{{./splat}}{{/if}}{{./name}}{{#if @last}}{{^}}, {{/if}}{{/each}}, _opts) { wrapper(cmdlet.call({{#each cmdlet.parameters}}{{#if ./splat}}{{./splat}}{{/if}}{{./name}}{{#if @last}}{{^}}, {{/if}}{{/each}})) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# {{camel cmdlet.name}}: {{cmdlet.description}}
|
4
|
+
RSpec.describe Handlebarsjs::Helpers::{{camel cmdlet.category}}::{{camel cmdlet.name}} do
|
5
|
+
let(:helper_name) { :{{cmdlet.name}} }
|
6
|
+
let(:helper) { described_class.new }
|
7
|
+
let(:handlebars) { Handlebarsjs::Handlebars.new }
|
8
|
+
|
9
|
+
before { handlebars.handlebars_snapshot.add_helper(helper_name, helper) }
|
10
|
+
|
11
|
+
describe '#process_template' do
|
12
|
+
subject { handlebars.process_template(template, data).squish }
|
13
|
+
|
14
|
+
let(:lhs) { nil }
|
15
|
+
let(:rhs) { nil }
|
16
|
+
let(:data) { { lhs: lhs, rhs: rhs } }
|
17
|
+
|
18
|
+
let(:template) do
|
19
|
+
<<~TEXT.chomp
|
20
|
+
{{#if (and lhs rhs)}}
|
21
|
+
{{^}}
|
22
|
+
{{/if}}
|
23
|
+
TEXT
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/.builders/boot.rb
CHANGED
@@ -46,6 +46,7 @@ KConfig.configure(CONFIG_KEY) do |config|
|
|
46
46
|
builder_folder = Dir.pwd
|
47
47
|
base_folder = File.expand_path('../', builder_folder)
|
48
48
|
global_template = File.expand_path('~/dev/kgems/k_templates/templates')
|
49
|
+
handlebars_folder = File.expand_path('~/dev/kgems/handlebarsjs/')
|
49
50
|
|
50
51
|
config.template_folders.add(:global_template , global_template)
|
51
52
|
config.template_folders.add(:template , File.expand_path('.templates', Dir.pwd))
|
@@ -55,6 +56,9 @@ KConfig.configure(CONFIG_KEY) do |config|
|
|
55
56
|
config.target_folders.add(:spec , :app, 'spec/cmdlet')
|
56
57
|
config.target_folders.add(:builder , builder_folder)
|
57
58
|
config.target_folders.add(:builder_data , :builder, 'data')
|
59
|
+
config.target_folders.add(:handlebars , handlebars_folder)
|
60
|
+
config.target_folders.add(:handlebars_lib , :handlebars, 'lib')
|
61
|
+
config.target_folders.add(:handlebars_spec , :handlebars, 'spec')
|
58
62
|
end
|
59
63
|
|
60
64
|
KConfig.configuration(CONFIG_KEY).debug
|
@@ -0,0 +1,313 @@
|
|
1
|
+
{
|
2
|
+
"category_key": "case",
|
3
|
+
"cmdlets": [
|
4
|
+
{
|
5
|
+
"name": "back_slash",
|
6
|
+
"description": "Convert to back slash notation",
|
7
|
+
"result": "value converted to back_slash case",
|
8
|
+
"category": "case",
|
9
|
+
"category_description": "Tokenize and apply case and/or separator",
|
10
|
+
"base_class_require": null,
|
11
|
+
"base_class": null,
|
12
|
+
"parameters": [
|
13
|
+
{
|
14
|
+
"name": "value",
|
15
|
+
"description": "value - to be converted",
|
16
|
+
"splat": null,
|
17
|
+
"default": null,
|
18
|
+
"param_type": "String|Int"
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"examples": [
|
22
|
+
|
23
|
+
],
|
24
|
+
"ruby": " tokenizer.parse(value, preserve_case: true, separator: '\\\\')\n"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "camel",
|
28
|
+
"description": "Camel case the characters in the given 'string'",
|
29
|
+
"result": "value converted to camel case",
|
30
|
+
"category": "case",
|
31
|
+
"category_description": "Tokenize and apply case and/or separator",
|
32
|
+
"base_class_require": null,
|
33
|
+
"base_class": null,
|
34
|
+
"parameters": [
|
35
|
+
{
|
36
|
+
"name": "value",
|
37
|
+
"description": "value - to be converted",
|
38
|
+
"splat": null,
|
39
|
+
"default": null,
|
40
|
+
"param_type": "String|Int"
|
41
|
+
}
|
42
|
+
],
|
43
|
+
"examples": [
|
44
|
+
|
45
|
+
],
|
46
|
+
"ruby": " tokenizer.parse(value).underscore.camelize\n"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"name": "constant",
|
50
|
+
"description": "Constant case the characters in the given 'string'",
|
51
|
+
"result": "value converted to constant case",
|
52
|
+
"category": "case",
|
53
|
+
"category_description": "Tokenize and apply case and/or separator",
|
54
|
+
"base_class_require": null,
|
55
|
+
"base_class": null,
|
56
|
+
"parameters": [
|
57
|
+
{
|
58
|
+
"name": "value",
|
59
|
+
"description": "value - to be converted",
|
60
|
+
"splat": null,
|
61
|
+
"default": null,
|
62
|
+
"param_type": "String|Int"
|
63
|
+
}
|
64
|
+
],
|
65
|
+
"examples": [
|
66
|
+
|
67
|
+
],
|
68
|
+
"ruby": " tokenizer.parse(value, separator: '_').upcase\n"
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"name": "dash",
|
72
|
+
"description": "Dash case the characters in the given 'string'",
|
73
|
+
"result": "value converted to dash case",
|
74
|
+
"category": "case",
|
75
|
+
"category_description": "Tokenize and apply case and/or separator",
|
76
|
+
"base_class_require": null,
|
77
|
+
"base_class": null,
|
78
|
+
"parameters": [
|
79
|
+
{
|
80
|
+
"name": "value",
|
81
|
+
"description": "value - to be converted",
|
82
|
+
"splat": null,
|
83
|
+
"default": null,
|
84
|
+
"param_type": "String|Int"
|
85
|
+
}
|
86
|
+
],
|
87
|
+
"examples": [
|
88
|
+
|
89
|
+
],
|
90
|
+
"ruby": " tokenizer.parse(value)\n"
|
91
|
+
},
|
92
|
+
{
|
93
|
+
"name": "dot",
|
94
|
+
"description": "Dot case the characters in the given 'string'",
|
95
|
+
"result": "value converted to dot case",
|
96
|
+
"category": "case",
|
97
|
+
"category_description": "Tokenize and apply case and/or separator",
|
98
|
+
"base_class_require": null,
|
99
|
+
"base_class": null,
|
100
|
+
"parameters": [
|
101
|
+
{
|
102
|
+
"name": "value",
|
103
|
+
"description": "value - to be converted",
|
104
|
+
"splat": null,
|
105
|
+
"default": null,
|
106
|
+
"param_type": "String|Int"
|
107
|
+
}
|
108
|
+
],
|
109
|
+
"examples": [
|
110
|
+
|
111
|
+
],
|
112
|
+
"ruby": " tokenizer.parse(value, separator: '.')\n"
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"name": "double_colon",
|
116
|
+
"description": "Double colon case the characters in the given 'string'",
|
117
|
+
"result": "value converted to double_colon case",
|
118
|
+
"category": "case",
|
119
|
+
"category_description": "Tokenize and apply case and/or separator",
|
120
|
+
"base_class_require": null,
|
121
|
+
"base_class": null,
|
122
|
+
"parameters": [
|
123
|
+
{
|
124
|
+
"name": "value",
|
125
|
+
"description": "value - to be converted",
|
126
|
+
"splat": null,
|
127
|
+
"default": null,
|
128
|
+
"param_type": "String|Int"
|
129
|
+
}
|
130
|
+
],
|
131
|
+
"examples": [
|
132
|
+
|
133
|
+
],
|
134
|
+
"ruby": " tokenizer.parse(value, preserve_case: true, separator: '::')\n"
|
135
|
+
},
|
136
|
+
{
|
137
|
+
"name": "human",
|
138
|
+
"description": "Human case the characters in the given 'string'",
|
139
|
+
"result": "value converted to human case",
|
140
|
+
"category": "case",
|
141
|
+
"category_description": "Tokenize and apply case and/or separator",
|
142
|
+
"base_class_require": null,
|
143
|
+
"base_class": null,
|
144
|
+
"parameters": [
|
145
|
+
{
|
146
|
+
"name": "value",
|
147
|
+
"description": "value - to be converted",
|
148
|
+
"splat": null,
|
149
|
+
"default": null,
|
150
|
+
"param_type": "String|Int"
|
151
|
+
}
|
152
|
+
],
|
153
|
+
"examples": [
|
154
|
+
|
155
|
+
],
|
156
|
+
"ruby": " tokenizer.parse(value,\n separator: ' ',\n preserve_case: true,\n compress_prefix_numerals: false,\n compress_suffix_numerals: false).humanize\n"
|
157
|
+
},
|
158
|
+
{
|
159
|
+
"name": "lamel",
|
160
|
+
"description": "Lower camel case the characters in the given 'string'",
|
161
|
+
"result": "value converted to lower camel case",
|
162
|
+
"category": "case",
|
163
|
+
"category_description": "Tokenize and apply case and/or separator",
|
164
|
+
"base_class_require": null,
|
165
|
+
"base_class": null,
|
166
|
+
"parameters": [
|
167
|
+
{
|
168
|
+
"name": "value",
|
169
|
+
"description": "value - to be converted",
|
170
|
+
"splat": null,
|
171
|
+
"default": null,
|
172
|
+
"param_type": "String|Int"
|
173
|
+
}
|
174
|
+
],
|
175
|
+
"examples": [
|
176
|
+
|
177
|
+
],
|
178
|
+
"ruby": " tokenizer.parse(value, separator: '_').camelize(:lower)\n"
|
179
|
+
},
|
180
|
+
{
|
181
|
+
"name": "lower",
|
182
|
+
"description": "Lower case the characters in the given 'string'",
|
183
|
+
"result": "value converted to lower case",
|
184
|
+
"category": "case",
|
185
|
+
"category_description": "Tokenize and apply case and/or separator",
|
186
|
+
"base_class_require": null,
|
187
|
+
"base_class": null,
|
188
|
+
"parameters": [
|
189
|
+
{
|
190
|
+
"name": "value",
|
191
|
+
"description": "value - to be converted",
|
192
|
+
"splat": null,
|
193
|
+
"default": null,
|
194
|
+
"param_type": "String|Int"
|
195
|
+
}
|
196
|
+
],
|
197
|
+
"examples": [
|
198
|
+
|
199
|
+
],
|
200
|
+
"ruby": " return '' if value.nil?\n\n value.downcase\n"
|
201
|
+
},
|
202
|
+
{
|
203
|
+
"name": "sentence",
|
204
|
+
"description": "Sentence case the characters in the given 'string'",
|
205
|
+
"result": "value converted to sentence case",
|
206
|
+
"category": "case",
|
207
|
+
"category_description": "Tokenize and apply case and/or separator",
|
208
|
+
"base_class_require": null,
|
209
|
+
"base_class": null,
|
210
|
+
"parameters": [
|
211
|
+
{
|
212
|
+
"name": "value",
|
213
|
+
"description": "value - to be converted",
|
214
|
+
"splat": null,
|
215
|
+
"default": null,
|
216
|
+
"param_type": "String|Int"
|
217
|
+
}
|
218
|
+
],
|
219
|
+
"examples": [
|
220
|
+
|
221
|
+
],
|
222
|
+
"ruby": " tokenizer.parse(value,\n separator: ' ',\n preserve_case: true,\n compress_prefix_numerals: false,\n compress_suffix_numerals: false).titleize\n"
|
223
|
+
},
|
224
|
+
{
|
225
|
+
"name": "slash",
|
226
|
+
"description": "Slash case the characters in the given 'string'",
|
227
|
+
"result": "value converted to slash case",
|
228
|
+
"category": "case",
|
229
|
+
"category_description": "Tokenize and apply case and/or separator",
|
230
|
+
"base_class_require": null,
|
231
|
+
"base_class": null,
|
232
|
+
"parameters": [
|
233
|
+
{
|
234
|
+
"name": "value",
|
235
|
+
"description": "value - to be converted",
|
236
|
+
"splat": null,
|
237
|
+
"default": null,
|
238
|
+
"param_type": "String|Int"
|
239
|
+
}
|
240
|
+
],
|
241
|
+
"examples": [
|
242
|
+
|
243
|
+
],
|
244
|
+
"ruby": " tokenizer.parse(value, preserve_case: true, separator: '/')\n"
|
245
|
+
},
|
246
|
+
{
|
247
|
+
"name": "snake",
|
248
|
+
"description": "Snake case the characters in the given 'string'",
|
249
|
+
"result": "value converted to snake case",
|
250
|
+
"category": "case",
|
251
|
+
"category_description": "Tokenize and apply case and/or separator",
|
252
|
+
"base_class_require": null,
|
253
|
+
"base_class": null,
|
254
|
+
"parameters": [
|
255
|
+
{
|
256
|
+
"name": "value",
|
257
|
+
"description": "value - to be converted",
|
258
|
+
"splat": null,
|
259
|
+
"default": null,
|
260
|
+
"param_type": "String|Int"
|
261
|
+
}
|
262
|
+
],
|
263
|
+
"examples": [
|
264
|
+
|
265
|
+
],
|
266
|
+
"ruby": " tokenizer.parse(value, separator: '_', forced_separator: true)\n"
|
267
|
+
},
|
268
|
+
{
|
269
|
+
"name": "title",
|
270
|
+
"description": "Title case the characters in the given 'string'",
|
271
|
+
"result": "value converted to title case",
|
272
|
+
"category": "case",
|
273
|
+
"category_description": "Tokenize and apply case and/or separator",
|
274
|
+
"base_class_require": null,
|
275
|
+
"base_class": null,
|
276
|
+
"parameters": [
|
277
|
+
{
|
278
|
+
"name": "value",
|
279
|
+
"description": "value - to be converted",
|
280
|
+
"splat": null,
|
281
|
+
"default": null,
|
282
|
+
"param_type": "String|Int"
|
283
|
+
}
|
284
|
+
],
|
285
|
+
"examples": [
|
286
|
+
|
287
|
+
],
|
288
|
+
"ruby": " tokenizer.parse(value,\n separator: ' ',\n preserve_case: true,\n compress_prefix_numerals: false,\n compress_suffix_numerals: false)\n .titleize\n"
|
289
|
+
},
|
290
|
+
{
|
291
|
+
"name": "upper",
|
292
|
+
"description": "Upper case the characters in the given 'string'",
|
293
|
+
"result": "value converted to upper case",
|
294
|
+
"category": "case",
|
295
|
+
"category_description": "Tokenize and apply case and/or separator",
|
296
|
+
"base_class_require": null,
|
297
|
+
"base_class": null,
|
298
|
+
"parameters": [
|
299
|
+
{
|
300
|
+
"name": "value",
|
301
|
+
"description": "value - to be converted",
|
302
|
+
"splat": null,
|
303
|
+
"default": null,
|
304
|
+
"param_type": "String|Int"
|
305
|
+
}
|
306
|
+
],
|
307
|
+
"examples": [
|
308
|
+
|
309
|
+
],
|
310
|
+
"ruby": " return '' if value.nil?\n\n value.upcase\n"
|
311
|
+
}
|
312
|
+
]
|
313
|
+
}
|
@@ -0,0 +1,129 @@
|
|
1
|
+
{
|
2
|
+
"category_key": "inflection",
|
3
|
+
"cmdlets": [
|
4
|
+
{
|
5
|
+
"name": "ordinal",
|
6
|
+
"description": "The suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th",
|
7
|
+
"result": "ordinal suffix that would be required for a number",
|
8
|
+
"category": "inflection",
|
9
|
+
"category_description": "Inflection handling routines, eg. pluralize, singular, ordinalize",
|
10
|
+
"base_class_require": null,
|
11
|
+
"base_class": null,
|
12
|
+
"parameters": [
|
13
|
+
{
|
14
|
+
"name": "value",
|
15
|
+
"description": "value - numeric value",
|
16
|
+
"splat": null,
|
17
|
+
"default": null,
|
18
|
+
"param_type": "String|Int"
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"examples": [
|
22
|
+
|
23
|
+
],
|
24
|
+
"ruby": " return '' if value.nil?\n\n value = value.to_i if value.is_a? String\n\n value.ordinal\n"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "ordinalize",
|
28
|
+
"description": "Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.",
|
29
|
+
"result": "number value turned to 1st, 2nd, 3rd, 4th etc.",
|
30
|
+
"category": "inflection",
|
31
|
+
"category_description": "Inflection handling routines, eg. pluralize, singular, ordinalize",
|
32
|
+
"base_class_require": null,
|
33
|
+
"base_class": null,
|
34
|
+
"parameters": [
|
35
|
+
{
|
36
|
+
"name": "value",
|
37
|
+
"description": "value - numeric value",
|
38
|
+
"splat": null,
|
39
|
+
"default": null,
|
40
|
+
"param_type": "Int"
|
41
|
+
}
|
42
|
+
],
|
43
|
+
"examples": [
|
44
|
+
|
45
|
+
],
|
46
|
+
"ruby": " return '' if value.nil?\n\n value = value.to_i if value.is_a? String\n\n value.ordinalize\n"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"name": "pluralize",
|
50
|
+
"description": "Returns the plural form of the word in the string",
|
51
|
+
"result": "value in plural form",
|
52
|
+
"category": "inflection",
|
53
|
+
"category_description": "Inflection handling routines, eg. pluralize, singular, ordinalize",
|
54
|
+
"base_class_require": null,
|
55
|
+
"base_class": null,
|
56
|
+
"parameters": [
|
57
|
+
{
|
58
|
+
"name": "value",
|
59
|
+
"description": "value - value to pluralize",
|
60
|
+
"splat": null,
|
61
|
+
"default": null,
|
62
|
+
"param_type": "String"
|
63
|
+
}
|
64
|
+
],
|
65
|
+
"examples": [
|
66
|
+
|
67
|
+
],
|
68
|
+
"ruby": " return '' if value.nil?\n\n value = value.to_s if value.is_a?(Symbol)\n\n value.pluralize\n"
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"name": "pluralize_by_number",
|
72
|
+
"description": "Returns the plural form of the word based on a count",
|
73
|
+
"result": "value and number are used to calculate plural/singular form",
|
74
|
+
"category": "inflection",
|
75
|
+
"category_description": "Inflection handling routines, eg. pluralize, singular, ordinalize",
|
76
|
+
"base_class_require": null,
|
77
|
+
"base_class": null,
|
78
|
+
"parameters": [
|
79
|
+
{
|
80
|
+
"name": "value",
|
81
|
+
"description": "value - value to pluralize",
|
82
|
+
"splat": null,
|
83
|
+
"default": null,
|
84
|
+
"param_type": "String"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"name": "count",
|
88
|
+
"description": "count used to determine pluralization",
|
89
|
+
"splat": null,
|
90
|
+
"default": null,
|
91
|
+
"param_type": "Int"
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"name": "format",
|
95
|
+
"description": "(Optional) what format should output be. :word, :number_word",
|
96
|
+
"splat": null,
|
97
|
+
"default": null,
|
98
|
+
"param_type": "String"
|
99
|
+
}
|
100
|
+
],
|
101
|
+
"examples": [
|
102
|
+
|
103
|
+
],
|
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
|
+
},
|
106
|
+
{
|
107
|
+
"name": "singularize",
|
108
|
+
"description": "The reverse of #pluralize, returns the singular form of a word in a string",
|
109
|
+
"result": "plural value turned to singular value",
|
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 singularized",
|
118
|
+
"splat": null,
|
119
|
+
"default": null,
|
120
|
+
"param_type": "String"
|
121
|
+
}
|
122
|
+
],
|
123
|
+
"examples": [
|
124
|
+
|
125
|
+
],
|
126
|
+
"ruby": " return '' if value.nil?\n\n value = value.to_s if value.is_a?(Symbol)\n\n value.singularize\n"
|
127
|
+
}
|
128
|
+
]
|
129
|
+
}
|
@@ -31,7 +31,12 @@ class CategoryDirector < KDirector::Directors::BaseDirector
|
|
31
31
|
def generate_require_all_cmdlets
|
32
32
|
cd(:lib)
|
33
33
|
add('_.rb',
|
34
|
-
template_file: '
|
34
|
+
template_file: 'cmdlets_require_all.rb',
|
35
|
+
cmdlets: data_access.cmdlet.all_cmdlets)
|
36
|
+
|
37
|
+
cd(:handlebars_lib)
|
38
|
+
add('_.rb',
|
39
|
+
template_file: 'handlebars_helper_require_all.rb',
|
35
40
|
cmdlets: data_access.cmdlet.all_cmdlets)
|
36
41
|
|
37
42
|
end
|
@@ -32,12 +32,20 @@ class CmdletDirector < KDirector::Directors::BaseDirector
|
|
32
32
|
builder.cmdlets.each do |cmdlet|
|
33
33
|
cmdlet_file = "#{cmdlet[:category]}/#{cmdlet[:name]}.rb"
|
34
34
|
cmdlet_spec_file = "#{cmdlet[:category]}/#{cmdlet[:name]}_spec.rb"
|
35
|
+
handlebars_file = "handlebarsjs/helpers/#{cmdlet[:category]}/#{cmdlet[:name]}.rb"
|
36
|
+
handlebars_spec_file = "handlebarsjs/helpers/#{cmdlet[:category]}/#{cmdlet[:name]}_spec.rb"
|
35
37
|
|
36
38
|
cd(:lib)
|
37
39
|
add(cmdlet_file, template_file: 'cmdlet.rb', cmdlet: cmdlet)
|
38
40
|
|
39
41
|
cd(:spec)
|
40
42
|
add(cmdlet_spec_file, template_file: 'cmdlet_spec.rb', cmdlet: cmdlet, on_exist: :skip)
|
43
|
+
|
44
|
+
cd(:handlebars_lib)
|
45
|
+
add(handlebars_file, template_file: 'handlebars_helper.rb', cmdlet: cmdlet)
|
46
|
+
|
47
|
+
cd(:handlebars_spec)
|
48
|
+
add(handlebars_spec_file, template_file: 'handlebars_helper_spec.rb', cmdlet: cmdlet, on_exist: :skip)
|
41
49
|
end
|
42
50
|
|
43
51
|
self
|
@@ -69,41 +69,3 @@ KManager.action :array_commands do
|
|
69
69
|
.debug
|
70
70
|
end
|
71
71
|
end
|
72
|
-
|
73
|
-
# result "return block when every value is truthy"
|
74
|
-
|
75
|
-
# parameter('values', 'list of values (via *splat) to be checked via AND condition', splat: true)
|
76
|
-
|
77
|
-
# example <<-TEXT
|
78
|
-
# {{#if (and p1 p2 p3 p4 p5)}}
|
79
|
-
# found
|
80
|
-
# {{/if}}
|
81
|
-
# TEXT
|
82
|
-
|
83
|
-
# example <<-TEXT
|
84
|
-
# {{#if (and name age)}}
|
85
|
-
# {{name}}-{{age}}
|
86
|
-
# {{else}}
|
87
|
-
# no name or age
|
88
|
-
# {{/if}}
|
89
|
-
# TEXT
|
90
|
-
|
91
|
-
# builder
|
92
|
-
# .add_file('FUNCTIONS.md',
|
93
|
-
# template_file: 'FUNCTIONS.md',
|
94
|
-
# categories: categories.sort_by { |r| r.name },
|
95
|
-
# functions: functions.sort_by { |r| [r.category, r.name] },
|
96
|
-
# on_exist: :write)
|
97
|
-
|
98
|
-
# add('all_commands.rb',
|
99
|
-
# template_file: 'all_commands.rb',
|
100
|
-
# commands: commands.sort_by { |r| [r.category, r.name] },
|
101
|
-
# on_exist: :write)
|
102
|
-
|
103
|
-
# cmdlets.each do |cmdlet|
|
104
|
-
|
105
|
-
# add("#{cmdlet.category}/#{cmdlet.name}.rb",
|
106
|
-
# cmdlet: cmdlet,
|
107
|
-
# template_file: 'command.rb',
|
108
|
-
# on_exist: :write)
|
109
|
-
# end
|