cmdlet 0.1.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.templates/{require_all_cmdlets.rb → cmdlets_require_all.rb} +0 -0
  3. data/.builders/.templates/handlebars_helper.rb +17 -0
  4. data/.builders/.templates/handlebars_helper_require_all.rb +5 -0
  5. data/.builders/.templates/handlebars_helper_spec.rb +26 -0
  6. data/.builders/boot.rb +4 -0
  7. data/.builders/data/cmdlets/case.json +313 -0
  8. data/.builders/data/cmdlets/inflection.json +129 -0
  9. data/.builders/director/category_director.rb +6 -1
  10. data/.builders/director/cmdlet_director.rb +8 -0
  11. data/.builders/generators/cmdlets/array.rb +0 -38
  12. data/.builders/generators/cmdlets/case.rb +184 -0
  13. data/.builders/generators/cmdlets/comparison.rb +1 -39
  14. data/.builders/generators/cmdlets/inflection.rb +93 -0
  15. data/CHANGELOG.md +22 -0
  16. data/lib/cmdlet/_.rb +19 -0
  17. data/lib/cmdlet/base_cmdlet.rb +1 -1
  18. data/lib/cmdlet/case/back_slash.rb +16 -0
  19. data/lib/cmdlet/case/camel.rb +16 -0
  20. data/lib/cmdlet/case/constant.rb +16 -0
  21. data/lib/cmdlet/case/dash.rb +16 -0
  22. data/lib/cmdlet/case/dot.rb +16 -0
  23. data/lib/cmdlet/case/double_colon.rb +16 -0
  24. data/lib/cmdlet/case/human.rb +20 -0
  25. data/lib/cmdlet/case/lamel.rb +16 -0
  26. data/lib/cmdlet/case/lower.rb +18 -0
  27. data/lib/cmdlet/case/sentence.rb +20 -0
  28. data/lib/cmdlet/case/slash.rb +16 -0
  29. data/lib/cmdlet/case/snake.rb +16 -0
  30. data/lib/cmdlet/case/title.rb +21 -0
  31. data/lib/cmdlet/case/upper.rb +18 -0
  32. data/lib/cmdlet/inflection/ordinal.rb +20 -0
  33. data/lib/cmdlet/inflection/ordinalize.rb +20 -0
  34. data/lib/cmdlet/inflection/pluralize.rb +20 -0
  35. data/lib/cmdlet/inflection/pluralize_by_number.rb +28 -0
  36. data/lib/cmdlet/inflection/singularize.rb +20 -0
  37. data/lib/cmdlet/version.rb +1 -1
  38. data/lib/cmdlet.rb +2 -0
  39. data/package-lock.json +2 -2
  40. data/package.json +1 -1
  41. metadata +29 -3
@@ -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
@@ -11,7 +11,7 @@ KManager.action :comparison_commands do
11
11
 
12
12
  parameter :values, 'list of values (via *splat) to be checked via AND condition', splat: '*', param_type: 'Object'
13
13
 
14
- ruby <<-RUBY
14
+ ruby <<-RUBY
15
15
  values.all? { |value| value }
16
16
  RUBY
17
17
  end
@@ -124,41 +124,3 @@ KManager.action :comparison_commands do
124
124
  .debug
125
125
  end
126
126
  end
127
-
128
- # result "return block when every value is truthy"
129
-
130
- # parameter('values', 'list of values (via *splat) to be checked via AND condition', splat: true)
131
-
132
- # example <<-TEXT
133
- # {{#if (and p1 p2 p3 p4 p5)}}
134
- # found
135
- # {{/if}}
136
- # TEXT
137
-
138
- # example <<-TEXT
139
- # {{#if (and name age)}}
140
- # {{name}}-{{age}}
141
- # {{else}}
142
- # no name or age
143
- # {{/if}}
144
- # TEXT
145
-
146
- # builder
147
- # .add_file('FUNCTIONS.md',
148
- # template_file: 'FUNCTIONS.md',
149
- # categories: categories.sort_by { |r| r.name },
150
- # functions: functions.sort_by { |r| [r.category, r.name] },
151
- # on_exist: :write)
152
-
153
- # add('all_commands.rb',
154
- # template_file: 'all_commands.rb',
155
- # commands: commands.sort_by { |r| [r.category, r.name] },
156
- # on_exist: :write)
157
-
158
- # cmdlets.each do |cmdlet|
159
-
160
- # add("#{cmdlet.category}/#{cmdlet.name}.rb",
161
- # cmdlet: cmdlet,
162
- # template_file: 'command.rb',
163
- # on_exist: :write)
164
- # end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ KManager.action :inflection_commands do
4
+ action do
5
+ CmdletDirector
6
+ .init(k_builder, category: :inflection)
7
+ .cmdlet do
8
+ name :ordinal
9
+ description 'The suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th'
10
+ result 'ordinal suffix that would be required for a number'
11
+
12
+ parameter :value, 'value - numeric value', param_type: 'String|Int'
13
+
14
+ ruby <<-RUBY
15
+ return '' if value.nil?
16
+
17
+ value = value.to_i if value.is_a? String
18
+
19
+ value.ordinal
20
+ RUBY
21
+ end
22
+ .cmdlet do
23
+ name :ordinalize
24
+ description 'Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.'
25
+ result 'number value turned to 1st, 2nd, 3rd, 4th etc.'
26
+
27
+ parameter :value, 'value - numeric value', param_type: 'Int'
28
+
29
+ ruby <<-RUBY
30
+ return '' if value.nil?
31
+
32
+ value = value.to_i if value.is_a? String
33
+
34
+ value.ordinalize
35
+ RUBY
36
+ end
37
+ .cmdlet do
38
+ name :pluralize
39
+ description 'Returns the plural form of the word in the string'
40
+ result 'value in plural form'
41
+
42
+ parameter :value, 'value - value to pluralize', param_type: 'String'
43
+
44
+ ruby <<-RUBY
45
+ return '' if value.nil?
46
+
47
+ value = value.to_s if value.is_a?(Symbol)
48
+
49
+ value.pluralize
50
+ RUBY
51
+ end
52
+ .cmdlet do
53
+ name :pluralize_by_number
54
+ description 'Returns the plural form of the word based on a count'
55
+ result 'value and number are used to calculate plural/singular form'
56
+
57
+ parameter :value, 'value - value to pluralize', param_type: 'String'
58
+ parameter :count, 'count used to determine pluralization', param_type: 'Int'
59
+ parameter :format, '(Optional) what format should output be. :word, :number_word'
60
+
61
+ ruby <<-'RUBY'
62
+ return '' if value.nil?
63
+
64
+ count = count.to_i if count.is_a? String
65
+ format = :word if format.nil?
66
+
67
+ case format.to_sym
68
+ when :number_word, :number_and_word
69
+ "#{count} #{value.pluralize(count)}"
70
+ else # aka :word
71
+ value.pluralize(count)
72
+ end
73
+ RUBY
74
+ end
75
+ .cmdlet do
76
+ name :singularize
77
+ description 'The reverse of #pluralize, returns the singular form of a word in a string'
78
+ result 'plural value turned to singular value'
79
+
80
+ parameter :value, 'value - value to singularized', param_type: 'String'
81
+
82
+ ruby <<-RUBY
83
+ return '' if value.nil?
84
+
85
+ value = value.to_s if value.is_a?(Symbol)
86
+
87
+ value.singularize
88
+ RUBY
89
+ end
90
+ .generate
91
+ .debug
92
+ end
93
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## [0.2.1](https://github.com/klueless-io/cmdlet/compare/v0.2.0...v0.2.1) (2022-07-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add case commandlets ([b269f2a](https://github.com/klueless-io/cmdlet/commit/b269f2a770dd698119f360d47756b47bd5b57516))
7
+
8
+ # [0.2.0](https://github.com/klueless-io/cmdlet/compare/v0.1.2...v0.2.0) (2022-07-10)
9
+
10
+
11
+ ### Features
12
+
13
+ * add inflection cmdlets ([55bb73f](https://github.com/klueless-io/cmdlet/commit/55bb73fe3420096a1d4edd85d207529507c088db))
14
+
15
+ ## [0.1.2](https://github.com/klueless-io/cmdlet/compare/v0.1.1...v0.1.2) (2022-07-10)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * add comparison :or ([633633d](https://github.com/klueless-io/cmdlet/commit/633633d2a22b98a0de1acf6257feb3603a2f2c39))
21
+ * add comparison :or, :and, :lt, :lte, :gt, :gte, :ne, :eq, :default ([000cb1a](https://github.com/klueless-io/cmdlet/commit/000cb1a3cbd643abcb5dac6828972ec94c9f53a8))
22
+
1
23
  ## [0.1.1](https://github.com/klueless-io/cmdlet/compare/v0.1.0...v0.1.1) (2022-07-10)
2
24
 
3
25
 
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'
@@ -12,3 +26,8 @@ require_relative 'comparison/lt'
12
26
  require_relative 'comparison/lte'
13
27
  require_relative 'comparison/ne'
14
28
  require_relative 'comparison/or'
29
+ require_relative 'inflection/ordinal'
30
+ require_relative 'inflection/ordinalize'
31
+ require_relative 'inflection/pluralize'
32
+ require_relative 'inflection/pluralize_by_number'
33
+ require_relative 'inflection/singularize'
@@ -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
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Inflection handling routines, eg. pluralize, singular, ordinalize
5
+ module Inflection
6
+ # Ordinal: The suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th
7
+ class Ordinal < Cmdlet::BaseCmdlet
8
+ #
9
+ # @param [String|Int] value - value - numeric value
10
+ # @return [String] ordinal suffix that would be required for a number
11
+ def call(value)
12
+ return '' if value.nil?
13
+
14
+ value = value.to_i if value.is_a? String
15
+
16
+ value.ordinal
17
+ end
18
+ end
19
+ end
20
+ end