cmdlet 0.0.7 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.templates/cmdlet.rb +26 -0
  3. data/.builders/.templates/{command_spec.rb → cmdlet_spec.rb} +4 -4
  4. data/.builders/.templates/require_all_cmdlets.rb +5 -0
  5. data/.builders/_.rb +7 -1
  6. data/.builders/boot.rb +2 -0
  7. data/.builders/data/categories.json +2 -10
  8. data/.builders/data/cmdlets/array.json +121 -0
  9. data/.builders/data/cmdlets/comparison.json +245 -0
  10. data/.builders/director/category_builder.rb +26 -0
  11. data/.builders/director/category_dao.rb +38 -0
  12. data/.builders/director/category_director.rb +24 -10
  13. data/.builders/director/cmdlet_builder.rb +27 -34
  14. data/.builders/director/cmdlet_child.rb +16 -44
  15. data/.builders/director/cmdlet_dao.rb +29 -0
  16. data/.builders/director/cmdlet_director.rb +37 -13
  17. data/.builders/director/dao.rb +16 -0
  18. data/.builders/documents/commands.rb +15 -16
  19. data/.builders/documents/use_cases.rb +32 -34
  20. data/.builders/documents/x_functions.rb +7 -10
  21. data/.builders/generators/01-bootstrap.rb +112 -112
  22. data/.builders/generators/20-categories.rb +16 -0
  23. data/.builders/generators/30-commands-bak.rb +53 -0
  24. data/.builders/generators/cmdlets/array.rb +109 -0
  25. data/.builders/generators/cmdlets/comparison.rb +164 -0
  26. data/CHANGELOG.md +22 -0
  27. data/Guardfile +1 -1
  28. data/lib/cmdlet/_.rb +14 -0
  29. data/lib/cmdlet/array/join.rb +8 -10
  30. data/lib/cmdlet/array/join_post.rb +22 -0
  31. data/lib/cmdlet/array/join_pre.rb +22 -0
  32. data/lib/cmdlet/base_cmdlet.rb +17 -0
  33. data/lib/cmdlet/comparison/and.rb +16 -0
  34. data/lib/cmdlet/comparison/default.rb +20 -0
  35. data/lib/cmdlet/comparison/eq.rb +20 -0
  36. data/lib/cmdlet/comparison/gt.rb +17 -0
  37. data/lib/cmdlet/comparison/gte.rb +17 -0
  38. data/lib/cmdlet/comparison/lt.rb +17 -0
  39. data/lib/cmdlet/comparison/lte.rb +17 -0
  40. data/lib/cmdlet/comparison/ne.rb +20 -0
  41. data/lib/cmdlet/comparison/or.rb +16 -0
  42. data/lib/cmdlet/version.rb +1 -1
  43. data/lib/cmdlet.rb +3 -0
  44. data/package-lock.json +2 -2
  45. data/package.json +1 -1
  46. metadata +28 -9
  47. data/.builders/.templates/all_commands.rb +0 -5
  48. data/.builders/.templates/command.rb +0 -26
  49. data/.builders/documents/categories.rb +0 -24
  50. data/.builders/documents/cmdlets.rb +0 -30
  51. data/.builders/generators/20-commands.rb +0 -54
  52. data/.builders/generators/25-categories.rb +0 -20
@@ -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
- .init(k_builder,
8
- on_exist: :skip, # %i[skip write compare]
9
- on_action: :queue # %i[queue execute]
10
- )
11
- .data(
12
- ruby_version: '2.7',
13
- application: application_name,
14
- application_description: 'Cmdlet provides a set of functions (wrapped in the command pattern) that perform simple actions',
15
- application_lib_path: application_name.to_s,
16
- application_lib_namespace: 'Cmdlet',
17
- namespaces: ['Cmdlet'],
18
- author: 'David Cruwys',
19
- author_email: 'david@ideasmen.com.au',
20
- initial_semver: '0.0.1',
21
- main_story: 'As a Developer, I want to use simple categorized functions so that I can easily add commonplace functionality to my application',
22
- copyright_date: '2022',
23
- website: 'http://appydave.com/gems/cmdlet'
24
- )
25
- .github(
26
- active: false,
27
- repo_name: application_name
28
- ) do
29
- create_repository
30
- # delete_repository
31
- # list_repositories
32
- open_repository
33
- # run_command('git init')
34
- end
35
- .blueprint(
36
- active: false,
37
- name: :bin_hook,
38
- description: 'initialize repository',
39
- on_exist: :write) do
40
-
41
- cd(:app)
42
-
43
- run_template_script('bin/runonce/git-setup.sh', dom: dom)
44
-
45
- add('.githooks/commit-msg').run_command('chmod +x .githooks/commit-msg')
46
- add('.githooks/pre-commit').run_command('chmod +x .githooks/pre-commit')
47
-
48
- add('.gitignore')
49
-
50
- run_command('git config core.hooksPath .githooks') # enable sharable githooks (developer needs to turn this on before editing rep)
51
-
52
- run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
53
- run_command("gh repo edit -d \"#{dom[:application_description]}\"")
54
- end
55
- .package_json(
56
- active: false,
57
- name: :package_json,
58
- description: 'Set up the package.json file for semantic versioning'
59
- ) do
60
- self
61
- .add('package.json', dom: dom)
62
- .play_actions
63
-
64
- self
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: #{self.options.description.downcase}'; git push")
71
- end
72
- .blueprint(
73
- active: false,
74
- name: :opinionated,
75
- description: 'opinionated GEM files',
76
- on_exist: :write) do
77
-
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: #{self.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) do
108
-
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: #{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,25 @@
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
+
1
23
  ## [0.0.6](https://github.com/klueless-io/cmdlet/compare/v0.0.5...v0.0.6) (2022-07-08)
2
24
 
3
25
 
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/unit/#{m[1]}_spec.rb" }
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'
@@ -1,22 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # reference: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb
4
-
5
3
  module Cmdlet
6
4
  # Array handling routines, eg. join, join_prefix, join_post
7
5
  module Array
8
6
  # Join: join an array of values with separator as a string
9
- class Join < Funcky::BaseFunction
7
+ class Join < Cmdlet::BaseCmdlet
10
8
  #
11
- # @param [String|Int] value - numeric value
12
- # @return [String] ordinal suffix that would be required for a number
13
- def parse(value)
14
- return '' if value.nil? || !value.is_a?(Array)
9
+ # @param [String|Int] values - array of values to join
10
+ # @param [String] separator - separator between values, defaults to comma
11
+ # @return [String] new String formed by joining the array elements with seperator
12
+ def call(values, separator = ',')
13
+ return false if values.nil? || values.length.zero?
15
14
 
16
- values = value.reject(&:blank?)
17
- return '' if value.length.zero?
15
+ values = values.reject(&:blank?)
16
+ return '' if values.length.zero?
18
17
 
19
- separator = ','
20
18
  values.join(separator)
21
19
  end
22
20
  end