cmdlet 0.0.7 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) 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/case.json +313 -0
  10. data/.builders/data/cmdlets/comparison.json +245 -0
  11. data/.builders/data/cmdlets/inflection.json +129 -0
  12. data/.builders/director/category_builder.rb +26 -0
  13. data/.builders/director/category_dao.rb +38 -0
  14. data/.builders/director/category_director.rb +24 -10
  15. data/.builders/director/cmdlet_builder.rb +27 -34
  16. data/.builders/director/cmdlet_child.rb +16 -44
  17. data/.builders/director/cmdlet_dao.rb +29 -0
  18. data/.builders/director/cmdlet_director.rb +37 -13
  19. data/.builders/director/dao.rb +16 -0
  20. data/.builders/documents/commands.rb +15 -16
  21. data/.builders/documents/use_cases.rb +32 -34
  22. data/.builders/documents/x_functions.rb +7 -10
  23. data/.builders/generators/01-bootstrap.rb +112 -112
  24. data/.builders/generators/20-categories.rb +16 -0
  25. data/.builders/generators/30-commands-bak.rb +53 -0
  26. data/.builders/generators/cmdlets/array.rb +71 -0
  27. data/.builders/generators/cmdlets/case.rb +184 -0
  28. data/.builders/generators/cmdlets/comparison.rb +126 -0
  29. data/.builders/generators/cmdlets/inflection.rb +93 -0
  30. data/CHANGELOG.md +37 -0
  31. data/Guardfile +1 -1
  32. data/lib/cmdlet/_.rb +33 -0
  33. data/lib/cmdlet/array/join.rb +8 -10
  34. data/lib/cmdlet/array/join_post.rb +22 -0
  35. data/lib/cmdlet/array/join_pre.rb +22 -0
  36. data/lib/cmdlet/base_cmdlet.rb +17 -0
  37. data/lib/cmdlet/case/back_slash.rb +16 -0
  38. data/lib/cmdlet/case/camel.rb +16 -0
  39. data/lib/cmdlet/case/constant.rb +16 -0
  40. data/lib/cmdlet/case/dash.rb +16 -0
  41. data/lib/cmdlet/case/dot.rb +16 -0
  42. data/lib/cmdlet/case/double_colon.rb +16 -0
  43. data/lib/cmdlet/case/human.rb +20 -0
  44. data/lib/cmdlet/case/lamel.rb +16 -0
  45. data/lib/cmdlet/case/lower.rb +18 -0
  46. data/lib/cmdlet/case/sentence.rb +20 -0
  47. data/lib/cmdlet/case/slash.rb +16 -0
  48. data/lib/cmdlet/case/snake.rb +16 -0
  49. data/lib/cmdlet/case/title.rb +21 -0
  50. data/lib/cmdlet/case/upper.rb +18 -0
  51. data/lib/cmdlet/comparison/and.rb +16 -0
  52. data/lib/cmdlet/comparison/default.rb +20 -0
  53. data/lib/cmdlet/comparison/eq.rb +20 -0
  54. data/lib/cmdlet/comparison/gt.rb +17 -0
  55. data/lib/cmdlet/comparison/gte.rb +17 -0
  56. data/lib/cmdlet/comparison/lt.rb +17 -0
  57. data/lib/cmdlet/comparison/lte.rb +17 -0
  58. data/lib/cmdlet/comparison/ne.rb +20 -0
  59. data/lib/cmdlet/comparison/or.rb +16 -0
  60. data/lib/cmdlet/inflection/ordinal.rb +20 -0
  61. data/lib/cmdlet/inflection/ordinalize.rb +20 -0
  62. data/lib/cmdlet/inflection/pluralize.rb +20 -0
  63. data/lib/cmdlet/inflection/pluralize_by_number.rb +28 -0
  64. data/lib/cmdlet/inflection/singularize.rb +20 -0
  65. data/lib/cmdlet/version.rb +1 -1
  66. data/lib/cmdlet.rb +5 -0
  67. data/package-lock.json +2 -2
  68. data/package.json +1 -1
  69. metadata +51 -9
  70. data/.builders/.templates/all_commands.rb +0 -5
  71. data/.builders/.templates/command.rb +0 -26
  72. data/.builders/documents/categories.rb +0 -24
  73. data/.builders/documents/cmdlets.rb +0 -30
  74. data/.builders/generators/20-commands.rb +0 -54
  75. data/.builders/generators/25-categories.rb +0 -20
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CmdletDao
4
+ attr_reader :k_builder
5
+
6
+ def initialize(k_builder)
7
+ @k_builder = k_builder
8
+ end
9
+
10
+ def all_cmdlets
11
+ data_access
12
+ .category
13
+ .categories.flat_map { |category| read_cmdlets(category[:name]) }
14
+ .compact
15
+ .uniq
16
+ .sort_by { |r| [r[:category], r[:name]] }
17
+ end
18
+
19
+ private
20
+
21
+ def read_cmdlets(category_name)
22
+ file_name = k_builder.target_folders.join(:builder_data, 'cmdlets', "#{category_name}.json")
23
+
24
+ return JSON.parse(File.read(file_name), symbolize_names: true)[:cmdlets] if File.exist?(file_name)
25
+
26
+ puts "Cmdlet file #{file_name} not found"
27
+ nil
28
+ end
29
+ end
@@ -1,36 +1,60 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class CmdletDirector < KDirector::Directors::BaseDirector
4
- default_builder_type(CmdletBuilder)
4
+ defaults(builder_type: CmdletBuilder, on_exist: :write, on_action: :execute)
5
5
 
6
- def category(name, description)
7
- builder.category(name, description)
6
+ def initialize(k_builder, builder, **opts)
7
+ super(k_builder, builder, **opts)
8
+
9
+ builder.category_key = opts[:category] || :unknown
10
+ end
11
+
12
+ def cmdlet(**opts, &block)
13
+ cmdlet = CmdletChild.new(self, **opts)
14
+ cmdlet.instance_eval(&block) if block_given?
8
15
 
9
16
  self
10
17
  end
11
18
 
12
- def helper(**opts, &block)
13
- helper = CmdletChild.new(self, **opts)
14
- helper.instance_eval(&block) if block_given?
19
+ def categories
20
+ data_access.category_director.categories
21
+ end
22
+
23
+ def generate
24
+ build_cmdlets
25
+ save_cmdlets
26
+ run_cop
15
27
 
16
28
  self
17
29
  end
18
30
 
19
- def build_helpers
20
- builder.helpers.each do |helper|
31
+ def build_cmdlets
32
+ builder.cmdlets.each do |cmdlet|
33
+ cmdlet_file = "#{cmdlet[:category]}/#{cmdlet[:name]}.rb"
34
+ cmdlet_spec_file = "#{cmdlet[:category]}/#{cmdlet[:name]}_spec.rb"
35
+
21
36
  cd(:lib)
22
- add("helpers/#{helper[:category]}/#{helper[:name]}.rb", template_file: 'helper.rb', helper: helper)
37
+ add(cmdlet_file, template_file: 'cmdlet.rb', cmdlet: cmdlet)
23
38
 
24
39
  cd(:spec)
25
- add("helpers/#{helper[:category]}/#{helper[:name]}_spec.rb", template_file: 'helper_spec.rb', helper: helper)
40
+ add(cmdlet_spec_file, template_file: 'cmdlet_spec.rb', cmdlet: cmdlet, on_exist: :skip)
26
41
  end
27
42
 
28
43
  self
29
44
  end
30
45
 
31
- def save_categories
46
+ def run_cop
47
+ Dir.chdir(k_builder.target_folders.get(:app)) do
48
+ k_builder.run_cop('**/*.rb', fix_unsafe: true)
49
+ end
50
+
51
+ self
52
+ end
53
+
54
+ def save_cmdlets
32
55
  cd(:builder_data)
33
- add('categories.json', content: JSON.pretty_generate(builder.categories.map(&:to_h)))
34
- play_actions
56
+ add("cmdlets/#{builder.category_key}.json", content: builder.to_json)
57
+
58
+ self
35
59
  end
36
60
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ def data_access
4
+ @data_access ||= Dao.new(k_builder)
5
+ end
6
+
7
+ class Dao
8
+ attr_reader :k_builder
9
+ attr_reader :category
10
+ attr_reader :cmdlet
11
+
12
+ def initialize(k_builder)
13
+ @category = CategoryDao.new(k_builder)
14
+ @cmdlet = CmdletDao.new(k_builder)
15
+ end
16
+ end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  def commands
2
4
  return @commands unless @commands.nil?
3
-
5
+
4
6
  result = KDoc.model :document do
5
7
  table :rows do
6
8
  fields :category, :name, :alias, :description, :ruby # , f(name: :params, default: [:value])
@@ -23,7 +25,7 @@ def commands
23
25
  # it { is_expected.to eq('the,quick,fox') }
24
26
  # end
25
27
 
26
- row :array , :join , [] , "join an array of values with separator as a string", <<-'RUBY'
28
+ row :array , :join , [] , 'join an array of values with separator as a string', <<-'RUBY'
27
29
  return '' if value.nil? || !value.is_a?(Array)
28
30
  values = value.reject(&:blank?)
29
31
  return '' if value.length.zero?
@@ -32,14 +34,14 @@ def commands
32
34
  values.join(separator)
33
35
  RUBY
34
36
 
35
- # row :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?
37
+ row :array , :join_pre , [] , 'join an array of values with separator as a string and using the separator at the beginning of string', <<-'RUBY'
38
+ return '' if value.nil? || !value.is_a?(Array)
39
+ values = value.reject(&:blank?)
40
+ return '' if value.length.zero?
39
41
 
40
- # separator = ','
41
- # "#{separator}#{value.join(separator)}"
42
- # RUBY
42
+ separator = ','
43
+ "#{separator}#{value.join(separator)}"
44
+ RUBY
43
45
 
44
46
  # row :array , :join_post , [] , "join an array of values with separator as a string and using the separator at the end of string", <<-'RUBY'
45
47
  # return '' if value.nil? || !value.is_a?(Array)
@@ -59,7 +61,7 @@ def commands
59
61
  # RUBY
60
62
 
61
63
  # row :a_transform , :constant , [:constantize] , "", <<-'RUBY'
62
- # tokenizer.parse(value, separator: '_').upcase
64
+ # tokenizer.parse(value, separator: '_').upcase
63
65
  # RUBY
64
66
 
65
67
  # row :a_transform , :dash , [:dasherize] , "convert to dash notation", <<-'RUBY'
@@ -81,7 +83,7 @@ def commands
81
83
  # RUBY
82
84
 
83
85
  # # row :a_transform , :format_as , [] , "", <<-'RUBY'
84
-
86
+
85
87
  # # RUBY
86
88
 
87
89
  # row :a_transform , :proper , [] , "Proper case capitalizes the first letter of ALL words in a string", <<-'RUBY'
@@ -129,7 +131,6 @@ def commands
129
131
  # value.upcase
130
132
  # RUBY
131
133
 
132
-
133
134
  # row :a_comparison , :and , [:all] , "", <<-'RUBY'
134
135
  # values.all? { |value| value }
135
136
  # RUBY
@@ -177,8 +178,6 @@ def commands
177
178
  # values.any? { |value| value }
178
179
  # RUBY
179
180
 
180
-
181
-
182
181
  # 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
182
  # return '' if value.nil?
184
183
 
@@ -216,11 +215,11 @@ def commands
216
215
  # value.pluralize(count)
217
216
  # end
218
217
  # RUBY
219
-
218
+
220
219
  # row :a_inflection , :singularize , [] , ""
221
220
  end
222
221
  end
223
-
222
+
224
223
  @commands = result.raw_data_struct.rows
225
224
  end
226
225
  @commands = nil
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  def use_cases
2
4
  return @use_cases unless @use_cases.nil?
3
-
4
- result = KDoc.model :document do
5
5
 
6
+ result = KDoc.model :document do
6
7
  # table :inputs do
7
8
  # fields :name, :value
8
9
 
@@ -18,9 +19,9 @@ def use_cases
18
19
 
19
20
  # end
20
21
 
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"
22
+ sentence1 = 'The quick brown fox, jumped over the lazy dog'
23
+ sentence2 = 'coyote and the acme company'
24
+ text1 = 'the Quick brown Fox 99'
24
25
 
25
26
  table :rows do
26
27
  # fields :category, :function, :input, :commands, :expected_value
@@ -62,37 +63,36 @@ def use_cases
62
63
  row :a_transform , :title , [text1] , 'The Quick Brown Fox 99'
63
64
  row :a_transform , :title , [sentence1] , 'The Quick Brown Fox Jumped over the Lazy Dog'
64
65
  row :a_transform , :upper , [text1] , 'THE QUICK BROWN FOX 99'
65
-
66
66
 
67
67
  row :a_comparison , :and , [nil, nil] , false
68
68
  row :a_comparison , :and , ['data', nil] , false
69
69
  row :a_comparison , :and , [nil, 'data'] , false
70
- row :a_comparison , :and , ['data', 'data'] , true
71
- row :a_comparison , :and , ['aaa', 'bbb'] , true
70
+ row :a_comparison , :and , %w[data data] , true
71
+ row :a_comparison , :and , %w[aaa bbb] , true
72
72
 
73
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"
74
+ row :a_comparison , :default , [nil, 'happy'] , 'happy'
75
+ row :a_comparison , :default , %w[sad happy] , 'sad'
76
+ row :a_comparison , :default , [nil, nil, nil, nil, 'david'] , 'david'
77
+ row :a_comparison , :default , ['', 'happy'] , 'happy'
78
78
 
79
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
80
+ row :a_comparison , :eq , [111, '111'], false
81
+ row :a_comparison , :eq , [111, 111.0], false
82
+ row :a_comparison , :eq , %w[aaa aaa], true
83
+ row :a_comparison , :eq , %w[aaa bbb], false
84
+ row :a_comparison , :eq , %i[aaa aaa] , true
85
85
  row :a_comparison , :eq , ['aaa', :aaa] , false
86
- row :a_comparison , :eq , ['aaa', 'bbb'], false
87
- row :a_comparison , :eq , ['aaa', 'AAA'], false
86
+ row :a_comparison , :eq , %w[aaa bbb], false
87
+ row :a_comparison , :eq , %w[aaa AAA], false
88
88
 
89
89
  row :a_comparison , :gt , [2, 1] , true
90
90
  row :a_comparison , :gt , [2, 2] , false
91
-
91
+
92
92
  row :a_comparison , :gte , [1, 2] , false
93
93
  row :a_comparison , :gte , [1, 1] , true
94
94
  row :a_comparison , :gte , [2, 1] , true
95
-
95
+
96
96
  row :a_comparison , :lt , [1, 2] , true
97
97
  row :a_comparison , :lt , [2, 1] , false
98
98
 
@@ -102,16 +102,15 @@ def use_cases
102
102
 
103
103
  row :a_comparison , :ne , [1, 2] , true
104
104
  row :a_comparison , :ne , [1, 1] , false
105
-
105
+
106
106
  row :a_comparison , :or , [nil, nil] , false
107
107
  row :a_comparison , :or , ['data', nil] , true
108
108
  row :a_comparison , :or , [nil, 'data'] , true
109
- row :a_comparison , :or , ['data', 'data'] , true
110
- row :a_comparison , :or , ['aaa', 'bbb'] , true
109
+ row :a_comparison , :or , %w[data data] , true
110
+ row :a_comparison , :or , %w[aaa bbb] , true
111
111
  # row :text1 , %i[backslash] , 'the\quick\brown\fox99'
112
112
  # row :text1 , %i[camel] , 'TheQuickBrownFox99'
113
113
 
114
-
115
114
  # row :sentence3 , %i[plural] , "jumped over the lazy dogs"
116
115
  # row :title , %i[plural] , "Account Categories"
117
116
  # row :sentence1 , %i[dash] , "The-quick-brown-fox-jumped-over-the-lazy-dog"
@@ -120,17 +119,16 @@ def use_cases
120
119
  # row :bsb_account , %i[lower snake] , "abc_123"
121
120
  # row :bsb_account , %i[slash] , "ABC/123"
122
121
  end
123
-
124
122
  end
125
-
123
+
126
124
  @use_cases = result.raw_data_struct.rows
127
125
  end
128
126
  @use_cases = nil
129
127
 
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
128
+ # def self.camel_case(string, tokenizer = PreservePrefixedUnderscoreTokenizer.new)
129
+ # # DAVE INPUT 9 Oct 21 from lucky_case play
130
+ # # dependency injection: to use enhanced tokenizer
131
+ # a = split_case_string string
132
+ # converted = ([a[0]] + a[1..-1].map { |e| capital e }).join('')
133
+ # tokenizer.parse(converted)
134
+ # end
@@ -1,6 +1,6 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  def category_blueprint
3
-
4
4
  fn_builder
5
5
  .init
6
6
  .category(:array , active: 0 , title: 'Array' , description: 'Functions for working with Array')
@@ -24,11 +24,9 @@ def category_blueprint
24
24
  .category(:regex , active: 0 , title: 'Regex' , description: 'Functions for working with Regex')
25
25
  .category(:string , active: 0 , title: 'String' , description: 'Functions for working with String')
26
26
  .category(:url , active: 0 , title: 'Url' , description: 'Functions for working with Url')
27
-
28
27
  end
29
28
 
30
29
  def function_blueprint
31
-
32
30
  fn_builder
33
31
  .init
34
32
  .for_category(:array)
@@ -41,11 +39,11 @@ def function_blueprint
41
39
  .for_category(:html)
42
40
  .for_category(:i18n)
43
41
  .for_category(:inflection)
44
- .function(:ordinal)
45
- .function(:ordinalize)
46
- .function(:pluralize_by_number)
47
- .function(:pluralize)
48
- .function(:singularize)
42
+ .function(:ordinal)
43
+ .function(:ordinalize)
44
+ .function(:pluralize_by_number)
45
+ .function(:pluralize)
46
+ .function(:singularize)
49
47
  .for_category(:logging)
50
48
  .for_category(:markdown)
51
49
  .for_category(:match)
@@ -57,10 +55,9 @@ def function_blueprint
57
55
  .for_category(:regex)
58
56
  .for_category(:string)
59
57
  .for_category(:url)
60
-
61
58
  end
62
59
 
63
60
  # {{arrayify}}
64
61
  # Cast the given value to an array.
65
62
  # {{before}}
66
- # Return all of the items in the collection before the specified count. Opposite of after.
63
+ # Return all of the items in the collection before the specified count. Opposite of after.
@@ -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