cmdlet 0.0.5 → 0.1.2
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 +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/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 +109 -0
- data/.builders/generators/cmdlets/comparison.rb +164 -0
- data/CHANGELOG.md +36 -0
- data/Guardfile +1 -1
- data/lib/cmdlet/_.rb +14 -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/configuration.rb +1 -1
- data/lib/cmdlet/version.rb +1 -1
- data/lib/cmdlet.rb +3 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +39 -5
- data/.builders/documents/_.rb +0 -4
- data/.builders/documents/categories.rb +0 -24
- data/.builders/documents/functions.rb +0 -226
@@ -1,121 +1,121 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
KManager.action :bootstrap do
|
2
4
|
action do
|
3
5
|
application_name = :cmdlet
|
4
6
|
|
5
7
|
# Ruby Gem Bootstrap
|
6
8
|
director = KDirector::Dsls::RubyGemDsl
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
|
118
|
-
end
|
9
|
+
.init(k_builder,
|
10
|
+
on_exist: :skip, # %i[skip write compare]
|
11
|
+
on_action: :queue # %i[queue execute]
|
12
|
+
)
|
13
|
+
.data(
|
14
|
+
ruby_version: '2.7',
|
15
|
+
application: application_name,
|
16
|
+
application_description: 'Cmdlet provides a set of functions (wrapped in the command pattern) that perform simple actions',
|
17
|
+
application_lib_path: application_name.to_s,
|
18
|
+
application_lib_namespace: 'Cmdlet',
|
19
|
+
namespaces: ['Cmdlet'],
|
20
|
+
author: 'David Cruwys',
|
21
|
+
author_email: 'david@ideasmen.com.au',
|
22
|
+
initial_semver: '0.0.1',
|
23
|
+
main_story: 'As a Developer, I want to use simple categorized functions so that I can easily add commonplace functionality to my application',
|
24
|
+
copyright_date: '2022',
|
25
|
+
website: 'http://appydave.com/gems/cmdlet'
|
26
|
+
)
|
27
|
+
.github(
|
28
|
+
active: false,
|
29
|
+
repo_name: application_name
|
30
|
+
) do
|
31
|
+
create_repository
|
32
|
+
# delete_repository
|
33
|
+
# list_repositories
|
34
|
+
open_repository
|
35
|
+
# run_command('git init')
|
36
|
+
end
|
37
|
+
.blueprint(
|
38
|
+
active: false,
|
39
|
+
name: :bin_hook,
|
40
|
+
description: 'initialize repository',
|
41
|
+
on_exist: :write
|
42
|
+
) do
|
43
|
+
cd(:app)
|
44
|
+
|
45
|
+
run_template_script('bin/runonce/git-setup.sh', dom: dom)
|
46
|
+
|
47
|
+
add('.githooks/commit-msg').run_command('chmod +x .githooks/commit-msg')
|
48
|
+
add('.githooks/pre-commit').run_command('chmod +x .githooks/pre-commit')
|
49
|
+
|
50
|
+
add('.gitignore')
|
51
|
+
|
52
|
+
run_command('git config core.hooksPath .githooks') # enable sharable githooks (developer needs to turn this on before editing rep)
|
53
|
+
|
54
|
+
run_command("git add .; git commit -m 'chore: #{options.description.downcase}'; git push")
|
55
|
+
run_command("gh repo edit -d \"#{dom[:application_description]}\"")
|
56
|
+
end
|
57
|
+
.package_json(
|
58
|
+
active: false,
|
59
|
+
name: :package_json,
|
60
|
+
description: 'Set up the package.json file for semantic versioning'
|
61
|
+
) do
|
62
|
+
add('package.json', dom: dom)
|
63
|
+
.play_actions
|
64
|
+
|
65
|
+
add_script('release', 'semantic-release')
|
66
|
+
.sort
|
67
|
+
.development
|
68
|
+
.npm_add_group('semver-ruby')
|
69
|
+
|
70
|
+
run_command("git add .; git commit -m 'chore: #{options.description.downcase}'; git push")
|
71
|
+
end
|
72
|
+
.blueprint(
|
73
|
+
active: false,
|
74
|
+
name: :opinionated,
|
75
|
+
description: 'opinionated GEM files',
|
76
|
+
on_exist: :write
|
77
|
+
) do
|
78
|
+
cd(:app)
|
79
|
+
|
80
|
+
add('bin/setup')
|
81
|
+
add('bin/console')
|
82
|
+
|
83
|
+
add("lib/#{typed_dom.application}.rb" , template_file: 'lib/applet_name.rb' , dom: dom)
|
84
|
+
add("lib/#{typed_dom.application}/version.rb" , template_file: 'lib/applet_name/version.rb' , dom: dom)
|
85
|
+
|
86
|
+
add('spec/spec_helper.rb')
|
87
|
+
add("spec/#{typed_dom.application}_spec.rb" , template_file: 'spec/applet_name_spec.rb', dom: dom)
|
88
|
+
|
89
|
+
add("#{typed_dom.application}.gemspec" , template_file: 'applet_name.gemspec', dom: dom)
|
90
|
+
add('Gemfile', dom: dom)
|
91
|
+
add('Guardfile', dom: dom)
|
92
|
+
add('Rakefile', dom: dom)
|
93
|
+
add('.rspec', dom: dom)
|
94
|
+
add('.rubocop.yml', dom: dom)
|
95
|
+
add('README.md', dom: dom)
|
96
|
+
add('CODE_OF_CONDUCT.md', dom: dom)
|
97
|
+
add('LICENSE.txt', dom: dom)
|
98
|
+
|
99
|
+
run_command('rubocop -a')
|
100
|
+
|
101
|
+
run_command("git add .; git commit -m 'chore: #{options.description.downcase}'; git push")
|
102
|
+
end
|
103
|
+
.blueprint(
|
104
|
+
active: true,
|
105
|
+
name: :ci_cd,
|
106
|
+
description: 'github actions (CI/CD)',
|
107
|
+
on_exist: :write
|
108
|
+
) do
|
109
|
+
cd(:app)
|
110
|
+
|
111
|
+
run_command('gh secret set SLACK_WEBHOOK --body "$SLACK_REPO_WEBHOOK"')
|
112
|
+
run_command('gh secret set GEM_HOST_API_KEY --body "$GEM_HOST_API_KEY"')
|
113
|
+
|
114
|
+
add('.github/workflows/main.yml')
|
115
|
+
add('.releaserc.json')
|
116
|
+
|
117
|
+
run_command("git add .; git commit -m 'chore: #{options.description.downcase}'; git push")
|
118
|
+
end
|
119
119
|
|
120
120
|
director.play_actions
|
121
121
|
# director.builder.logit
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
KManager.action :categories do
|
4
|
+
action do
|
5
|
+
CategoryDirector
|
6
|
+
.init(k_builder)
|
7
|
+
.category(:case , 'Tokenize and apply case and/or separator')
|
8
|
+
.category(:comparison , 'Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.')
|
9
|
+
.category(:inflection , 'Inflection handling routines, eg. pluralize, singular, ordinalize')
|
10
|
+
.category(:string , 'String handling helpers')
|
11
|
+
.category(:array , 'Array handling routines, eg. join, join_prefix, join_post')
|
12
|
+
.category(:transform , 'Tokenize and apply case and/or separator')
|
13
|
+
.save_categories
|
14
|
+
.generate
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
KManager.action :commands_bak do
|
4
|
+
action do
|
5
|
+
puts commands.first.function_description
|
6
|
+
# Ruby Gem Bootstrap
|
7
|
+
director = KDirector::Dsls::BasicDsl
|
8
|
+
.init(k_builder,
|
9
|
+
template_base_folder: '',
|
10
|
+
on_exist: :skip, # %i[skip write compare]
|
11
|
+
on_action: :queue # %i[queue execute]
|
12
|
+
)
|
13
|
+
.blueprint(
|
14
|
+
active: true,
|
15
|
+
name: :build_commands,
|
16
|
+
description: 'Build Commandlets',
|
17
|
+
on_exist: :write
|
18
|
+
) do
|
19
|
+
cd(:lib)
|
20
|
+
|
21
|
+
# builder
|
22
|
+
# .add_file('FUNCTIONS.md',
|
23
|
+
# template_file: 'FUNCTIONS.md',
|
24
|
+
# categories: categories.sort_by { |r| r.name },
|
25
|
+
# functions: functions.sort_by { |r| [r.category, r.name] },
|
26
|
+
# on_exist: :write)
|
27
|
+
|
28
|
+
add('all_commands.rb',
|
29
|
+
template_file: 'all_commands.rb',
|
30
|
+
commands: commands.sort_by { |r| [r.category, r.name] },
|
31
|
+
on_exist: :write)
|
32
|
+
|
33
|
+
cmdlets.each do |cmdlet|
|
34
|
+
add("#{cmdlet.category}/#{cmdlet.name}.rb",
|
35
|
+
cmdlet: cmdlet,
|
36
|
+
template_file: 'command.rb',
|
37
|
+
on_exist: :write)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
director.play_actions
|
42
|
+
# director.builder.logit
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
KManager.opts.app_name = 'commands'
|
47
|
+
KManager.opts.sleep = 2
|
48
|
+
KManager.opts.reboot_on_kill = 0
|
49
|
+
KManager.opts.reboot_sleep = 4
|
50
|
+
KManager.opts.exception_style = :short
|
51
|
+
KManager.opts.show.time_taken = true
|
52
|
+
KManager.opts.show.finished = true
|
53
|
+
KManager.opts.show.finished_message = 'FINISHED :)'
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
KManager.action :array_commands do
|
4
|
+
action do
|
5
|
+
CmdletDirector
|
6
|
+
.init(k_builder, category: :array)
|
7
|
+
.cmdlet do
|
8
|
+
name :join
|
9
|
+
description 'join an array of values with separator as a string'
|
10
|
+
result 'new String formed by joining the array elements with seperator'
|
11
|
+
|
12
|
+
parameter :values, 'array of values to join', param_type: 'String|Int'
|
13
|
+
parameter :separator, 'separator between values, defaults to comma', default: "','"
|
14
|
+
|
15
|
+
ruby <<-RUBY
|
16
|
+
return false if values.nil? || values.length == 0
|
17
|
+
values = values.reject(&:blank?)
|
18
|
+
return '' if values.length.zero?
|
19
|
+
|
20
|
+
values.join(separator)
|
21
|
+
RUBY
|
22
|
+
end
|
23
|
+
.cmdlet do
|
24
|
+
name :join_pre
|
25
|
+
description 'join an array of values with separator as a string and using the separator at the beginning of string'
|
26
|
+
|
27
|
+
parameter :values, 'array of values to join', param_type: 'String|Int'
|
28
|
+
parameter :separator, 'separator between values, defaults to comma', default: "','"
|
29
|
+
|
30
|
+
ruby <<-'RUBY'
|
31
|
+
return '' if values.nil? || !values.is_a?(::Array)
|
32
|
+
values = values.reject(&:blank?)
|
33
|
+
return '' if values.length.zero?
|
34
|
+
|
35
|
+
"#{separator}#{values.join(separator)}"
|
36
|
+
RUBY
|
37
|
+
end
|
38
|
+
.cmdlet do
|
39
|
+
name :join_pre
|
40
|
+
description 'join an array of values with separator as a string and using the separator at the beginning of string'
|
41
|
+
|
42
|
+
parameter :values, 'array of values to join', param_type: 'String|Int'
|
43
|
+
parameter :separator, 'separator between values, defaults to comma', default: "','"
|
44
|
+
|
45
|
+
ruby <<-'RUBY'
|
46
|
+
return '' if values.nil? || !values.is_a?(::Array)
|
47
|
+
values = values.reject(&:blank?)
|
48
|
+
return '' if values.length.zero?
|
49
|
+
|
50
|
+
"#{separator}#{values.join(separator)}"
|
51
|
+
RUBY
|
52
|
+
end
|
53
|
+
.cmdlet do
|
54
|
+
name :join_post
|
55
|
+
description 'join an array of values with separator as a string and using the separator at the end of string'
|
56
|
+
|
57
|
+
parameter :values, 'array of values to join', param_type: 'String|Int'
|
58
|
+
parameter :separator, 'separator between values, defaults to comma', default: "','"
|
59
|
+
|
60
|
+
ruby <<-'RUBY'
|
61
|
+
return '' if values.nil? || !values.is_a?(::Array)
|
62
|
+
values = values.reject(&:blank?)
|
63
|
+
return '' if values.length.zero?
|
64
|
+
|
65
|
+
"#{values.join(separator)}#{separator}"
|
66
|
+
RUBY
|
67
|
+
end
|
68
|
+
.generate
|
69
|
+
.debug
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# result "return block when every value is truthy"
|
74
|
+
|
75
|
+
# parameter('values', 'list of values (via *splat) to be checked via AND condition', splat: true)
|
76
|
+
|
77
|
+
# example <<-TEXT
|
78
|
+
# {{#if (and p1 p2 p3 p4 p5)}}
|
79
|
+
# found
|
80
|
+
# {{/if}}
|
81
|
+
# TEXT
|
82
|
+
|
83
|
+
# example <<-TEXT
|
84
|
+
# {{#if (and name age)}}
|
85
|
+
# {{name}}-{{age}}
|
86
|
+
# {{else}}
|
87
|
+
# no name or age
|
88
|
+
# {{/if}}
|
89
|
+
# TEXT
|
90
|
+
|
91
|
+
# builder
|
92
|
+
# .add_file('FUNCTIONS.md',
|
93
|
+
# template_file: 'FUNCTIONS.md',
|
94
|
+
# categories: categories.sort_by { |r| r.name },
|
95
|
+
# functions: functions.sort_by { |r| [r.category, r.name] },
|
96
|
+
# on_exist: :write)
|
97
|
+
|
98
|
+
# add('all_commands.rb',
|
99
|
+
# template_file: 'all_commands.rb',
|
100
|
+
# commands: commands.sort_by { |r| [r.category, r.name] },
|
101
|
+
# on_exist: :write)
|
102
|
+
|
103
|
+
# cmdlets.each do |cmdlet|
|
104
|
+
|
105
|
+
# add("#{cmdlet.category}/#{cmdlet.name}.rb",
|
106
|
+
# cmdlet: cmdlet,
|
107
|
+
# template_file: 'command.rb',
|
108
|
+
# on_exist: :write)
|
109
|
+
# end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
KManager.action :comparison_commands do
|
4
|
+
action do
|
5
|
+
CmdletDirector
|
6
|
+
.init(k_builder, category: :comparison)
|
7
|
+
.cmdlet do
|
8
|
+
name :and
|
9
|
+
description 'Return true if **all of** the given values are truthy.'
|
10
|
+
result 'return true when every value is truthy'
|
11
|
+
|
12
|
+
parameter :values, 'list of values (via *splat) to be checked via AND condition', splat: '*', param_type: 'Object'
|
13
|
+
|
14
|
+
ruby <<-RUBY
|
15
|
+
values.all? { |value| value }
|
16
|
+
RUBY
|
17
|
+
end
|
18
|
+
.cmdlet do
|
19
|
+
name :default
|
20
|
+
description 'Return true if **all of** the given values are truthy.'
|
21
|
+
result 'return true when every value is truthy'
|
22
|
+
|
23
|
+
parameter :values, 'one or more paramaters that may or may not contain nil', splat: '*', param_type: 'Object'
|
24
|
+
|
25
|
+
ruby <<-RUBY
|
26
|
+
default_value = values[-1]
|
27
|
+
|
28
|
+
find_value = values[0..-2].find { |value| !value.nil? }
|
29
|
+
|
30
|
+
find_value || default_value
|
31
|
+
RUBY
|
32
|
+
|
33
|
+
end
|
34
|
+
.cmdlet do
|
35
|
+
name :eq
|
36
|
+
description 'Return true if two values are equal'
|
37
|
+
result 'return truthy value if left hand side equals right hand side'
|
38
|
+
|
39
|
+
parameter :lhs, 'lhs - left hand side value', param_type: 'Object'
|
40
|
+
parameter :rhs, 'rhs - right hand side value', param_type: 'Object'
|
41
|
+
|
42
|
+
ruby <<-RUBY
|
43
|
+
lhs = lhs.to_s if lhs.is_a?(Symbol)
|
44
|
+
rhs = rhs.to_s if rhs.is_a?(Symbol)
|
45
|
+
|
46
|
+
lhs == rhs
|
47
|
+
RUBY
|
48
|
+
end
|
49
|
+
.cmdlet do
|
50
|
+
name :gt
|
51
|
+
description 'Return true if left hand side GREATER THAN right hand side'
|
52
|
+
result 'truthy value if left hand side GREATER THAN right hand side'
|
53
|
+
|
54
|
+
parameter :lhs, 'lhs - left hand side value', param_type: 'Object'
|
55
|
+
parameter :rhs, 'rhs - right hand side value', param_type: 'Object'
|
56
|
+
|
57
|
+
ruby <<-RUBY
|
58
|
+
lhs > rhs
|
59
|
+
RUBY
|
60
|
+
end
|
61
|
+
.cmdlet do
|
62
|
+
name :gte
|
63
|
+
description 'Return true if left hand side GREATER THAN or EQUAL TO right hand side'
|
64
|
+
result 'truthy value if left hand side GREATER THAN or EQUAL TO right hand side'
|
65
|
+
|
66
|
+
parameter :lhs, 'lhs - left hand side value', param_type: 'Object'
|
67
|
+
parameter :rhs, 'rhs - right hand side value', param_type: 'Object'
|
68
|
+
|
69
|
+
ruby <<-RUBY
|
70
|
+
lhs >= rhs
|
71
|
+
RUBY
|
72
|
+
end
|
73
|
+
.cmdlet do
|
74
|
+
name :lt
|
75
|
+
description 'Return true if left hand side LESS THAN right hand side'
|
76
|
+
result 'truthy value if left hand side LESS THAN right hand side'
|
77
|
+
|
78
|
+
parameter :lhs, 'lhs - left hand side value', param_type: 'Object'
|
79
|
+
parameter :rhs, 'rhs - right hand side value', param_type: 'Object'
|
80
|
+
|
81
|
+
ruby <<-RUBY
|
82
|
+
lhs < rhs
|
83
|
+
RUBY
|
84
|
+
end
|
85
|
+
.cmdlet do
|
86
|
+
name :lte
|
87
|
+
description 'Return true if left hand side LESS THAN or EQUAL TO right hand side'
|
88
|
+
result 'truthy value if left hand side LESS THAN or EQUAL TO right hand side'
|
89
|
+
|
90
|
+
parameter :lhs, 'lhs - left hand side value', param_type: 'Object'
|
91
|
+
parameter :rhs, 'rhs - right hand side value', param_type: 'Object'
|
92
|
+
|
93
|
+
ruby <<-RUBY
|
94
|
+
lhs <= rhs
|
95
|
+
RUBY
|
96
|
+
end
|
97
|
+
.cmdlet do
|
98
|
+
name :ne
|
99
|
+
description 'Return true if left hand side is NOT equal to right hand side'
|
100
|
+
result 'truthy value if left hand side is NOT equal to right hand side'
|
101
|
+
|
102
|
+
parameter :lhs, 'lhs - left hand side value', param_type: 'Object'
|
103
|
+
parameter :rhs, 'rhs - right hand side value', param_type: 'Object'
|
104
|
+
|
105
|
+
ruby <<-RUBY
|
106
|
+
lhs = lhs.to_s if lhs.is_a?(Symbol)
|
107
|
+
rhs = rhs.to_s if rhs.is_a?(Symbol)
|
108
|
+
|
109
|
+
lhs != rhs
|
110
|
+
RUBY
|
111
|
+
end
|
112
|
+
.cmdlet do
|
113
|
+
name :or
|
114
|
+
description 'Return true if any value is truthy.'
|
115
|
+
result 'return true when first value is truthy'
|
116
|
+
|
117
|
+
parameter :values, 'list of values (via *splat) to be checked via AND condition', splat: '*', param_type: 'Object'
|
118
|
+
|
119
|
+
ruby <<-RUBY
|
120
|
+
values.any? { |value| value }
|
121
|
+
RUBY
|
122
|
+
end
|
123
|
+
.generate
|
124
|
+
.debug
|
125
|
+
end
|
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
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,39 @@
|
|
1
|
+
## [0.1.1](https://github.com/klueless-io/cmdlet/compare/v0.1.0...v0.1.1) (2022-07-10)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* add specs ([80f384f](https://github.com/klueless-io/cmdlet/commit/80f384f9f7cd1c1ea67396bb12d3119c433ea139))
|
7
|
+
|
8
|
+
# [0.1.0](https://github.com/klueless-io/cmdlet/compare/v0.0.7...v0.1.0) (2022-07-09)
|
9
|
+
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
* generate commandlets ([a61948e](https://github.com/klueless-io/cmdlet/commit/a61948e285d488d3aab68a9ef3bd0c136b87170f))
|
14
|
+
|
15
|
+
## [0.0.7](https://github.com/klueless-io/cmdlet/compare/v0.0.6...v0.0.7) (2022-07-09)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* add category director ([3b72b72](https://github.com/klueless-io/cmdlet/commit/3b72b72d9f739c9a3711f14a640bb6d527e17140))
|
21
|
+
* add category director ([cea0f1a](https://github.com/klueless-io/cmdlet/commit/cea0f1ae37bfbb67d634f18cf1d315a80c1f6082))
|
22
|
+
|
23
|
+
## [0.0.6](https://github.com/klueless-io/cmdlet/compare/v0.0.5...v0.0.6) (2022-07-08)
|
24
|
+
|
25
|
+
|
26
|
+
### Bug Fixes
|
27
|
+
|
28
|
+
* add tests for configuration ([59a764f](https://github.com/klueless-io/cmdlet/commit/59a764f99f84dbe1c5b1022e8fdc2386fcced92a))
|
29
|
+
|
30
|
+
## [0.0.5](https://github.com/klueless-io/cmdlet/compare/v0.0.4...v0.0.5) (2022-07-08)
|
31
|
+
|
32
|
+
|
33
|
+
### Bug Fixes
|
34
|
+
|
35
|
+
* add string tokenizer ([9d996ff](https://github.com/klueless-io/cmdlet/commit/9d996ff97545617b894d2f29c4500dc44df492b7))
|
36
|
+
|
1
37
|
## [0.0.4](https://github.com/klueless-io/cmdlet/compare/v0.0.3...v0.0.4) (2022-07-08)
|
2
38
|
|
3
39
|
|
data/Guardfile
CHANGED
@@ -19,7 +19,7 @@ group :green_pass_then_cop, halt_on_fail: true do
|
|
19
19
|
# Ruby files
|
20
20
|
ruby = dsl.ruby
|
21
21
|
dsl.watch_spec_files_for(ruby.lib_files)
|
22
|
-
watch(%r{^lib//(.+)\.rb$}) { |m| "spec
|
22
|
+
watch(%r{^lib//(.+)\.rb$}) { |m| "spec/**/#{m[1]}_spec.rb" }
|
23
23
|
watch(%r{^lib//commands/(.+)\.rb$}) { |m| "spec/unit/commands/#{m[1]}_spec.rb" }
|
24
24
|
end
|
25
25
|
|
data/lib/cmdlet/_.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'array/join'
|
4
|
+
require_relative 'array/join_post'
|
5
|
+
require_relative 'array/join_pre'
|
6
|
+
require_relative 'comparison/and'
|
7
|
+
require_relative 'comparison/default'
|
8
|
+
require_relative 'comparison/eq'
|
9
|
+
require_relative 'comparison/gt'
|
10
|
+
require_relative 'comparison/gte'
|
11
|
+
require_relative 'comparison/lt'
|
12
|
+
require_relative 'comparison/lte'
|
13
|
+
require_relative 'comparison/ne'
|
14
|
+
require_relative 'comparison/or'
|