cmdlet 0.0.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.builders/.templates/FUNCTIONS.MD +19 -0
- data/.builders/.templates/cmdlet.rb +26 -0
- data/.builders/.templates/cmdlet_spec.rb +22 -0
- data/.builders/.templates/require_all_cmdlets.rb +5 -0
- data/.builders/_.rb +11 -1
- data/.builders/boot.rb +6 -3
- data/.builders/data/categories.json +28 -0
- data/.builders/data/cmdlets/array.json +121 -0
- data/.builders/data/cmdlets/comparison.json +245 -0
- data/.builders/data/cmdlets/inflection.json +129 -0
- data/.builders/director/category_builder.rb +26 -0
- data/.builders/director/category_dao.rb +38 -0
- data/.builders/director/category_director.rb +39 -0
- data/.builders/director/cmdlet_builder.rb +67 -0
- data/.builders/director/cmdlet_child.rb +39 -0
- data/.builders/director/cmdlet_dao.rb +29 -0
- data/.builders/director/cmdlet_director.rb +60 -0
- data/.builders/director/dao.rb +16 -0
- data/.builders/documents/commands.rb +222 -28
- data/.builders/documents/use_cases.rb +32 -34
- data/.builders/documents/x_functions.rb +7 -10
- data/.builders/generators/01-bootstrap.rb +112 -112
- data/.builders/generators/20-categories.rb +16 -0
- data/.builders/generators/30-commands-bak.rb +53 -0
- data/.builders/generators/cmdlets/array.rb +71 -0
- data/.builders/generators/cmdlets/comparison.rb +126 -0
- data/.builders/generators/cmdlets/inflection.rb +93 -0
- data/CHANGELOG.md +37 -0
- data/Guardfile +1 -1
- data/lib/cmdlet/_.rb +19 -0
- data/lib/cmdlet/all_commands.rb +3 -0
- data/lib/cmdlet/array/join.rb +22 -0
- data/lib/cmdlet/array/join_post.rb +22 -0
- data/lib/cmdlet/array/join_pre.rb +22 -0
- data/lib/cmdlet/base_cmdlet.rb +17 -0
- data/lib/cmdlet/comparison/and.rb +16 -0
- data/lib/cmdlet/comparison/default.rb +20 -0
- data/lib/cmdlet/comparison/eq.rb +20 -0
- data/lib/cmdlet/comparison/gt.rb +17 -0
- data/lib/cmdlet/comparison/gte.rb +17 -0
- data/lib/cmdlet/comparison/lt.rb +17 -0
- data/lib/cmdlet/comparison/lte.rb +17 -0
- data/lib/cmdlet/comparison/ne.rb +20 -0
- data/lib/cmdlet/comparison/or.rb +16 -0
- data/lib/cmdlet/inflection/ordinal.rb +20 -0
- data/lib/cmdlet/inflection/ordinalize.rb +20 -0
- data/lib/cmdlet/inflection/pluralize.rb +20 -0
- data/lib/cmdlet/inflection/pluralize_by_number.rb +28 -0
- data/lib/cmdlet/inflection/singularize.rb +20 -0
- data/lib/cmdlet/version.rb +1 -1
- data/lib/cmdlet.rb +5 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +46 -5
- data/.builders/documents/_.rb +0 -4
- data/.builders/documents/categories.rb +0 -24
- data/.builders/documents/functions.rb +0 -226
@@ -1,226 +0,0 @@
|
|
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
|