cmdlet 0.0.7 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.templates/cmdlet.rb +26 -0
  3. data/.builders/.templates/{command_spec.rb → cmdlet_spec.rb} +4 -4
  4. data/.builders/.templates/require_all_cmdlets.rb +5 -0
  5. data/.builders/_.rb +7 -1
  6. data/.builders/boot.rb +2 -0
  7. data/.builders/data/categories.json +2 -10
  8. data/.builders/data/cmdlets/array.json +121 -0
  9. data/.builders/data/cmdlets/case.json +313 -0
  10. data/.builders/data/cmdlets/comparison.json +245 -0
  11. data/.builders/data/cmdlets/inflection.json +129 -0
  12. data/.builders/director/category_builder.rb +26 -0
  13. data/.builders/director/category_dao.rb +38 -0
  14. data/.builders/director/category_director.rb +24 -10
  15. data/.builders/director/cmdlet_builder.rb +27 -34
  16. data/.builders/director/cmdlet_child.rb +16 -44
  17. data/.builders/director/cmdlet_dao.rb +29 -0
  18. data/.builders/director/cmdlet_director.rb +37 -13
  19. data/.builders/director/dao.rb +16 -0
  20. data/.builders/documents/commands.rb +15 -16
  21. data/.builders/documents/use_cases.rb +32 -34
  22. data/.builders/documents/x_functions.rb +7 -10
  23. data/.builders/generators/01-bootstrap.rb +112 -112
  24. data/.builders/generators/20-categories.rb +16 -0
  25. data/.builders/generators/30-commands-bak.rb +53 -0
  26. data/.builders/generators/cmdlets/array.rb +71 -0
  27. data/.builders/generators/cmdlets/case.rb +184 -0
  28. data/.builders/generators/cmdlets/comparison.rb +126 -0
  29. data/.builders/generators/cmdlets/inflection.rb +93 -0
  30. data/CHANGELOG.md +37 -0
  31. data/Guardfile +1 -1
  32. data/lib/cmdlet/_.rb +33 -0
  33. data/lib/cmdlet/array/join.rb +8 -10
  34. data/lib/cmdlet/array/join_post.rb +22 -0
  35. data/lib/cmdlet/array/join_pre.rb +22 -0
  36. data/lib/cmdlet/base_cmdlet.rb +17 -0
  37. data/lib/cmdlet/case/back_slash.rb +16 -0
  38. data/lib/cmdlet/case/camel.rb +16 -0
  39. data/lib/cmdlet/case/constant.rb +16 -0
  40. data/lib/cmdlet/case/dash.rb +16 -0
  41. data/lib/cmdlet/case/dot.rb +16 -0
  42. data/lib/cmdlet/case/double_colon.rb +16 -0
  43. data/lib/cmdlet/case/human.rb +20 -0
  44. data/lib/cmdlet/case/lamel.rb +16 -0
  45. data/lib/cmdlet/case/lower.rb +18 -0
  46. data/lib/cmdlet/case/sentence.rb +20 -0
  47. data/lib/cmdlet/case/slash.rb +16 -0
  48. data/lib/cmdlet/case/snake.rb +16 -0
  49. data/lib/cmdlet/case/title.rb +21 -0
  50. data/lib/cmdlet/case/upper.rb +18 -0
  51. data/lib/cmdlet/comparison/and.rb +16 -0
  52. data/lib/cmdlet/comparison/default.rb +20 -0
  53. data/lib/cmdlet/comparison/eq.rb +20 -0
  54. data/lib/cmdlet/comparison/gt.rb +17 -0
  55. data/lib/cmdlet/comparison/gte.rb +17 -0
  56. data/lib/cmdlet/comparison/lt.rb +17 -0
  57. data/lib/cmdlet/comparison/lte.rb +17 -0
  58. data/lib/cmdlet/comparison/ne.rb +20 -0
  59. data/lib/cmdlet/comparison/or.rb +16 -0
  60. data/lib/cmdlet/inflection/ordinal.rb +20 -0
  61. data/lib/cmdlet/inflection/ordinalize.rb +20 -0
  62. data/lib/cmdlet/inflection/pluralize.rb +20 -0
  63. data/lib/cmdlet/inflection/pluralize_by_number.rb +28 -0
  64. data/lib/cmdlet/inflection/singularize.rb +20 -0
  65. data/lib/cmdlet/version.rb +1 -1
  66. data/lib/cmdlet.rb +5 -0
  67. data/package-lock.json +2 -2
  68. data/package.json +1 -1
  69. metadata +51 -9
  70. data/.builders/.templates/all_commands.rb +0 -5
  71. data/.builders/.templates/command.rb +0 -26
  72. data/.builders/documents/categories.rb +0 -24
  73. data/.builders/documents/cmdlets.rb +0 -30
  74. data/.builders/generators/20-commands.rb +0 -54
  75. data/.builders/generators/25-categories.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49865609277b82bf27cc7275b38f0830109e2228b8ab3629ca1774d07b85f834
4
- data.tar.gz: 7d6c2c92910fc466f8f0d3e04ebb4356dfb070c17e553a3e573c60e946648032
3
+ metadata.gz: cbd35f78dbd459eac65f0df1fd2f6aefc16b560b3083140a9ea092dc6cf359ec
4
+ data.tar.gz: 27fff2ef08e9df32b43b5bf06d72755893e3a701af8057d55c0379f6ebe82226
5
5
  SHA512:
6
- metadata.gz: d7bd4e1e6364146d104a96bd66425df76f3bd164b350f1b3328f046cc8c8e2b6f2d65eec9dacd18c7ce510e064846f10b0ba2a49315089f6ff0235e494b34387
7
- data.tar.gz: e0ddc16a51d5c16957ac2241098de2f1a7a0de777f59621d8398da8e61172ae07c9ea796971e48ce024a646eee0c6b29cd1fe93fde4c6840c0d41b497c63da14
6
+ metadata.gz: cf6ea403db6da89cf2f82957773fe648f7eb8883acd112524d44149fb4f8067409b3d17e8240d13b6ab1059883d86ecbadc4efb61bbbec4722cd0bc6620baee6
7
+ data.tar.gz: 91153e6f0c1aec787f555ff44afe2469328208bd11f8d8857a05d4da18a7f54cdc00dd12e2a6c774c1d2ec2cd2870a5e23723bc08d9783709fd75fa526d40a35
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # {{cmdlet.category_description}}
5
+ module {{camel cmdlet.category}}
6
+ # {{camel cmdlet.name}}: {{cmdlet.description}}
7
+ class {{camel cmdlet.name}} < Cmdlet::BaseCmdlet
8
+ {{#each cmdlet.usecases}}
9
+ # @example
10
+ #
11
+ # puts {{camel ./function}}.new.call({{{nice_inputs}}})
12
+ #
13
+ # {{expected_output}}
14
+ #
15
+ {{/each}}
16
+ #
17
+ {{#each cmdlet.parameters}}
18
+ # @param [{{./param_type}}] {{./name}} - {{./description}}
19
+ {{/each}}
20
+ # @return [String] {{cmdlet.result}}
21
+ def call({{#each cmdlet.parameters}}{{#if ./splat}}{{./splat}}{{/if}}{{./name}}{{#if ./default}} = {{{./default}}}{{/if}}{{#if @last}}{{^}}, {{/if}}{{/each}})
22
+ {{{cmdlet.ruby}}}
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # {{camel command.name}}: {{command.function_description}}
4
- RSpec.describe Funcky::{{camel command.category}}::{{camel command.name}} do
3
+ # {{camel cmdlet.name}}: {{cmdlet.description}}
4
+ RSpec.describe Cmdlet::{{camel cmdlet.category}}::{{camel cmdlet.name}} do
5
5
  let(:instance) { described_class.new }
6
6
 
7
7
  describe 'initialize' do
@@ -10,8 +10,8 @@ RSpec.describe Funcky::{{camel command.category}}::{{camel command.name}} do
10
10
  it { is_expected.not_to be_nil }
11
11
  end
12
12
 
13
- describe '#parse' do
14
- subject { instance.parse(value) }
13
+ describe '#call' do
14
+ subject { instance.call(value) }
15
15
 
16
16
  let(:value) { nil }
17
17
 
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ {{#each cmdlets}}
4
+ require_relative '{{category}}/{{name}}'
5
+ {{/each}}
data/.builders/_.rb CHANGED
@@ -1,4 +1,10 @@
1
- # require_relative './documents/_'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './director/category_dao'
4
+ require_relative './director/cmdlet_dao'
5
+ require_relative './director/dao'
6
+
7
+ require_relative './director/category_builder'
2
8
  require_relative './director/category_director'
3
9
  require_relative './director/cmdlet_builder'
4
10
  require_relative './director/cmdlet_director'
data/.builders/boot.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Boot Sequence
2
4
 
3
5
  include KLog::Logging
@@ -17,20 +17,12 @@
17
17
  "description": "String handling helpers"
18
18
  },
19
19
  {
20
- "name": "a_array",
20
+ "name": "array",
21
21
  "description": "Array handling routines, eg. join, join_prefix, join_post"
22
22
  },
23
23
  {
24
- "name": "a_transform",
24
+ "name": "transform",
25
25
  "description": "Tokenize and apply case and/or separator"
26
- },
27
- {
28
- "name": "a_comparison",
29
- "description": "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc."
30
- },
31
- {
32
- "name": "a_inflection",
33
- "description": "Inflection handling routines, eg. pluralize, singular, ordinalize"
34
26
  }
35
27
  ]
36
28
  }
@@ -0,0 +1,121 @@
1
+ {
2
+ "category_key": "array",
3
+ "cmdlets": [
4
+ {
5
+ "name": "join",
6
+ "description": "join an array of values with separator as a string",
7
+ "result": "new String formed by joining the array elements with seperator",
8
+ "category": "array",
9
+ "category_description": "Array handling routines, eg. join, join_prefix, join_post",
10
+ "base_class_require": null,
11
+ "base_class": null,
12
+ "parameters": [
13
+ {
14
+ "name": "values",
15
+ "description": "array of values to join",
16
+ "splat": null,
17
+ "default": null,
18
+ "param_type": "String|Int"
19
+ },
20
+ {
21
+ "name": "separator",
22
+ "description": "separator between values, defaults to comma",
23
+ "splat": null,
24
+ "default": "','",
25
+ "param_type": "String"
26
+ }
27
+ ],
28
+ "examples": [
29
+
30
+ ],
31
+ "ruby": " return false if values.nil? || values.length == 0\n values = values.reject(&:blank?)\n return '' if values.length.zero?\n\n values.join(separator)\n"
32
+ },
33
+ {
34
+ "name": "join_pre",
35
+ "description": "join an array of values with separator as a string and using the separator at the beginning of string",
36
+ "result": null,
37
+ "category": "array",
38
+ "category_description": "Array handling routines, eg. join, join_prefix, join_post",
39
+ "base_class_require": null,
40
+ "base_class": null,
41
+ "parameters": [
42
+ {
43
+ "name": "values",
44
+ "description": "array of values to join",
45
+ "splat": null,
46
+ "default": null,
47
+ "param_type": "String|Int"
48
+ },
49
+ {
50
+ "name": "separator",
51
+ "description": "separator between values, defaults to comma",
52
+ "splat": null,
53
+ "default": "','",
54
+ "param_type": "String"
55
+ }
56
+ ],
57
+ "examples": [
58
+
59
+ ],
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
+ },
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
+ {
92
+ "name": "join_post",
93
+ "description": "join an array of values with separator as a string and using the separator at the end of string",
94
+ "result": null,
95
+ "category": "array",
96
+ "category_description": "Array handling routines, eg. join, join_prefix, join_post",
97
+ "base_class_require": null,
98
+ "base_class": null,
99
+ "parameters": [
100
+ {
101
+ "name": "values",
102
+ "description": "array of values to join",
103
+ "splat": null,
104
+ "default": null,
105
+ "param_type": "String|Int"
106
+ },
107
+ {
108
+ "name": "separator",
109
+ "description": "separator between values, defaults to comma",
110
+ "splat": null,
111
+ "default": "','",
112
+ "param_type": "String"
113
+ }
114
+ ],
115
+ "examples": [
116
+
117
+ ],
118
+ "ruby": " return '' if values.nil? || !values.is_a?(::Array)\n values = values.reject(&:blank?)\n return '' if values.length.zero?\n\n \"#{values.join(separator)}#{separator}\"\n"
119
+ }
120
+ ]
121
+ }
@@ -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
+ }