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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmdlet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-09 00:00:00.000000000 Z
11
+ date: 2022-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -47,24 +47,34 @@ extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
49
  - ".builders/.templates/FUNCTIONS.MD"
50
- - ".builders/.templates/all_commands.rb"
51
- - ".builders/.templates/command.rb"
52
- - ".builders/.templates/command_spec.rb"
50
+ - ".builders/.templates/cmdlet.rb"
51
+ - ".builders/.templates/cmdlet_spec.rb"
52
+ - ".builders/.templates/require_all_cmdlets.rb"
53
53
  - ".builders/_.rb"
54
54
  - ".builders/boot.rb"
55
55
  - ".builders/data/categories.json"
56
+ - ".builders/data/cmdlets/array.json"
57
+ - ".builders/data/cmdlets/case.json"
58
+ - ".builders/data/cmdlets/comparison.json"
59
+ - ".builders/data/cmdlets/inflection.json"
60
+ - ".builders/director/category_builder.rb"
61
+ - ".builders/director/category_dao.rb"
56
62
  - ".builders/director/category_director.rb"
57
63
  - ".builders/director/cmdlet_builder.rb"
58
64
  - ".builders/director/cmdlet_child.rb"
65
+ - ".builders/director/cmdlet_dao.rb"
59
66
  - ".builders/director/cmdlet_director.rb"
60
- - ".builders/documents/categories.rb"
61
- - ".builders/documents/cmdlets.rb"
67
+ - ".builders/director/dao.rb"
62
68
  - ".builders/documents/commands.rb"
63
69
  - ".builders/documents/use_cases.rb"
64
70
  - ".builders/documents/x_functions.rb"
65
71
  - ".builders/generators/01-bootstrap.rb"
66
- - ".builders/generators/20-commands.rb"
67
- - ".builders/generators/25-categories.rb"
72
+ - ".builders/generators/20-categories.rb"
73
+ - ".builders/generators/30-commands-bak.rb"
74
+ - ".builders/generators/cmdlets/array.rb"
75
+ - ".builders/generators/cmdlets/case.rb"
76
+ - ".builders/generators/cmdlets/comparison.rb"
77
+ - ".builders/generators/cmdlets/inflection.rb"
68
78
  - ".releaserc.json"
69
79
  - ".rspec"
70
80
  - ".rubocop.yml"
@@ -78,9 +88,41 @@ files:
78
88
  - bin/console
79
89
  - bin/setup
80
90
  - lib/cmdlet.rb
91
+ - lib/cmdlet/_.rb
81
92
  - lib/cmdlet/all_commands.rb
82
93
  - lib/cmdlet/array/join.rb
94
+ - lib/cmdlet/array/join_post.rb
95
+ - lib/cmdlet/array/join_pre.rb
96
+ - lib/cmdlet/base_cmdlet.rb
97
+ - lib/cmdlet/case/back_slash.rb
98
+ - lib/cmdlet/case/camel.rb
99
+ - lib/cmdlet/case/constant.rb
100
+ - lib/cmdlet/case/dash.rb
101
+ - lib/cmdlet/case/dot.rb
102
+ - lib/cmdlet/case/double_colon.rb
103
+ - lib/cmdlet/case/human.rb
104
+ - lib/cmdlet/case/lamel.rb
105
+ - lib/cmdlet/case/lower.rb
106
+ - lib/cmdlet/case/sentence.rb
107
+ - lib/cmdlet/case/slash.rb
108
+ - lib/cmdlet/case/snake.rb
109
+ - lib/cmdlet/case/title.rb
110
+ - lib/cmdlet/case/upper.rb
111
+ - lib/cmdlet/comparison/and.rb
112
+ - lib/cmdlet/comparison/default.rb
113
+ - lib/cmdlet/comparison/eq.rb
114
+ - lib/cmdlet/comparison/gt.rb
115
+ - lib/cmdlet/comparison/gte.rb
116
+ - lib/cmdlet/comparison/lt.rb
117
+ - lib/cmdlet/comparison/lte.rb
118
+ - lib/cmdlet/comparison/ne.rb
119
+ - lib/cmdlet/comparison/or.rb
83
120
  - lib/cmdlet/configuration.rb
121
+ - lib/cmdlet/inflection/ordinal.rb
122
+ - lib/cmdlet/inflection/ordinalize.rb
123
+ - lib/cmdlet/inflection/pluralize.rb
124
+ - lib/cmdlet/inflection/pluralize_by_number.rb
125
+ - lib/cmdlet/inflection/singularize.rb
84
126
  - lib/cmdlet/string_tokenizer.rb
85
127
  - lib/cmdlet/version.rb
86
128
  - package-lock.json
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- {{#each commands}}
4
- require 'cmdlet/{{category}}/{{name}}'
5
- {{/each}}
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # reference: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb
4
-
5
- module Cmdlet
6
- # {{cmdlet.category_description}}
7
- module {{camel cmdlet.category}}
8
- # {{camel cmdlet.name}}: {{cmdlet.command_description}}
9
- class {{camel cmdlet.name}} < Funcky::BaseFunction
10
- {{#each cmdlet.usecases}}
11
- # @example
12
- #
13
- # puts {{camel ./function}}.new.parse({{{nice_inputs}}})
14
- #
15
- # {{expected_output}}
16
- #
17
- {{/each}}
18
- #
19
- # @param [String|Int] value - numeric value
20
- # @return [String] ordinal suffix that would be required for a number
21
- def parse(value)
22
- {{{cmdlet.ruby}}}
23
- end
24
- end
25
- end
26
- end
@@ -1,24 +0,0 @@
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 :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
-
@@ -1,30 +0,0 @@
1
- def cmdlets
2
- commands.map do |command|
3
- category = categories.find { |c| c.name == command.category }
4
-
5
- log.error("Category '#{command.category}' not found") unless category
6
-
7
- OpenStruct.new(
8
- category: command.category,
9
- name: command.name,
10
- category_description: category.description,
11
- command_description: command.description,
12
- ruby: command.ruby,
13
- usecases: use_cases
14
- .select { |uc| uc.category == command.category && uc.command == command.name }
15
- .map { |uc|
16
- OpenStruct.new({
17
- category: uc.category,
18
- command: uc.command,
19
- inputs: uc.inputs,
20
- nice_inputs: nice_inputs(uc.inputs),
21
- expected_output: uc.expected_output
22
- })
23
- }
24
- )
25
- end
26
- end
27
-
28
- def nice_inputs(values)
29
- values.map { |value| value.is_a?(String) ? "'#{value}'" : value }.join(', ')
30
- end
@@ -1,54 +0,0 @@
1
- KManager.action :commands do
2
- action do
3
-
4
- puts commands.first.function_description
5
- # Ruby Gem Bootstrap
6
- director = KDirector::Dsls::BasicDsl
7
- .init(k_builder,
8
- template_base_folder: '',
9
- on_exist: :skip, # %i[skip write compare]
10
- on_action: :queue # %i[queue execute]
11
- )
12
- .blueprint(
13
- active: true,
14
- name: :build_commands,
15
- description: 'Build Commandlets',
16
- on_exist: :write) do
17
-
18
- cd(:lib)
19
-
20
- # builder
21
- # .add_file('FUNCTIONS.md',
22
- # template_file: 'FUNCTIONS.md',
23
- # categories: categories.sort_by { |r| r.name },
24
- # functions: functions.sort_by { |r| [r.category, r.name] },
25
- # on_exist: :write)
26
-
27
- add('all_commands.rb',
28
- template_file: 'all_commands.rb',
29
- commands: commands.sort_by { |r| [r.category, r.name] },
30
- on_exist: :write)
31
-
32
- cmdlets.each do |cmdlet|
33
-
34
- add("#{cmdlet.category}/#{cmdlet.name}.rb",
35
- cmdlet: cmdlet,
36
- template_file: 'command.rb',
37
- on_exist: :write)
38
- end
39
-
40
- end
41
-
42
- director.play_actions
43
- # director.builder.logit
44
- end
45
- end
46
-
47
- KManager.opts.app_name = 'commands'
48
- KManager.opts.sleep = 2
49
- KManager.opts.reboot_on_kill = 0
50
- KManager.opts.reboot_sleep = 4
51
- KManager.opts.exception_style = :short
52
- KManager.opts.show.time_taken = true
53
- KManager.opts.show.finished = true
54
- KManager.opts.show.finished_message = 'FINISHED :)'
@@ -1,20 +0,0 @@
1
- KManager.action :categories do
2
- action do
3
-
4
- CategoryDirector
5
- .init(k_builder,
6
- on_exist: :write, # %i[skip write compare]
7
- on_action: :execute # %i[queue execute]
8
- )
9
- .category(:case , "Tokenize and apply case and/or separator")
10
- .category(:comparison , "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.")
11
- .category(:inflection , "Inflection handling routines, eg. pluralize, singular, ordinalize")
12
- .category(:string , "String handling helpers")
13
- .category(:a_array , "Array handling routines, eg. join, join_prefix, join_post")
14
- .category(:a_transform , "Tokenize and apply case and/or separator")
15
- .category(:a_comparison , "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.")
16
- .category(:a_inflection , "Inflection handling routines, eg. pluralize, singular, ordinalize")
17
- .save_categories
18
- .category_file
19
- end
20
- end