cmdlet 0.0.3 → 0.0.6

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: d66542098bfbb9641d3c40c9de148303dc603be24fac2c1b7bbd1c20ef76a362
4
- data.tar.gz: bd50bf086ba1c020f30986152fe0a8fc3084391d03f86416862cf8c8713d53ed
3
+ metadata.gz: a228cff2db6bbe44396a3ace5b9821d35543741aaf3d747ed4c1558b81b5122a
4
+ data.tar.gz: 3700618c940d33e2e5521b8fbc3be24cac854fe484dce81a8d2f6331cbfebf73
5
5
  SHA512:
6
- metadata.gz: 7a8d4b61be26278b044e61d702741c1ce9317e32ff9f731e3bf4e1beacd1e4c474607071d552ddc854bbba65817d110c38b543f4858b6a51669a7ea4578754f6
7
- data.tar.gz: 59f3bcd0f17b54a3e4044c14656ee6ebde73e7f434fcd2b82e14ed79206c26bb8651ec6b7921bb16adc1ad88c00a0d994e8f2c5bb93da65f4289e2a17e0a4613
6
+ metadata.gz: eaf387c0b489d2ff93d6ff10b6bf158d98d2ac265206d70ff25780fd0bd39c7a16eb54ab843b8844a586c192d52c18e31124afc133ddea403c412d6e0ffb3c3c
7
+ data.tar.gz: b599968faa50ddfbc1d8b78a7989df7e7816fedb126260b888919c6e8cdb993352b8acaa5abc29e7d3bc782a72c73d862440f3720f9fc142dffecbcf7816861d
data/.builders/_.rb CHANGED
@@ -1 +1 @@
1
- # require_relative './path/here'
1
+ require_relative './documents/_'
@@ -0,0 +1,4 @@
1
+ require_relative './categories'
2
+ require_relative './functions'
3
+ require_relative './use_cases'
4
+ require_relative './commands'
@@ -0,0 +1,24 @@
1
+ def categories
2
+ return @categories unless @categories.nil?
3
+
4
+
5
+ result = KDoc.model :document do
6
+ table :rows do
7
+ fields :name, :description
8
+
9
+ row :case , "Tokenize and apply case and/or separator"
10
+ row :comparison , "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc."
11
+ row :inflection , "Inflection handling routines, eg. pluralize, singular, ordinalize"
12
+ row :string , "String handling helpers"
13
+
14
+ row :a_array , "Array handling routines, eg. join, join_prefix, join_post"
15
+ row :a_transform , "Tokenize and apply case and/or separator"
16
+ row :a_comparison , "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc."
17
+ row :a_inflection , "Inflection handling routines, eg. pluralize, singular, ordinalize"
18
+ end
19
+ end
20
+
21
+ @categories = result.raw_data_struct.rows
22
+ end
23
+ @categories = nil
24
+
@@ -0,0 +1,31 @@
1
+ def commands
2
+ functions.map do |function|
3
+ category = categories.find { |c| c.name == function.category }
4
+
5
+
6
+ log.error("Category '#{function.category}' not found") unless category
7
+
8
+ OpenStruct.new(
9
+ category: function.category,
10
+ name: function.name,
11
+ category_description: category.description,
12
+ function_description: function.description,
13
+ ruby: function.ruby,
14
+ usecases: use_cases
15
+ .select { |uc| uc.category == function.category && uc.function == function.name }
16
+ .map { |uc|
17
+ OpenStruct.new({
18
+ category: uc.category,
19
+ function: uc.function,
20
+ inputs: uc.inputs,
21
+ nice_inputs: nice_inputs(uc.inputs),
22
+ expected_output: uc.expected_output
23
+ })
24
+ }
25
+ )
26
+ end
27
+ end
28
+
29
+ def nice_inputs(values)
30
+ values.map { |value| value.is_a?(String) ? "'#{value}'" : value }.join(', ')
31
+ end
@@ -0,0 +1,226 @@
1
+ def functions
2
+ return @functions unless @functions.nil?
3
+
4
+ result = KDoc.model :document do
5
+ table :rows do
6
+ fields :category, :name, :alias, :description, :ruby # , f(name: :params, default: [:value])
7
+
8
+ # context 'when array of string' do
9
+ # let(:value) { %w[the quick fox] }
10
+
11
+ # it { is_expected.to eq('the,quick,fox') }
12
+ # end
13
+
14
+ # context 'when array of numbers' do
15
+ # let(:value) { [1, 2, 3] }
16
+
17
+ # it { is_expected.to eq('1,2,3') }
18
+ # end
19
+
20
+ # context 'when array of symbol' do
21
+ # let(:value) { %i[the quick fox] }
22
+
23
+ # it { is_expected.to eq('the,quick,fox') }
24
+ # end
25
+
26
+ row :a_array , :join , [] , "join an array of values with separator as a string", <<-'RUBY'
27
+ return '' if value.nil? || !value.is_a?(Array)
28
+ values = value.reject(&:blank?)
29
+ return '' if value.length.zero?
30
+
31
+ separator = ','
32
+ value.join(separator)
33
+ RUBY
34
+
35
+ row :a_array , :join_pre , [] , "join an array of values with separator as a string and using the separator at the beginning of string", <<-'RUBY'
36
+ return '' if value.nil? || !value.is_a?(Array)
37
+ values = value.reject(&:blank?)
38
+ return '' if value.length.zero?
39
+
40
+ separator = ','
41
+ "#{separator}#{value.join(separator)}"
42
+ RUBY
43
+
44
+ row :a_array , :join_post , [] , "join an array of values with separator as a string and using the separator at the end of string", <<-'RUBY'
45
+ return '' if value.nil? || !value.is_a?(Array)
46
+ values = value.reject(&:blank?)
47
+ return '' if value.length.zero?
48
+
49
+ separator = ','
50
+ "#{value.join(separator)}#{separator}"
51
+ RUBY
52
+
53
+ row :a_transform , :backslash , [:back_slash] , "convert to back slash notation", <<-'RUBY'
54
+ tokenizer.parse(value, preserve_case: true, separator: '\\')
55
+ RUBY
56
+
57
+ row :a_transform , :camel , [:upper_camel, :pascal] , "convert to camel notation", <<-'RUBY'
58
+ tokenizer.parse(value).underscore.camelize
59
+ RUBY
60
+
61
+ row :a_transform , :constant , [:constantize] , "", <<-'RUBY'
62
+ tokenizer.parse(value, separator: '_').upcase
63
+ RUBY
64
+
65
+ row :a_transform , :dash , [:dasherize] , "convert to dash notation", <<-'RUBY'
66
+ tokenizer.parse(value)
67
+ RUBY
68
+
69
+ row :a_transform , :dot , [:dotirize] , "", <<-'RUBY'
70
+ tokenizer.parse(value, separator: '.')
71
+ RUBY
72
+
73
+ row :a_transform , :double_colon , [] , "", <<-'RUBY'
74
+ tokenizer.parse(value, preserve_case: true, separator: '::')
75
+ RUBY
76
+
77
+ row :a_transform , :lower , [:lowercase, :downcase] , "", <<-'RUBY'
78
+ return '' if value.nil?
79
+
80
+ value.downcase
81
+ RUBY
82
+
83
+ # row :a_transform , :format_as , [] , "", <<-'RUBY'
84
+
85
+ # RUBY
86
+
87
+ row :a_transform , :proper , [] , "Proper case capitalizes the first letter of ALL words in a string", <<-'RUBY'
88
+ tokenizer.parse(value,
89
+ separator: ' ',
90
+ preserve_case: true,
91
+ compress_prefix_numerals: false,
92
+ compress_suffix_numerals: false)
93
+ .titleize
94
+ RUBY
95
+
96
+ row :a_transform , :sentence , [:human, :humanize] , "Upper case for first letter only. Numbers will maintain their spacing", <<-'RUBY'
97
+ tokenizer.parse(value,
98
+ separator: ' ',
99
+ preserve_case: true,
100
+ compress_prefix_numerals: false,
101
+ compress_suffix_numerals: false)
102
+ .humanize
103
+ RUBY
104
+
105
+ row :a_transform , :lamel , [:lower_camel] , "", <<-'RUBY'
106
+ tokenizer.parse(value, separator: '_').camelize(:lower)
107
+ RUBY
108
+
109
+ row :a_transform , :slash , [:forwardslash, :forward_slash] , "", <<-'RUBY'
110
+ tokenizer.parse(value, preserve_case: true, separator: '/')
111
+ RUBY
112
+
113
+ row :a_transform , :snake , [:snake] , "", <<-'RUBY'
114
+ tokenizer.parse(value, separator: '_', forced_separator: true)
115
+ RUBY
116
+
117
+ row :a_transform , :title , [:titleize] , "", <<-'RUBY'
118
+ tokenizer.parse(value,
119
+ separator: ' ',
120
+ preserve_case: true,
121
+ compress_prefix_numerals: false,
122
+ compress_suffix_numerals: false)
123
+ .titleize
124
+ RUBY
125
+
126
+ row :a_transform , :upper , [:upper_case, :upcase] , "", <<-'RUBY'
127
+ return '' if value.nil?
128
+
129
+ value.upcase
130
+ RUBY
131
+
132
+
133
+ row :a_comparison , :and , [:all] , "", <<-'RUBY'
134
+ values.all? { |value| value }
135
+ RUBY
136
+
137
+ # DEFAULT does not make sense in comparison
138
+ row :a_comparison , :default , [:fallback] , "", <<-'RUBY'
139
+ default_value = values[-1]
140
+
141
+ find_value = values[0..-2].find { |value| !value.nil? }
142
+
143
+ find_value || default_value
144
+ RUBY
145
+
146
+ row :a_comparison , :eq , [:equal] , "", <<-'RUBY'
147
+ lhs = lhs.to_s if lhs.is_a?(Symbol)
148
+ rhs = rhs.to_s if rhs.is_a?(Symbol)
149
+
150
+ lhs == rhs
151
+ RUBY
152
+
153
+ row :a_comparison , :gt , [] , "", <<-'RUBY'
154
+ lhs > rhs
155
+ RUBY
156
+
157
+ row :a_comparison , :gte , [] , "", <<-'RUBY'
158
+ lhs >= rhs
159
+ RUBY
160
+
161
+ row :a_comparison , :lt , [:less_than] , "# Lt: (less than) Block helper that renders a block if `a` is **less than** `b`. If an inverse block is specified it will be rendered when falsy.", <<-'RUBY'
162
+ lhs < rhs
163
+ RUBY
164
+
165
+ row :a_comparison , :lte , [:less_than_or_equal_to] , "# Lte: (less than or equal to) Block helper that renders a block if `a` is **less than or equal to** `b`. If an inverse block is specified it will be rendered when falsy.", <<-'RUBY'
166
+ lhs <= rhs
167
+ RUBY
168
+
169
+ row :a_comparison , :ne , [:not_equal] , "# Ne: (not equal) Block helper that renders a block if `a` is **not equal to** `b`. If an inverse block is specified it will be rendered when falsy.", <<-'RUBY'
170
+ lhs = lhs.to_s if lhs.is_a?(Symbol)
171
+ rhs = rhs.to_s if rhs.is_a?(Symbol)
172
+
173
+ lhs != rhs
174
+ RUBY
175
+
176
+ row :a_comparison , :or , [:any] , "", <<-'RUBY'
177
+ values.any? { |value| value }
178
+ RUBY
179
+
180
+
181
+
182
+ row :a_inflection , :ordinal , [] , "The suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th", <<-RUBY
183
+ return '' if value.nil?
184
+
185
+ value = value.to_i if value.is_a? String
186
+
187
+ value.ordinal
188
+ RUBY
189
+
190
+ row :a_inflection , :ordinalize , [] , "Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.", <<-RUBY
191
+ return '' if value.nil?
192
+
193
+ value = value.to_i if value.is_a? String
194
+
195
+ value.ordinalize
196
+ RUBY
197
+
198
+ row :a_inflection , :pluralize , [] , "Returns the plural form of the word in the string", <<-RUBY
199
+ return '' if value.nil?
200
+
201
+ value = value.to_s if value.is_a?(Symbol)
202
+
203
+ value.pluralize
204
+ RUBY
205
+
206
+ row :a_inflection , :pluralize_by_number , [] , "Uses both a word and number to decide if the plural or singular form should be used.", <<-'RUBY'
207
+ return '' if value.nil?
208
+
209
+ count = count.to_i if count.is_a? String
210
+ format = :word if format.nil?
211
+
212
+ case format.to_sym
213
+ when :number_word, :number_and_word
214
+ "#{count} #{value.pluralize(count)}"
215
+ else # aka :word
216
+ value.pluralize(count)
217
+ end
218
+ RUBY
219
+
220
+ # row :a_inflection , :singularize , [] , ""
221
+ end
222
+ end
223
+
224
+ @functions = result.raw_data_struct.rows
225
+ end
226
+ @functions = nil
@@ -0,0 +1,136 @@
1
+ def use_cases
2
+ return @use_cases unless @use_cases.nil?
3
+
4
+ result = KDoc.model :document do
5
+
6
+ # table :inputs do
7
+ # fields :name, :value
8
+
9
+ # row :title , "Account Category"
10
+ # row :bsb_account , "ABC 123"
11
+ # row :text1 , "the Quick brown Fox 99"
12
+ # row :sentence1 , "The quick brown fox, jumped over the lazy dog"
13
+ # row :sentence2 , "The quick brown fox"
14
+ # row :sentence3 , "jumped over the lazy dog"
15
+ # row :num1 , 1
16
+ # row :num2 , 2
17
+ # row :num3 , 3
18
+
19
+ # end
20
+
21
+ sentence1 = "The quick brown fox, jumped over the lazy dog"
22
+ sentence2 = "coyote and the acme company"
23
+ text1 = "the Quick brown Fox 99"
24
+
25
+ table :rows do
26
+ # fields :category, :function, :input, :commands, :expected_value
27
+ fields :category , :function, :inputs, :expected_output
28
+
29
+ row :a_inflection , :ordinal , [1], 'st'
30
+ row :a_inflection , :ordinal , [2], 'nd'
31
+ row :a_inflection , :ordinal , [3], 'rd'
32
+ row :a_inflection , :ordinal , [4], 'th'
33
+ row :a_inflection , :ordinal , ['101'], 'st'
34
+ row :a_inflection , :ordinal , ['105'], 'th'
35
+
36
+ row :a_inflection , :ordinalize , [1], '1st'
37
+ row :a_inflection , :ordinalize , [2], '2nd'
38
+ row :a_inflection , :ordinalize , [3], '3rd'
39
+ row :a_inflection , :ordinalize , [4], '4th'
40
+ row :a_inflection , :ordinalize , ['101'], '101st'
41
+ row :a_inflection , :ordinalize , ['105'], '105th'
42
+
43
+ row :a_inflection , :pluralize , ['name'], 'names'
44
+ row :a_inflection , :pluralize , ['octopus'], 'octopi'
45
+
46
+ row :a_transform , :backslash , [text1] , 'the\quick\brown\fox99'
47
+ row :a_transform , :camel , [text1] , 'TheQuickBrownFox99'
48
+ row :a_transform , :constant , [text1] , 'THE_QUICK_BROWN_FOX99'
49
+ row :a_transform , :dash , [text1] , 'the-quick-brown-fox99'
50
+ row :a_transform , :dot , [text1] , 'the.quick.brown.fox99'
51
+ row :a_transform , :double_colon , [text1] , 'The::Quick::Brown::Fox99'
52
+ row :a_transform , :lower , [text1] , 'the quick brown fox 99'
53
+ row :a_transform , :lamel , [text1] , 'theQuickBrownFox99'
54
+ row :a_transform , :proper , [text1] , 'The Quick Brown Fox 99'
55
+ row :a_transform , :proper , [sentence1] , 'The Quick Brown Fox Jumped Over The Lazy Dog'
56
+ row :a_transform , :sentence , [text1] , 'The quick brown fox 99'
57
+ row :a_transform , :sentence , [sentence1] , 'The quick brown fox jumped over the lazy dog'
58
+ # row :a_transform , :sentence , [sentence2] , 'Coyote and the ACME company'
59
+
60
+ row :a_transform , :slash , [text1] , 'the/Quick/brown/Fox99'
61
+ row :a_transform , :snake , [text1] , 'the_quick_brown_fox99'
62
+ row :a_transform , :title , [text1] , 'The Quick Brown Fox 99'
63
+ row :a_transform , :title , [sentence1] , 'The Quick Brown Fox Jumped over the Lazy Dog'
64
+ row :a_transform , :upper , [text1] , 'THE QUICK BROWN FOX 99'
65
+
66
+
67
+ row :a_comparison , :and , [nil, nil] , false
68
+ row :a_comparison , :and , ['data', nil] , false
69
+ row :a_comparison , :and , [nil, 'data'] , false
70
+ row :a_comparison , :and , ['data', 'data'] , true
71
+ row :a_comparison , :and , ['aaa', 'bbb'] , true
72
+
73
+ # DEFAULT does not make sense in comparison
74
+ row :a_comparison , :default , [nil, 'happy'] , "happy"
75
+ row :a_comparison , :default , ['sad', 'happy'] , "sad"
76
+ row :a_comparison , :default , [nil, nil, nil, nil, 'david'] , "david"
77
+ row :a_comparison , :default , ['', 'happy'] , "happy"
78
+
79
+ # type: :strict, :equiv, :cast, :insensitive
80
+ row :a_comparison , :eq , [111, '111' ], false
81
+ row :a_comparison , :eq , [111, 111.0 ], false
82
+ row :a_comparison , :eq , ['aaa', 'aaa'], true
83
+ row :a_comparison , :eq , ['aaa', 'bbb'], false
84
+ row :a_comparison , :eq , [:aaa, :aaa] , true
85
+ row :a_comparison , :eq , ['aaa', :aaa] , false
86
+ row :a_comparison , :eq , ['aaa', 'bbb'], false
87
+ row :a_comparison , :eq , ['aaa', 'AAA'], false
88
+
89
+ row :a_comparison , :gt , [2, 1] , true
90
+ row :a_comparison , :gt , [2, 2] , false
91
+
92
+ row :a_comparison , :gte , [1, 2] , false
93
+ row :a_comparison , :gte , [1, 1] , true
94
+ row :a_comparison , :gte , [2, 1] , true
95
+
96
+ row :a_comparison , :lt , [1, 2] , true
97
+ row :a_comparison , :lt , [2, 1] , false
98
+
99
+ row :a_comparison , :lte , [1, 2] , true
100
+ row :a_comparison , :lte , [2, 2] , true
101
+ row :a_comparison , :lte , [2, 1] , false
102
+
103
+ row :a_comparison , :ne , [1, 2] , true
104
+ row :a_comparison , :ne , [1, 1] , false
105
+
106
+ row :a_comparison , :or , [nil, nil] , false
107
+ row :a_comparison , :or , ['data', nil] , true
108
+ row :a_comparison , :or , [nil, 'data'] , true
109
+ row :a_comparison , :or , ['data', 'data'] , true
110
+ row :a_comparison , :or , ['aaa', 'bbb'] , true
111
+ # row :text1 , %i[backslash] , 'the\quick\brown\fox99'
112
+ # row :text1 , %i[camel] , 'TheQuickBrownFox99'
113
+
114
+
115
+ # row :sentence3 , %i[plural] , "jumped over the lazy dogs"
116
+ # row :title , %i[plural] , "Account Categories"
117
+ # row :sentence1 , %i[dash] , "The-quick-brown-fox-jumped-over-the-lazy-dog"
118
+ # row :sentence1 , %i[natural] , "The quick brown fox, jumped over the lazy dog"
119
+ # row :sentence1 , %i[lower dash] , "the-quick-brown-fox-jumped-over-the-lazy-dog"
120
+ # row :bsb_account , %i[lower snake] , "abc_123"
121
+ # row :bsb_account , %i[slash] , "ABC/123"
122
+ end
123
+
124
+ end
125
+
126
+ @use_cases = result.raw_data_struct.rows
127
+ end
128
+ @use_cases = nil
129
+
130
+ # def self.camel_case(string, tokenizer = PreservePrefixedUnderscoreTokenizer.new)
131
+ # # DAVE INPUT 9 Oct 21 from lucky_case play
132
+ # # dependency injection: to use enhanced tokenizer
133
+ # a = split_case_string string
134
+ # converted = ([a[0]] + a[1..-1].map { |e| capital e }).join('')
135
+ # tokenizer.parse(converted)
136
+ # end
@@ -0,0 +1,66 @@
1
+
2
+ def category_blueprint
3
+
4
+ fn_builder
5
+ .init
6
+ .category(:array , active: 0 , title: 'Array' , description: 'Functions for working with Array')
7
+ .category(:cases , active: 0 , title: 'Cases' , description: 'Functions for working with Cases')
8
+ .category(:code , active: 0 , title: 'Code' , description: 'Functions for working with Code')
9
+ .category(:collection , active: 0 , title: 'Collection' , description: 'Functions for working with Collection')
10
+ .category(:comparison , active: 0 , title: 'Comparison' , description: 'Functions for working with Comparison')
11
+ .category(:date , active: 0 , title: 'Date' , description: 'Functions for working with Date')
12
+ .category(:file , active: 0 , title: 'File' , description: 'Functions for working with File')
13
+ .category(:html , active: 0 , title: 'Html' , description: 'Functions for working with Html')
14
+ .category(:i18n , active: 0 , title: 'I18n' , description: 'Functions for working with Internationalization')
15
+ .category(:inflection , active: 1 , title: 'Inflection' , description: 'Functions for working with Inflection')
16
+ .category(:logging , active: 0 , title: 'Logging' , description: 'Functions for working with Logging')
17
+ .category(:markdown , active: 0 , title: 'Markdown' , description: 'Functions for working with Markdown')
18
+ .category(:match , active: 0 , title: 'Match' , description: 'Functions for working with Match')
19
+ .category(:math , active: 0 , title: 'Math' , description: 'Functions for working with Math')
20
+ .category(:misc , active: 0 , title: 'Misc' , description: 'Functions for working with Misc')
21
+ .category(:number , active: 0 , title: 'Number' , description: 'Functions for working with Number')
22
+ .category(:object , active: 0 , title: 'Object' , description: 'Functions for working with Object')
23
+ .category(:path , active: 0 , title: 'Path' , description: 'Functions for working with Path')
24
+ .category(:regex , active: 0 , title: 'Regex' , description: 'Functions for working with Regex')
25
+ .category(:string , active: 0 , title: 'String' , description: 'Functions for working with String')
26
+ .category(:url , active: 0 , title: 'Url' , description: 'Functions for working with Url')
27
+
28
+ end
29
+
30
+ def function_blueprint
31
+
32
+ fn_builder
33
+ .init
34
+ .for_category(:array)
35
+ .for_category(:cases)
36
+ .for_category(:code)
37
+ .for_category(:collection)
38
+ .for_category(:comparison)
39
+ .for_category(:date)
40
+ .for_category(:file)
41
+ .for_category(:html)
42
+ .for_category(:i18n)
43
+ .for_category(:inflection)
44
+ .function(:ordinal)
45
+ .function(:ordinalize)
46
+ .function(:pluralize_by_number)
47
+ .function(:pluralize)
48
+ .function(:singularize)
49
+ .for_category(:logging)
50
+ .for_category(:markdown)
51
+ .for_category(:match)
52
+ .for_category(:math)
53
+ .for_category(:misc)
54
+ .for_category(:number)
55
+ .for_category(:object)
56
+ .for_category(:path)
57
+ .for_category(:regex)
58
+ .for_category(:string)
59
+ .for_category(:url)
60
+
61
+ end
62
+
63
+ # {{arrayify}}
64
+ # Cast the given value to an array.
65
+ # {{before}}
66
+ # Return all of the items in the collection before the specified count. Opposite of after.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [0.0.5](https://github.com/klueless-io/cmdlet/compare/v0.0.4...v0.0.5) (2022-07-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add string tokenizer ([9d996ff](https://github.com/klueless-io/cmdlet/commit/9d996ff97545617b894d2f29c4500dc44df492b7))
7
+
8
+ ## [0.0.4](https://github.com/klueless-io/cmdlet/compare/v0.0.3...v0.0.4) (2022-07-08)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add basic configuration ([d8ecbb1](https://github.com/klueless-io/cmdlet/commit/d8ecbb17f61600de3b3f5d8987cc132d6e5ba0b2))
14
+
15
+ ## [0.0.3](https://github.com/klueless-io/cmdlet/compare/v0.0.2...v0.0.3) (2022-07-08)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * base files for new GEM - [#2](https://github.com/klueless-io/cmdlet/issues/2) ([9d52c68](https://github.com/klueless-io/cmdlet/commit/9d52c68acfe98954c456859d40edf7db6e74e044))
21
+
1
22
  ## [0.0.2](https://github.com/klueless-io/cmdlet/compare/v0.0.1...v0.0.2) (2022-07-08)
2
23
 
3
24
 
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdlet
4
+ # Register this configuration access extension for Cmdlet configuration
5
+ module CmdletConfigurationExtension
6
+ def cmdlet
7
+ return @cmdlet if defined? @cmdlet
8
+
9
+ @cmdlet = CmdletConfiguration.new
10
+ end
11
+ end
12
+
13
+ # Structure for storing Cmdlet configuration
14
+ class CmdletConfiguration
15
+ include KLog::Logging
16
+
17
+ attr_accessor :tokenizer
18
+ attr_accessor :padl_count
19
+ attr_accessor :padl_char
20
+ attr_accessor :padr_count
21
+ attr_accessor :padr_char
22
+
23
+ def initialize
24
+ @tokenizer = Cmdlet::StringTokenizer.new
25
+ @padr_count = 30
26
+ @padr_char = ' '
27
+ @padl_count = 30
28
+ @padl_char = ' '
29
+ end
30
+ end
31
+ end
32
+
33
+ KConfig::Configuration.register(:cmdlet, Cmdlet::CmdletConfigurationExtension)
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/string'
4
+
5
+ module Cmdlet
6
+ # String tokenizer will clean up a string so that all sorts of formatted strings can be
7
+ # represented in a consistent fashion
8
+ class StringTokenizer
9
+ # Tokenize string
10
+ # rubocop:disable Metrics/ParameterLists
11
+ def parse(value,
12
+ preserve_case: false,
13
+ compress_prefix_numerals: true,
14
+ compress_suffix_numerals: true,
15
+ separator: '-',
16
+ forced_separator: false)
17
+ return '' if value.nil?
18
+
19
+ # Insert space before any lowercaseUppercase
20
+ value = value.gsub(/(?<=[a-z])(?=[A-Z])/, ' ')
21
+
22
+ # make sure that any numbers followed by space and then some text has the white space removed
23
+ value = value.gsub(/^(\d*)(\s*)/, '\1') if compress_prefix_numerals
24
+
25
+ # Technique1: make sure that trailing space followed by number is compressed
26
+ # NOTE: named groups don't seem to work with \1, \2 etc.
27
+ # ex = /(?<space>[\s]*)(?<number>[\d]*)$/
28
+ # value =value.sub(ex) { |_| Regexp.last_match[:number] }
29
+
30
+ # Technique2: make sure that trailing space followed by number is compressed
31
+ value = value.gsub(/(\s*)(\d*)$/, '\2') if compress_suffix_numerals
32
+
33
+ value = value.parameterize(preserve_case: preserve_case, separator: separator) # (separator: ' ')
34
+
35
+ value = value.gsub(/[-_]/, separator) if forced_separator
36
+
37
+ value
38
+ end
39
+ # rubocop:enable Metrics/ParameterLists
40
+ end
41
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cmdlet
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.6'
5
5
  end
data/lib/cmdlet.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # require 'k_log'
4
+ require 'k_config'
3
5
  require_relative 'cmdlet/version'
6
+ require_relative 'cmdlet/configuration'
7
+ require_relative 'cmdlet/string_tokenizer'
4
8
 
5
9
  module Cmdlet
6
10
  # raise Cmdlet::Error, 'Sample message'
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.0.3",
3
+ "version": "0.0.6",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "cmdlet",
9
- "version": "0.0.3",
9
+ "version": "0.0.6",
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.0.3",
3
+ "version": "0.0.6",
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.0.3
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
@@ -11,19 +11,33 @@ cert_chain: []
11
11
  date: 2022-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: k_log
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.0
19
+ version: '6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.0
26
+ version: '6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: k_config
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.3
27
41
  description: " Cmdlet provides a set of functions (wrapped in the command pattern)
28
42
  that perform simple actions\n"
29
43
  email:
@@ -34,6 +48,12 @@ extra_rdoc_files: []
34
48
  files:
35
49
  - ".builders/_.rb"
36
50
  - ".builders/boot.rb"
51
+ - ".builders/documents/_.rb"
52
+ - ".builders/documents/categories.rb"
53
+ - ".builders/documents/commands.rb"
54
+ - ".builders/documents/functions.rb"
55
+ - ".builders/documents/use_cases.rb"
56
+ - ".builders/documents/x_functions.rb"
37
57
  - ".builders/generators/01-bootstrap.rb"
38
58
  - ".releaserc.json"
39
59
  - ".rspec"
@@ -48,6 +68,8 @@ files:
48
68
  - bin/console
49
69
  - bin/setup
50
70
  - lib/cmdlet.rb
71
+ - lib/cmdlet/configuration.rb
72
+ - lib/cmdlet/string_tokenizer.rb
51
73
  - lib/cmdlet/version.rb
52
74
  - package-lock.json
53
75
  - package.json