cmdlet 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc4888cd594af0dd224a836be55e28d9b6cdf153ac89e770807d412b14d11982
4
- data.tar.gz: 00b2044a9a53f53afbe109a443aabd7cc38db54782fd1a1eebfbdc563db3de7c
3
+ metadata.gz: cbd35f78dbd459eac65f0df1fd2f6aefc16b560b3083140a9ea092dc6cf359ec
4
+ data.tar.gz: 27fff2ef08e9df32b43b5bf06d72755893e3a701af8057d55c0379f6ebe82226
5
5
  SHA512:
6
- metadata.gz: f7470c8c5cc637bfc48aa1e5d9a63d73748831e71d323cdf3a09d2cb1b5b0e8e40970300072eafbbe00976334d7021e3e22ce66f5626b4983faa2d02f5e4ca70
7
- data.tar.gz: e04137866c533b774510d0964be0a27f98110c23237da9d55b8c560d371f1a32d55e8e2af67799b0f58b3240434b1fb7b46f40915cb1baacf4adcfb5f037a496
6
+ metadata.gz: cf6ea403db6da89cf2f82957773fe648f7eb8883acd112524d44149fb4f8067409b3d17e8240d13b6ab1059883d86ecbadc4efb61bbbec4722cd0bc6620baee6
7
+ data.tar.gz: 91153e6f0c1aec787f555ff44afe2469328208bd11f8d8857a05d4da18a7f54cdc00dd12e2a6c774c1d2ec2cd2870a5e23723bc08d9783709fd75fa526d40a35
@@ -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,184 @@
1
+ # frozen_string_literal: true
2
+
3
+ KManager.action :case_commands do
4
+ action do
5
+ CmdletDirector
6
+ .init(k_builder, category: :case)
7
+ .cmdlet do
8
+ name :back_slash
9
+ description 'Convert to back slash notation'
10
+ result 'value converted to back_slash case'
11
+
12
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
13
+
14
+ ruby <<-'RUBY'
15
+ tokenizer.parse(value, preserve_case: true, separator: '\\')
16
+ RUBY
17
+ end
18
+ .cmdlet do
19
+ name :camel
20
+ description "Camel case the characters in the given 'string'"
21
+ result 'value converted to camel case'
22
+
23
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
24
+
25
+ ruby <<-'RUBY'
26
+ tokenizer.parse(value).underscore.camelize
27
+ RUBY
28
+ end
29
+ .cmdlet do
30
+ name :constant
31
+ description "Constant case the characters in the given 'string'"
32
+ result 'value converted to constant case'
33
+
34
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
35
+
36
+ ruby <<-'RUBY'
37
+ tokenizer.parse(value, separator: '_').upcase
38
+ RUBY
39
+ end
40
+ .cmdlet do
41
+ name :dash
42
+ description "Dash case the characters in the given 'string'"
43
+ result 'value converted to dash case'
44
+
45
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
46
+
47
+ ruby <<-'RUBY'
48
+ tokenizer.parse(value)
49
+ RUBY
50
+ end
51
+ .cmdlet do
52
+ name :dot
53
+ description "Dot case the characters in the given 'string'"
54
+ result 'value converted to dot case'
55
+
56
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
57
+
58
+ ruby <<-'RUBY'
59
+ tokenizer.parse(value, separator: '.')
60
+ RUBY
61
+ end
62
+ .cmdlet do
63
+ name :double_colon
64
+ description "Double colon case the characters in the given 'string'"
65
+ result 'value converted to double_colon case'
66
+
67
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
68
+
69
+ ruby <<-'RUBY'
70
+ tokenizer.parse(value, preserve_case: true, separator: '::')
71
+ RUBY
72
+ end
73
+ .cmdlet do
74
+ name :human
75
+ description "Human case the characters in the given 'string'"
76
+ result 'value converted to human case'
77
+
78
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
79
+
80
+ ruby <<-'RUBY'
81
+ tokenizer.parse(value,
82
+ separator: ' ',
83
+ preserve_case: true,
84
+ compress_prefix_numerals: false,
85
+ compress_suffix_numerals: false).humanize
86
+ RUBY
87
+ end
88
+ .cmdlet do
89
+ name :lamel
90
+ description "Lower camel case the characters in the given 'string'"
91
+ result 'value converted to lower camel case'
92
+
93
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
94
+
95
+ ruby <<-'RUBY'
96
+ tokenizer.parse(value, separator: '_').camelize(:lower)
97
+ RUBY
98
+ end
99
+ .cmdlet do
100
+ name :lower
101
+ description "Lower case the characters in the given 'string'"
102
+ result 'value converted to lower case'
103
+
104
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
105
+
106
+ ruby <<-'RUBY'
107
+ return '' if value.nil?
108
+
109
+ value.downcase
110
+ RUBY
111
+ end
112
+ .cmdlet do
113
+ name :sentence
114
+ description "Sentence case the characters in the given 'string'"
115
+ result 'value converted to sentence case'
116
+
117
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
118
+
119
+ ruby <<-'RUBY'
120
+ tokenizer.parse(value,
121
+ separator: ' ',
122
+ preserve_case: true,
123
+ compress_prefix_numerals: false,
124
+ compress_suffix_numerals: false).titleize
125
+ RUBY
126
+ end
127
+ .cmdlet do
128
+ name :slash
129
+ description "Slash case the characters in the given 'string'"
130
+ result 'value converted to slash case'
131
+
132
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
133
+
134
+ ruby <<-'RUBY'
135
+ tokenizer.parse(value, preserve_case: true, separator: '/')
136
+ RUBY
137
+ end
138
+ .cmdlet do
139
+ name :snake
140
+ description "Snake case the characters in the given 'string'"
141
+ result 'value converted to snake case'
142
+
143
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
144
+
145
+ ruby <<-'RUBY'
146
+ tokenizer.parse(value, separator: '_', forced_separator: true)
147
+ RUBY
148
+ end
149
+ .cmdlet do
150
+ name :title
151
+ description "Title case the characters in the given 'string'"
152
+ result 'value converted to title case'
153
+
154
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
155
+
156
+ ruby <<-'RUBY'
157
+ tokenizer.parse(value,
158
+ separator: ' ',
159
+ preserve_case: true,
160
+ compress_prefix_numerals: false,
161
+ compress_suffix_numerals: false)
162
+ .titleize
163
+ RUBY
164
+ end
165
+ .cmdlet do
166
+ name :upper
167
+ description "Upper case the characters in the given 'string'"
168
+ result 'value converted to upper case'
169
+
170
+ parameter :value, 'value - to be converted', param_type: 'String|Int'
171
+
172
+ ruby <<-'RUBY'
173
+ return '' if value.nil?
174
+
175
+ value.upcase
176
+ RUBY
177
+ end
178
+ .generate
179
+ .debug
180
+ end
181
+ end
182
+
183
+ # format_as
184
+ # upper
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [0.2.0](https://github.com/klueless-io/cmdlet/compare/v0.1.2...v0.2.0) (2022-07-10)
2
+
3
+
4
+ ### Features
5
+
6
+ * add inflection cmdlets ([55bb73f](https://github.com/klueless-io/cmdlet/commit/55bb73fe3420096a1d4edd85d207529507c088db))
7
+
1
8
  ## [0.1.2](https://github.com/klueless-io/cmdlet/compare/v0.1.1...v0.1.2) (2022-07-10)
2
9
 
3
10
 
data/lib/cmdlet/_.rb CHANGED
@@ -3,6 +3,20 @@
3
3
  require_relative 'array/join'
4
4
  require_relative 'array/join_post'
5
5
  require_relative 'array/join_pre'
6
+ require_relative 'case/back_slash'
7
+ require_relative 'case/camel'
8
+ require_relative 'case/constant'
9
+ require_relative 'case/dash'
10
+ require_relative 'case/dot'
11
+ require_relative 'case/double_colon'
12
+ require_relative 'case/human'
13
+ require_relative 'case/lamel'
14
+ require_relative 'case/lower'
15
+ require_relative 'case/sentence'
16
+ require_relative 'case/slash'
17
+ require_relative 'case/snake'
18
+ require_relative 'case/title'
19
+ require_relative 'case/upper'
6
20
  require_relative 'comparison/and'
7
21
  require_relative 'comparison/default'
8
22
  require_relative 'comparison/eq'
@@ -11,7 +11,7 @@ module Cmdlet
11
11
  # all sorts of case formatted strings can be
12
12
  # represented in a consistent fashion
13
13
  def tokenizer
14
- @_tokenizer ||= Funcky.configuration.tokenizer
14
+ @_tokenizer ||= KConfig.configuration.cmdlet.tokenizer
15
15
  end
16
16
  end
17
17
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # BackSlash: Convert to back slash notation
7
+ class BackSlash < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to back_slash case
11
+ def call(value)
12
+ tokenizer.parse(value, preserve_case: true, separator: '\\')
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # Camel: Camel case the characters in the given &#x27;string&#x27;
7
+ class Camel < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to camel case
11
+ def call(value)
12
+ tokenizer.parse(value).underscore.camelize
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # Constant: Constant case the characters in the given &#x27;string&#x27;
7
+ class Constant < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to constant case
11
+ def call(value)
12
+ tokenizer.parse(value, separator: '_').upcase
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # Dash: Dash case the characters in the given &#x27;string&#x27;
7
+ class Dash < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to dash case
11
+ def call(value)
12
+ tokenizer.parse(value)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # Dot: Dot case the characters in the given &#x27;string&#x27;
7
+ class Dot < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to dot case
11
+ def call(value)
12
+ tokenizer.parse(value, separator: '.')
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # DoubleColon: Double colon case the characters in the given &#x27;string&#x27;
7
+ class DoubleColon < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to double_colon case
11
+ def call(value)
12
+ tokenizer.parse(value, preserve_case: true, separator: '::')
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # Human: Human case the characters in the given &#x27;string&#x27;
7
+ class Human < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to human case
11
+ def call(value)
12
+ tokenizer.parse(value,
13
+ separator: ' ',
14
+ preserve_case: true,
15
+ compress_prefix_numerals: false,
16
+ compress_suffix_numerals: false).humanize
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # Lamel: Lower camel case the characters in the given &#x27;string&#x27;
7
+ class Lamel < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to lower camel case
11
+ def call(value)
12
+ tokenizer.parse(value, separator: '_').camelize(:lower)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # Lower: Lower case the characters in the given &#x27;string&#x27;
7
+ class Lower < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to lower case
11
+ def call(value)
12
+ return '' if value.nil?
13
+
14
+ value.downcase
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # Sentence: Sentence case the characters in the given &#x27;string&#x27;
7
+ class Sentence < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to sentence case
11
+ def call(value)
12
+ tokenizer.parse(value,
13
+ separator: ' ',
14
+ preserve_case: true,
15
+ compress_prefix_numerals: false,
16
+ compress_suffix_numerals: false).titleize
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # Slash: Slash case the characters in the given &#x27;string&#x27;
7
+ class Slash < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to slash case
11
+ def call(value)
12
+ tokenizer.parse(value, preserve_case: true, separator: '/')
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # Snake: Snake case the characters in the given &#x27;string&#x27;
7
+ class Snake < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to snake case
11
+ def call(value)
12
+ tokenizer.parse(value, separator: '_', forced_separator: true)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # Title: Title case the characters in the given &#x27;string&#x27;
7
+ class Title < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to title case
11
+ def call(value)
12
+ tokenizer.parse(value,
13
+ separator: ' ',
14
+ preserve_case: true,
15
+ compress_prefix_numerals: false,
16
+ compress_suffix_numerals: false)
17
+ .titleize
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Tokenize and apply case and/or separator
5
+ module Case
6
+ # Upper: Upper case the characters in the given &#x27;string&#x27;
7
+ class Upper < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - to be converted
10
+ # @return [String] value converted to upper case
11
+ def call(value)
12
+ return '' if value.nil?
13
+
14
+ value.upcase
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cmdlet
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "cmdlet",
9
- "version": "0.2.0",
9
+ "version": "0.2.1",
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.2.0",
3
+ "version": "0.2.1",
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
@@ -54,6 +54,7 @@ files:
54
54
  - ".builders/boot.rb"
55
55
  - ".builders/data/categories.json"
56
56
  - ".builders/data/cmdlets/array.json"
57
+ - ".builders/data/cmdlets/case.json"
57
58
  - ".builders/data/cmdlets/comparison.json"
58
59
  - ".builders/data/cmdlets/inflection.json"
59
60
  - ".builders/director/category_builder.rb"
@@ -71,6 +72,7 @@ files:
71
72
  - ".builders/generators/20-categories.rb"
72
73
  - ".builders/generators/30-commands-bak.rb"
73
74
  - ".builders/generators/cmdlets/array.rb"
75
+ - ".builders/generators/cmdlets/case.rb"
74
76
  - ".builders/generators/cmdlets/comparison.rb"
75
77
  - ".builders/generators/cmdlets/inflection.rb"
76
78
  - ".releaserc.json"
@@ -92,6 +94,20 @@ files:
92
94
  - lib/cmdlet/array/join_post.rb
93
95
  - lib/cmdlet/array/join_pre.rb
94
96
  - lib/cmdlet/base_cmdlet.rb
97
+ - lib/cmdlet/case/back_slash.rb
98
+ - lib/cmdlet/case/camel.rb
99
+ - lib/cmdlet/case/constant.rb
100
+ - lib/cmdlet/case/dash.rb
101
+ - lib/cmdlet/case/dot.rb
102
+ - lib/cmdlet/case/double_colon.rb
103
+ - lib/cmdlet/case/human.rb
104
+ - lib/cmdlet/case/lamel.rb
105
+ - lib/cmdlet/case/lower.rb
106
+ - lib/cmdlet/case/sentence.rb
107
+ - lib/cmdlet/case/slash.rb
108
+ - lib/cmdlet/case/snake.rb
109
+ - lib/cmdlet/case/title.rb
110
+ - lib/cmdlet/case/upper.rb
95
111
  - lib/cmdlet/comparison/and.rb
96
112
  - lib/cmdlet/comparison/default.rb
97
113
  - lib/cmdlet/comparison/eq.rb