cmdlet 0.13.2 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6f177ca5e10f4271358113d23c227355ce2831dd2c473f39d5a63ecbaeec0e5
4
- data.tar.gz: 7b5b5c83340b73a80071777f01ce8f8d04635f6601b50194016fca7b2b991df7
3
+ metadata.gz: 0a39225b9e94474cf8a11bc5abd2f157cf41e2aaafc18ab39f8267948b7fd66c
4
+ data.tar.gz: 56f92f2bb8a13a8cd911d0df090383a25d9c68405307250960bc1c226395975d
5
5
  SHA512:
6
- metadata.gz: b31410a96367e30a330dd71dababf73278c33ae590aac7847c508db1e6fcd0ff763ba3377f664bad3e06859087520a17d95ce3972cf3498623cb83f24a0fa507
7
- data.tar.gz: a5cd5041cd37563a402a99863290b396f92e87a7a4b5a3c6d3504bbc17ef89dfeff88fb2ba7aedd30ca8fde2bac139b4effc7b766f14fe3f3887baa4a7a4e9b4
6
+ metadata.gz: faa07d0d3b3a42739ffbb2c5ba3c3b7ad554e5eddcb55931f0ab6a07613536228f73122d82ce257b0abc7cbaeeda4187c40d98f7596d1cc4bf8db21cf0963e97
7
+ data.tar.gz: af16f9e693f99008abfcb8df1c6213ca73244b9b4227a5e8581439ac3ced181552c2b1fc423fc9bd6cf474644037fdb30bb065fd87f88a58ceb9c82f9db658e2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.13.2](https://github.com/klueless-io/cmdlet/compare/v0.13.1...v0.13.2) (2024-07-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update cops ([ba1ecf8](https://github.com/klueless-io/cmdlet/commit/ba1ecf86b3bc80616ba4cc4443afd29f52bb3447))
7
+
1
8
  ## [0.13.1](https://github.com/klueless-io/cmdlet/compare/v0.13.0...v0.13.1) (2023-10-17)
2
9
 
3
10
 
data/README.md CHANGED
@@ -33,7 +33,7 @@ See all [stories](./STORIES.md)
33
33
 
34
34
  ## Usage
35
35
 
36
- See all [usage examples](./USAGE.md)
36
+ See all [usage examples](./docs/usage.md)
37
37
 
38
38
 
39
39
 
data/docs/usage.md ADDED
@@ -0,0 +1,440 @@
1
+ # Cmdlet Usage Guide
2
+
3
+ ## Table of Contents
4
+ 1. [Introduction](#introduction)
5
+ 2. [Installation](#installation)
6
+ 3. [Configuration](#configuration)
7
+ 4. [Available Cmdlets](#available-cmdlets)
8
+ - [Array Operations](#array-operations)
9
+ - [Join](#join)
10
+ - [JoinPost](#joinpost)
11
+ - [JoinPre](#joinpre)
12
+ - [Case Transformations](#case-transformations)
13
+ - [Comparison Operations](#comparison-operations)
14
+ - [Inflection Operations](#inflection-operations)
15
+ - [Miscellaneous Operations](#miscellaneous-operations)
16
+ - [String Operations](#string-operations)
17
+ 5. [Examples](#examples)
18
+ 6. [Advanced Usage](#advanced-usage)
19
+ 7. [Troubleshooting](#troubleshooting)
20
+ 8. [Contributing](#contributing)
21
+
22
+ ## Introduction
23
+ Briefly explain what Cmdlet is and its main purpose.
24
+
25
+ ## Installation
26
+ Provide instructions on how to install the Cmdlet gem.
27
+
28
+ ## Configuration
29
+ Explain how to configure Cmdlet using the `KConfig::Configuration` system.
30
+
31
+ Example:
32
+
33
+ ```ruby
34
+ KConfig.configure do |config|
35
+ config.cmdlet.padl_count = 20
36
+ config.cmdlet.padl_char = '-'
37
+ # Add other configuration options
38
+ end
39
+ ```
40
+
41
+ ## Available Cmdlets
42
+
43
+ ### Array Operations
44
+ - Join
45
+ - JoinPost
46
+ - JoinPre
47
+
48
+ ### Case Transformations
49
+ - BackSlash
50
+ - Camel
51
+ - Constant
52
+ - Dash
53
+ - Dot
54
+ - DoubleColon
55
+ - Human
56
+ - Lamel
57
+ - Lower
58
+ - Slash
59
+ - Snake
60
+ - Title
61
+ - Upper
62
+
63
+ ### Comparison Operations
64
+ - And
65
+ - Default
66
+ - Eq
67
+ - Gt
68
+ - Gte
69
+ - Lt
70
+ - Lte
71
+ - Ne
72
+ - Or
73
+
74
+ ### Inflection Operations
75
+ - Ordinal
76
+ - Ordinalize
77
+ - Pluralize
78
+ - PluralizeNumber
79
+ - PluralizeNumberWord
80
+ - Singularize
81
+
82
+ ### Miscellaneous Operations
83
+ - FormatJson
84
+ - Safe
85
+
86
+ ### String Operations
87
+ - Padl
88
+ - Padr
89
+
90
+ ## Examples
91
+ Provide usage examples for each category of cmdlets.
92
+
93
+ Example for FormatJson:
94
+
95
+ ```ruby
96
+ require 'cmdlet'
97
+
98
+ data = { name: "John Doe", age: 30 }
99
+ formatted_json = Cmdlet::Misc::FormatJson.new.call(data)
100
+ puts formatted_json
101
+ ```
102
+
103
+ ## Cmdlet Examples
104
+
105
+ ### Array Operations
106
+
107
+ #### Join
108
+
109
+ ```ruby
110
+ join = Cmdlet::Array::Join.new
111
+ join.call([1, 2, 3]) # Output: "1,2,3"
112
+ join.call(%w[a b c], ' | ') # Output: "a | b | c"
113
+ ```
114
+
115
+ #### JoinPost
116
+
117
+ ```ruby
118
+ join_post = Cmdlet::Array::JoinPost.new
119
+ join_post.call([1, 2, 3]) # Output: "1,2,3,"
120
+ join_post.call(%w[a b c], ' | ') # Output: "a | b | c | "
121
+ ```
122
+
123
+ #### JoinPre
124
+
125
+ ```ruby
126
+ join_pre = Cmdlet::Array::JoinPre.new
127
+ join_pre.call([1, 2, 3]) # Output: ",1,2,3"
128
+ join_pre.call(%w[a b c], ' | ') # Output: " | a | b | c"
129
+ ```
130
+
131
+ ### Case Transformations
132
+
133
+ #### BackSlash
134
+
135
+ ```ruby
136
+ back_slash = Cmdlet::Case::BackSlash.new
137
+ back_slash.call('the quick brown fox') # Output: "the\quick\brown\fox"
138
+ back_slash.call('Twenty Five 66') # Output: "Twenty\Five66"
139
+ ```
140
+
141
+ #### Camel
142
+
143
+ ```ruby
144
+ camel = Cmdlet::Case::Camel.new
145
+ camel.call('the quick brown fox') # Output: "TheQuickBrownFox"
146
+ camel.call('twenty five 66') # Output: "TwentyFive66"
147
+ camel.call('p02_ef4') # Output: "P02Ef4"
148
+ ```
149
+
150
+ #### Constant
151
+
152
+ ```ruby
153
+ constant = Cmdlet::Case::Constant.new
154
+ constant.call('the quick brown fox') # Output: "THE_QUICK_BROWN_FOX"
155
+ constant.call('twenty five66') # Output: "TWENTY_FIVE66"
156
+ ```
157
+
158
+ #### Dash
159
+
160
+ ```ruby
161
+ dash = Cmdlet::Case::Dash.new
162
+ dash.call('The Quick Brown Fox') # Output: "the-quick-brown-fox"
163
+ dash.call('Twenty Five66') # Output: "twenty-five66"
164
+ ```
165
+
166
+ #### Dot
167
+
168
+ ```ruby
169
+ dot = Cmdlet::Case::Dot.new
170
+ dot.call('the quick brown fox') # Output: "the.quick.brown.fox"
171
+ dot.call('twenty five 66') # Output: "twenty.five66"
172
+ ```
173
+
174
+ #### DoubleColon
175
+
176
+ ```ruby
177
+ double_colon = Cmdlet::Case::DoubleColon.new
178
+ double_colon.call('the quick brown fox') # Output: "the::quick::brown::fox"
179
+ double_colon.call('Twenty Five 66') # Output: "Twenty::Five66"
180
+ ```
181
+
182
+ #### Human
183
+
184
+ ```ruby
185
+ human = Cmdlet::Case::Human.new
186
+ human.call('the Quick brown Fox') # Output: "The quick brown fox"
187
+ human.call('twenty five66') # Output: "Twenty five66"
188
+ ```
189
+
190
+ #### Lamel
191
+
192
+ ```ruby
193
+ lamel = Cmdlet::Case::Lamel.new
194
+ lamel.call('The quick brown fox') # Output: "theQuickBrownFox"
195
+ lamel.call('twenty five66') # Output: "twentyFive66"
196
+ ```
197
+
198
+ #### Lower
199
+
200
+ ```ruby
201
+ lower = Cmdlet::Case::Lower.new
202
+ lower.call('The Quick Brown Fox') # Output: "the quick brown fox"
203
+ ```
204
+
205
+ #### Slash
206
+
207
+ ```ruby
208
+ slash = Cmdlet::Case::Slash.new
209
+ slash.call('the quick brown fox') # Output: "the/quick/brown/fox"
210
+ slash.call('twenty Five66') # Output: "twenty/Five66"
211
+ ```
212
+
213
+ #### Snake
214
+
215
+ ```ruby
216
+ snake = Cmdlet::Case::Snake.new
217
+ snake.call('the Quick brown Fox') # Output: "the_quick_brown_fox"
218
+ snake.call('twenty five66') # Output: "twenty_five66"
219
+ ```
220
+
221
+ #### Title
222
+
223
+ ```ruby
224
+ title = Cmdlet::Case::Title.new
225
+ title.call('the quick brown fox jumped over the lazy dog') # Output: "The Quick Brown Fox Jumped Over The Lazy Dog"
226
+ title.call('twenty five66') # Output: "Twenty Five66"
227
+ ```
228
+
229
+ #### Upper
230
+
231
+ ```ruby
232
+ upper = Cmdlet::Case::Upper.new
233
+ upper.call('the quick brown fox') # Output: "THE QUICK BROWN FOX"
234
+ ```
235
+
236
+ ### Comparison Operations
237
+
238
+ #### And
239
+
240
+ ```ruby
241
+ and_op = Cmdlet::Comparison::And.new
242
+ and_op.call(true, true) # Output: true
243
+ and_op.call(true, false) # Output: false
244
+ and_op.call(false, true) # Output: false
245
+ and_op.call(false, false) # Output: false
246
+ ```
247
+
248
+ #### Default
249
+
250
+ ```ruby
251
+ default = Cmdlet::Comparison::Default.new
252
+ default.call(nil, 'default value') # Output: "default value"
253
+ default.call('existing value', 'default value') # Output: "existing value"
254
+ ```
255
+
256
+ #### Eq (Equal)
257
+
258
+ ```ruby
259
+ eq = Cmdlet::Comparison::Eq.new
260
+ eq.call(5, 5) # Output: true
261
+ eq.call(5, '5') # Output: false
262
+ eq.call('a', 'a') # Output: true
263
+ ```
264
+
265
+ #### Gt (Greater Than)
266
+
267
+ ```ruby
268
+ gt = Cmdlet::Comparison::Gt.new
269
+ gt.call(10, 5) # Output: true
270
+ gt.call(5, 10) # Output: false
271
+ gt.call(5, 5) # Output: false
272
+ ```
273
+
274
+ #### Gte (Greater Than or Equal)
275
+
276
+ ```ruby
277
+ gte = Cmdlet::Comparison::Gte.new
278
+ gte.call(10, 5) # Output: true
279
+ gte.call(5, 5) # Output: true
280
+ gte.call(5, 10) # Output: false
281
+ ```
282
+
283
+ #### Lt (Less Than)
284
+
285
+ ```ruby
286
+ lt = Cmdlet::Comparison::Lt.new
287
+ lt.call(5, 10) # Output: true
288
+ lt.call(10, 5) # Output: false
289
+ lt.call(5, 5) # Output: false
290
+ ```
291
+
292
+ #### Lte (Less Than or Equal)
293
+
294
+ ```ruby
295
+ lte = Cmdlet::Comparison::Lte.new
296
+ lte.call(5, 10) # Output: true
297
+ lte.call(5, 5) # Output: true
298
+ lte.call(10, 5) # Output: false
299
+ ```
300
+
301
+ #### Ne (Not Equal)
302
+
303
+ ```ruby
304
+ ne = Cmdlet::Comparison::Ne.new
305
+ ne.call(5, 10) # Output: true
306
+ ne.call(5, 5) # Output: false
307
+ ne.call('a', 'b') # Output: true
308
+ ```
309
+
310
+ #### Or
311
+
312
+ ```ruby
313
+ or_op = Cmdlet::Comparison::Or.new
314
+ or_op.call(true, true) # Output: true
315
+ or_op.call(true, false) # Output: true
316
+ or_op.call(false, true) # Output: true
317
+ or_op.call(false, false) # Output: false
318
+ ```
319
+
320
+ ### Inflection Operations
321
+
322
+ #### Ordinal
323
+
324
+ ```ruby
325
+ ordinal = Cmdlet::Inflection::Ordinal.new
326
+ ordinal.call(1) # Output: "st"
327
+ ordinal.call(2) # Output: "nd"
328
+ ordinal.call(3) # Output: "rd"
329
+ ordinal.call(4) # Output: "th"
330
+ ordinal.call(11) # Output: "th"
331
+ ordinal.call(21) # Output: "st"
332
+ ```
333
+
334
+ #### Ordinalize
335
+
336
+ ```ruby
337
+ ordinalize = Cmdlet::Inflection::Ordinalize.new
338
+ ordinalize.call(1) # Output: "1st"
339
+ ordinalize.call(2) # Output: "2nd"
340
+ ordinalize.call(3) # Output: "3rd"
341
+ ordinalize.call(4) # Output: "4th"
342
+ ordinalize.call(11) # Output: "11th"
343
+ ordinalize.call(21) # Output: "21st"
344
+ ```
345
+
346
+ #### Pluralize
347
+
348
+ ```ruby
349
+ pluralize = Cmdlet::Inflection::Pluralize.new
350
+ pluralize.call('book') # Output: "books"
351
+ pluralize.call('child') # Output: "children"
352
+ pluralize.call('sheep') # Output: "sheep"
353
+ pluralize.call('octopus') # Output: "octopi"
354
+ ```
355
+
356
+ #### PluralizeNumber
357
+
358
+ ```ruby
359
+ pluralize_number = Cmdlet::Inflection::PluralizeNumber.new
360
+ pluralize_number.call('book', 1) # Output: "book"
361
+ pluralize_number.call('book', 2) # Output: "books"
362
+ pluralize_number.call('child', 3) # Output: "children"
363
+ ```
364
+
365
+ #### PluralizeNumberWord
366
+
367
+ ```ruby
368
+ pluralize_number_word = Cmdlet::Inflection::PluralizeNumberWord.new
369
+ pluralize_number_word.call('book', 1) # Output: "1 book"
370
+ pluralize_number_word.call('book', 2) # Output: "2 books"
371
+ pluralize_number_word.call('child', 3) # Output: "3 children"
372
+ ```
373
+
374
+ #### Singularize
375
+
376
+ ```ruby
377
+ singularize = Cmdlet::Inflection::Singularize.new
378
+ singularize.call('books') # Output: "book"
379
+ singularize.call('children') # Output: "child"
380
+ singularize.call('sheep') # Output: "sheep"
381
+ singularize.call('octopi') # Output: "octopus"
382
+ ```
383
+
384
+ ### Miscellaneous Operations
385
+
386
+ #### FormatJson
387
+
388
+ ```ruby
389
+ format_json = Cmdlet::Misc::FormatJson.new
390
+ data = { name: "John Doe", age: 30, hobbies: ["reading", "cycling"] }
391
+ formatted = format_json.call(data)
392
+ puts formatted
393
+ # Output:
394
+ # {
395
+ # "name": "John Doe",
396
+ # "age": 30,
397
+ # "hobbies": [
398
+ # "reading",
399
+ # "cycling"
400
+ # ]
401
+ # }
402
+ ```
403
+
404
+ #### Safe
405
+
406
+ ```ruby
407
+ safe = Cmdlet::Misc::Safe.new
408
+ safe.call(nil) # Output: ""
409
+ safe.call(nil, default: "N/A") # Output: "N/A"
410
+ safe.call("Hello") # Output: "Hello"
411
+ ```
412
+
413
+ ### String Operations
414
+
415
+ #### Padl
416
+
417
+ ```ruby
418
+ padl = Cmdlet::String::Padl.new
419
+ padl.call("Hello", 10) # Output: " Hello"
420
+ padl.call("World", 10, '-') # Output: "-----World"
421
+ ```
422
+
423
+ #### Padr
424
+
425
+ ```ruby
426
+ padr = Cmdlet::String::Padr.new
427
+ padr.call("Hello", 10) # Output: "Hello "
428
+ padr.call("World", 10, '-') # Output: "World-----"
429
+ ```
430
+
431
+ These examples demonstrate how to use each of the Inflection, Miscellaneous, and String operations provided by the Cmdlet gem. Each operation is shown with typical use cases to give users a clear understanding of how they function and what output to expect.
432
+
433
+ ## Advanced Usage
434
+ Explain any advanced features or techniques for using Cmdlet.
435
+
436
+ ## Troubleshooting
437
+ List common issues and their solutions.
438
+
439
+ ## Contributing
440
+ Provide information on how developers can contribute to the Cmdlet project.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cmdlet
4
- VERSION = '0.13.2'
4
+ VERSION = '0.14.0'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.13.2",
3
+ "version": "0.14.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "cmdlet",
9
- "version": "0.13.2",
9
+ "version": "0.14.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.13.2",
3
+ "version": "0.14.0",
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmdlet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.2
4
+ version: 0.14.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: 2024-07-05 00:00:00.000000000 Z
11
+ date: 2024-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -93,6 +93,7 @@ files:
93
93
  - Rakefile
94
94
  - bin/console
95
95
  - bin/setup
96
+ - docs/usage.md
96
97
  - lib/cmdlet.rb
97
98
  - lib/cmdlet/_.rb
98
99
  - lib/cmdlet/all_commands.rb