cmdlet 0.9.0 → 0.10.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: 8f7f5033d225df4b35b6a961a515faf199316fe55fc3ef9ab18b3d5acf93ce08
4
- data.tar.gz: 6920780dde8303786350981f8312463cc7badb02b986c9c672de838889da2cd0
3
+ metadata.gz: 838f77f0abbcd638881e7172b1b51de493642ed08759d260bd19ec53f57cfa2c
4
+ data.tar.gz: 28b1aebad3a1ab88af71dd69c0bfbaf4925af1b5d3ed9ebebe853cc74612b518
5
5
  SHA512:
6
- metadata.gz: ff16d31f2830a656da55e744cab680818e3ef6a44682f54b5456af19416e2e3188507020929ba82cca92a72c24506cd661b3d4b0d9738f2a96fa9a179731f4dc
7
- data.tar.gz: 244346de4337b08d1ef29faf115da1b01a4ce31f98c1e0486bf2b9294d089d3644218783304638984a62bea3d0e21d4edf87126e10fa31d1b398bca12aa4dd45
6
+ metadata.gz: ca04fe9945aef2e6a74074cf1667aa6bac38599323ec575e947a0fb04f917fe583a975912ad0fe7ae38577dde1cfcb8db4f876f2ecab5f0b9804b1beb3409677
7
+ data.tar.gz: 48158ed2c3f7d91764361ce27764809689049f3606a534e212cd360b7469eec939262c3221339e305a3a67870f8b38baa64c4a41423dec62217938eea6209a64
@@ -19,6 +19,10 @@
19
19
  {
20
20
  "name": "misc",
21
21
  "description": "Miscellaneous cmdlets"
22
+ },
23
+ {
24
+ "name": "str",
25
+ "description": "String manipulation"
22
26
  }
23
27
  ]
24
28
  }
@@ -0,0 +1,83 @@
1
+ {
2
+ "category_key": "str",
3
+ "cmdlets": [
4
+ {
5
+ "name": "padl",
6
+ "aliases": [
7
+
8
+ ],
9
+ "description": "take the value and give it padding on the left hand side",
10
+ "result": "the value padded on LHS with [char (default ' ')] and [count (default 30)]",
11
+ "category": "str",
12
+ "category_description": "String manipulation",
13
+ "base_class_require": null,
14
+ "base_class": null,
15
+ "parameters": [
16
+ {
17
+ "name": "value",
18
+ "description": "value to apply padding to",
19
+ "splat": null,
20
+ "default": null,
21
+ "param_type": "String|Symbol|Int"
22
+ },
23
+ {
24
+ "name": "count",
25
+ "description": "how much padding to apply. defaults to configuration.padl_count",
26
+ "splat": null,
27
+ "default": "nil",
28
+ "param_type": "Int"
29
+ },
30
+ {
31
+ "name": "char",
32
+ "description": "character to pad with. defaults to configuration.padl_char",
33
+ "splat": null,
34
+ "default": "nil",
35
+ "param_type": "String"
36
+ }
37
+ ],
38
+ "examples": [
39
+
40
+ ],
41
+ "ruby": " value = '' if value.nil?\n count = KConfig.configuration.cmdlet.padl_count if count.nil?\n count = count.to_i if count.is_a?(String)\n char = KConfig.configuration.cmdlet.padl_char if char.nil?\n value.to_s.rjust(count, char)\n"
42
+ },
43
+ {
44
+ "name": "padr",
45
+ "aliases": [
46
+
47
+ ],
48
+ "description": "take the value and give it padding on the right hand side",
49
+ "result": "the value padded on RHS with [char (default ' ')] and [count (default 30)]",
50
+ "category": "str",
51
+ "category_description": "String manipulation",
52
+ "base_class_require": null,
53
+ "base_class": null,
54
+ "parameters": [
55
+ {
56
+ "name": "value",
57
+ "description": "value to apply padding to",
58
+ "splat": null,
59
+ "default": null,
60
+ "param_type": "String|Symbol|Int"
61
+ },
62
+ {
63
+ "name": "count",
64
+ "description": "how much padding to apply. defaults to configuration.padr_count",
65
+ "splat": null,
66
+ "default": "nil",
67
+ "param_type": "Int"
68
+ },
69
+ {
70
+ "name": "char",
71
+ "description": "character to pad with. defaults to configuration.padr_char",
72
+ "splat": null,
73
+ "default": "nil",
74
+ "param_type": "String"
75
+ }
76
+ ],
77
+ "examples": [
78
+
79
+ ],
80
+ "ruby": " value = '' if value.nil?\n count = KConfig.configuration.cmdlet.padr_count if count.nil?\n count = count.to_i if count.is_a?(String)\n char = KConfig.configuration.cmdlet.padr_char if char.nil?\n value.to_s.ljust(count, char)\n"
81
+ }
82
+ ]
83
+ }
@@ -9,6 +9,7 @@ KManager.action :categories do
9
9
  .category(:comparison , 'Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.')
10
10
  .category(:inflection , 'Inflection handling routines, eg. pluralize, singular, ordinalize')
11
11
  .category(:misc , 'Miscellaneous cmdlets')
12
+ .category(:str , 'String manipulation')
12
13
  .save_categories
13
14
  .generate
14
15
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ KManager.action :string_commands do
4
+ action do
5
+ CmdletDirector
6
+ .init(k_builder, category: :str)
7
+ .cmdlet do
8
+ name :padl
9
+ description 'take the value and give it padding on the left hand side'
10
+ result "the value padded on LHS with [char (default ' ')] and [count (default 30)]"
11
+
12
+ parameter :value, 'value to apply padding to', param_type: 'String|Symbol|Int'
13
+ parameter :count, 'how much padding to apply. defaults to configuration.padl_count', param_type: 'Int', default: 'nil'
14
+ parameter :char , 'character to pad with. defaults to configuration.padl_char', param_type: 'String', default: 'nil'
15
+
16
+ ruby <<-RUBY
17
+ value = '' if value.nil?
18
+ count = KConfig.configuration.cmdlet.padl_count if count.nil?
19
+ count = count.to_i if count.is_a?(String)
20
+ char = KConfig.configuration.cmdlet.padl_char if char.nil?
21
+ value.to_s.rjust(count, char)
22
+ RUBY
23
+ end
24
+ .cmdlet do
25
+ name :padr
26
+ description 'take the value and give it padding on the right hand side'
27
+ result "the value padded on RHS with [char (default ' ')] and [count (default 30)]"
28
+
29
+ parameter :value, 'value to apply padding to', param_type: 'String|Symbol|Int'
30
+ parameter :count, 'how much padding to apply. defaults to configuration.padr_count', param_type: 'Int', default: 'nil'
31
+ parameter :char , 'character to pad with. defaults to configuration.padr_char', param_type: 'String', default: 'nil'
32
+
33
+ ruby <<-RUBY
34
+ value = '' if value.nil?
35
+ count = KConfig.configuration.cmdlet.padr_count if count.nil?
36
+ count = count.to_i if count.is_a?(String)
37
+ char = KConfig.configuration.cmdlet.padr_char if char.nil?
38
+ value.to_s.ljust(count, char)
39
+ RUBY
40
+ end
41
+ .generate
42
+ # .debug
43
+ end
44
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [0.9.2](https://github.com/klueless-io/cmdlet/compare/v0.9.1...v0.9.2) (2022-08-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add reset to cmdlet configuration ([72a14a8](https://github.com/klueless-io/cmdlet/commit/72a14a843e08015425c8f2fba44b4a8ccd175a85))
7
+
8
+ ## [0.9.1](https://github.com/klueless-io/cmdlet/compare/v0.9.0...v0.9.1) (2022-08-24)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add string category (str) and padl ([36e3487](https://github.com/klueless-io/cmdlet/commit/36e348715812792dc1d139f56027f82e0ec67f82))
14
+
15
+ # [0.9.0](https://github.com/klueless-io/cmdlet/compare/v0.8.0...v0.9.0) (2022-07-16)
16
+
17
+
18
+ ### Features
19
+
20
+ * add safe support ([df784a2](https://github.com/klueless-io/cmdlet/commit/df784a2ce0b95fd46b6a2d10f55d858afa377fe3))
21
+
1
22
  # [0.8.0](https://github.com/klueless-io/cmdlet/compare/v0.7.1...v0.8.0) (2022-07-15)
2
23
 
3
24
 
data/lib/cmdlet/_.rb CHANGED
@@ -32,3 +32,5 @@ require_relative 'inflection/pluralize_number'
32
32
  require_relative 'inflection/pluralize_number_word'
33
33
  require_relative 'inflection/singularize'
34
34
  require_relative 'misc/safe'
35
+ require_relative 'str/padl'
36
+ require_relative 'str/padr'
@@ -22,6 +22,11 @@ module Cmdlet
22
22
 
23
23
  def initialize
24
24
  @tokenizer = Cmdlet::StringTokenizer.new
25
+
26
+ reset
27
+ end
28
+
29
+ def reset
25
30
  @padr_count = 30
26
31
  @padr_char = ' '
27
32
  @padl_count = 30
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # String manipulation
5
+ module Str
6
+ # Padl: take the value and give it padding on the left hand side
7
+ class Padl < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Symbol|Int] value - value to apply padding to
10
+ # @param [Int] count - how much padding to apply. defaults to configuration.padl_count
11
+ # @param [String] char - character to pad with. defaults to configuration.padl_char
12
+ # @return [String] the value padded on LHS with [char (default &#x27; &#x27;)] and [count (default 30)]
13
+ def call(value, count = nil, char = nil)
14
+ value = '' if value.nil?
15
+ count = KConfig.configuration.cmdlet.padl_count if count.nil?
16
+ count = count.to_i if count.is_a?(String)
17
+ char = KConfig.configuration.cmdlet.padl_char if char.nil?
18
+ value.to_s.rjust(count, char)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # String manipulation
5
+ module Str
6
+ # Padr: take the value and give it padding on the right hand side
7
+ class Padr < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Symbol|Int] value - value to apply padding to
10
+ # @param [Int] count - how much padding to apply. defaults to configuration.padr_count
11
+ # @param [String] char - character to pad with. defaults to configuration.padr_char
12
+ # @return [String] the value padded on RHS with [char (default &#x27; &#x27;)] and [count (default 30)]
13
+ def call(value, count = nil, char = nil)
14
+ value = '' if value.nil?
15
+ count = KConfig.configuration.cmdlet.padr_count if count.nil?
16
+ count = count.to_i if count.is_a?(String)
17
+ char = KConfig.configuration.cmdlet.padr_char if char.nil?
18
+ value.to_s.ljust(count, char)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cmdlet
4
- VERSION = '0.9.0'
4
+ VERSION = '0.10.0'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "cmdlet",
9
- "version": "0.9.0",
9
+ "version": "0.10.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.9.0",
3
+ "version": "0.10.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.9.0
4
+ version: 0.10.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-16 00:00:00.000000000 Z
11
+ date: 2022-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -62,6 +62,7 @@ files:
62
62
  - ".builders/data/cmdlets/comparison.json"
63
63
  - ".builders/data/cmdlets/inflection.json"
64
64
  - ".builders/data/cmdlets/misc.json"
65
+ - ".builders/data/cmdlets/str.json"
65
66
  - ".builders/director/category_builder.rb"
66
67
  - ".builders/director/category_dao.rb"
67
68
  - ".builders/director/category_director.rb"
@@ -79,6 +80,7 @@ files:
79
80
  - ".builders/generators/cmdlets/comparison.rb"
80
81
  - ".builders/generators/cmdlets/inflection.rb"
81
82
  - ".builders/generators/cmdlets/misc.rb"
83
+ - ".builders/generators/cmdlets/str.rb"
82
84
  - ".releaserc.json"
83
85
  - ".rspec"
84
86
  - ".rubocop.yml"
@@ -128,6 +130,8 @@ files:
128
130
  - lib/cmdlet/inflection/pluralize_number_word.rb
129
131
  - lib/cmdlet/inflection/singularize.rb
130
132
  - lib/cmdlet/misc/safe.rb
133
+ - lib/cmdlet/str/padl.rb
134
+ - lib/cmdlet/str/padr.rb
131
135
  - lib/cmdlet/string_tokenizer.rb
132
136
  - lib/cmdlet/version.rb
133
137
  - package-lock.json