rubysmith 0.15.0 → 1.1.0

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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/LICENSE.adoc +207 -155
  4. data/README.adoc +352 -93
  5. data/{bin → exe}/rubysmith +0 -0
  6. data/lib/rubysmith/builder.rb +2 -3
  7. data/lib/rubysmith/builders/bundler.rb +7 -11
  8. data/lib/rubysmith/builders/circle_ci.rb +8 -2
  9. data/lib/rubysmith/builders/console.rb +8 -2
  10. data/lib/rubysmith/builders/core.rb +7 -3
  11. data/lib/rubysmith/builders/documentation/{change.rb → citation.rb} +8 -8
  12. data/lib/rubysmith/builders/documentation/license.rb +9 -4
  13. data/lib/rubysmith/builders/documentation/readme.rb +12 -18
  14. data/lib/rubysmith/builders/documentation/{contribution.rb → version.rb} +10 -5
  15. data/lib/rubysmith/builders/git/commit.rb +3 -1
  16. data/lib/rubysmith/builders/{rubocop/setup.rb → git/ignore.rb} +11 -7
  17. data/lib/rubysmith/builders/git/setup.rb +2 -1
  18. data/lib/rubysmith/builders/git_hub.rb +8 -3
  19. data/lib/rubysmith/builders/guard.rb +9 -3
  20. data/lib/rubysmith/builders/rake.rb +9 -3
  21. data/lib/rubysmith/builders/reek.rb +7 -2
  22. data/lib/rubysmith/builders/rspec/context.rb +8 -2
  23. data/lib/rubysmith/builders/rspec/helper.rb +8 -2
  24. data/lib/rubysmith/builders/rubocop.rb +34 -0
  25. data/lib/rubysmith/builders/setup.rb +8 -2
  26. data/lib/rubysmith/cli/actions/build.rb +11 -12
  27. data/lib/rubysmith/cli/actions/config.rb +4 -2
  28. data/lib/rubysmith/cli/actions/publish.rb +21 -0
  29. data/lib/rubysmith/cli/parser.rb +31 -0
  30. data/lib/rubysmith/cli/parsers/build.rb +89 -45
  31. data/lib/rubysmith/cli/parsers/core.rb +14 -10
  32. data/lib/rubysmith/cli/shell.rb +22 -15
  33. data/lib/rubysmith/configuration/content.rb +174 -0
  34. data/lib/rubysmith/configuration/defaults.yml +89 -0
  35. data/lib/rubysmith/configuration/enhancers/current_time.rb +24 -0
  36. data/lib/rubysmith/configuration/enhancers/git_email.rb +31 -0
  37. data/lib/rubysmith/configuration/enhancers/git_hub_user.rb +31 -0
  38. data/lib/rubysmith/configuration/enhancers/git_user.rb +33 -0
  39. data/lib/rubysmith/configuration/loader.rb +48 -0
  40. data/lib/rubysmith/container.rb +1 -1
  41. data/lib/rubysmith/extensions/bundler.rb +30 -0
  42. data/lib/rubysmith/extensions/milestoner.rb +35 -0
  43. data/lib/rubysmith/extensions/pragmater.rb +35 -0
  44. data/lib/rubysmith/extensions/rubocop.rb +29 -0
  45. data/lib/rubysmith/extensions/tocer.rb +37 -0
  46. data/lib/rubysmith/identity.rb +1 -1
  47. data/lib/rubysmith/templates/%project_name%/.github/ISSUE_TEMPLATE.md.erb +1 -4
  48. data/lib/rubysmith/templates/%project_name%/.github/PULL_REQUEST_TEMPLATE.md.erb +0 -3
  49. data/lib/rubysmith/templates/%project_name%/.gitignore.erb +11 -0
  50. data/lib/rubysmith/templates/%project_name%/.rubocop.yml.erb +2 -0
  51. data/lib/rubysmith/templates/%project_name%/CITATION.cff.erb +16 -0
  52. data/lib/rubysmith/templates/%project_name%/Gemfile.erb +19 -10
  53. data/lib/rubysmith/templates/%project_name%/LICENSE-hippocratic.adoc.erb +214 -0
  54. data/lib/rubysmith/templates/%project_name%/LICENSE-hippocratic.md.erb +214 -0
  55. data/lib/rubysmith/templates/%project_name%/README.adoc.erb +20 -21
  56. data/lib/rubysmith/templates/%project_name%/README.md.erb +20 -21
  57. data/lib/rubysmith/templates/%project_name%/Rakefile.erb +9 -0
  58. data/lib/rubysmith/templates/%project_name%/VERSIONS.adoc.erb +5 -0
  59. data/lib/rubysmith/templates/%project_name%/VERSIONS.md.erb +5 -0
  60. data/lib/rubysmith/templates/%project_name%/bin/rubocop.erb +0 -1
  61. data.tar.gz.sig +0 -0
  62. metadata +61 -42
  63. metadata.gz.sig +0 -0
  64. data/lib/rubysmith/builders/documentation/conduct.rb +0 -32
  65. data/lib/rubysmith/builders/pragma.rb +0 -32
  66. data/lib/rubysmith/builders/rubocop/formatter.rb +0 -31
  67. data/lib/rubysmith/cli/configuration/content.rb +0 -97
  68. data/lib/rubysmith/cli/configuration/defaults.yml +0 -46
  69. data/lib/rubysmith/cli/configuration/enhancers/current_time.rb +0 -26
  70. data/lib/rubysmith/cli/configuration/enhancers/git_hub_user.rb +0 -33
  71. data/lib/rubysmith/cli/configuration/enhancers/version.rb +0 -26
  72. data/lib/rubysmith/cli/configuration/loader.rb +0 -46
  73. data/lib/rubysmith/cli/parsers/assembler.rb +0 -32
  74. data/lib/rubysmith/cli/parsers.rb +0 -11
  75. data/lib/rubysmith/templates/%project_name%/CHANGES.adoc.erb +0 -5
  76. data/lib/rubysmith/templates/%project_name%/CHANGES.md.erb +0 -5
  77. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.adoc.erb +0 -114
  78. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.md.erb +0 -115
  79. data/lib/rubysmith/templates/%project_name%/CONTRIBUTING.adoc.erb +0 -22
  80. data/lib/rubysmith/templates/%project_name%/CONTRIBUTING.md.erb +0 -22
@@ -5,7 +5,7 @@ module Rubysmith
5
5
  module Actions
6
6
  # Handles the config action.
7
7
  class Config
8
- def initialize client: CLI::Configuration::Loader::CLIENT, container: Container
8
+ def initialize client: Configuration::Loader::CLIENT, container: Container
9
9
  @client = client
10
10
  @container = container
11
11
  end
@@ -14,7 +14,7 @@ module Rubysmith
14
14
  case selection
15
15
  when :edit then edit
16
16
  when :view then view
17
- else fail StandardError, "Invalid configuration selection: #{selection}."
17
+ else logger.error { "Invalid configuration selection: #{selection}." }
18
18
  end
19
19
  end
20
20
 
@@ -27,6 +27,8 @@ module Rubysmith
27
27
  def view = kernel.system("cat #{client.current}")
28
28
 
29
29
  def kernel = container[__method__]
30
+
31
+ def logger = container[__method__]
30
32
  end
31
33
  end
32
34
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rubysmith
4
+ module CLI
5
+ module Actions
6
+ # Handles parsing of Command Line Interface (CLI) publish options.
7
+ class Publish
8
+ def initialize extension: Extensions::Milestoner, container: Container
9
+ @extension = extension
10
+ @container = container
11
+ end
12
+
13
+ def call(configuration) = extension.call(configuration)
14
+
15
+ private
16
+
17
+ attr_reader :extension, :container
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+
5
+ module Rubysmith
6
+ module CLI
7
+ # Assembles and parses all Command Line Interface (CLI) options.
8
+ class Parser
9
+ CLIENT = OptionParser.new nil, 40, " "
10
+ SECTIONS = [Parsers::Core, Parsers::Build].freeze # Order is important.
11
+
12
+ def initialize sections: SECTIONS, client: CLIENT, container: Container
13
+ @sections = sections
14
+ @client = client
15
+ @configuration = container[:configuration].dup
16
+ end
17
+
18
+ def call arguments = []
19
+ sections.each { |section| section.call configuration, client: }
20
+ client.parse arguments
21
+ configuration.freeze
22
+ end
23
+
24
+ def to_s = client.to_s
25
+
26
+ private
27
+
28
+ attr_reader :sections, :client, :configuration
29
+ end
30
+ end
31
+ end
@@ -1,33 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+
3
5
  module Rubysmith
4
6
  module CLI
5
7
  module Parsers
6
8
  # Handles parsing of Command Line Interface (CLI) build options.
7
9
  class Build
10
+ using Refinements::Structs
11
+
8
12
  def self.call(...) = new(...).call
9
13
 
10
- def initialize client: CLIENT, container: Container
14
+ def initialize configuration = Container[:configuration],
15
+ client: Parser::CLIENT,
16
+ container: Container
17
+ @configuration = configuration
11
18
  @client = client
12
19
  @container = container
13
20
  end
14
21
 
15
22
  def call arguments = []
16
23
  client.separator "\nBUILD OPTIONS:\n"
17
- private_methods.sort.grep(/add_/).each { |method| __send__ method }
18
- arguments.empty? ? arguments : client.parse!(arguments)
24
+ collate
25
+ client.parse arguments
26
+ configuration
19
27
  end
20
28
 
21
29
  private
22
30
 
23
- attr_reader :client, :container
31
+ attr_reader :configuration, :client, :container
32
+
33
+ def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
24
34
 
25
35
  def add_amazing_print
26
36
  client.on(
27
37
  "--[no-]amazing_print",
28
38
  "Add Amazing Print gem. #{default __method__}."
29
39
  ) do |value|
30
- configuration.build_amazing_print = value
40
+ configuration.merge! build_amazing_print: value
31
41
  end
32
42
  end
33
43
 
@@ -36,16 +46,7 @@ module Rubysmith
36
46
  "--[no-]bundler-leak",
37
47
  "Add Bundler Leak gem. #{default __method__}."
38
48
  ) do |value|
39
- configuration.build_bundler_leak = value
40
- end
41
- end
42
-
43
- def add_changes
44
- client.on(
45
- "--[no-]changes",
46
- "Add CHANGES documentation. #{default __method__}."
47
- ) do |value|
48
- configuration.build_changes = value
49
+ configuration.merge! build_bundler_leak: value
49
50
  end
50
51
  end
51
52
 
@@ -54,16 +55,16 @@ module Rubysmith
54
55
  "--[no-]console",
55
56
  "Add console script. #{default __method__}."
56
57
  ) do |value|
57
- configuration.build_console = value
58
+ configuration.merge! build_console: value
58
59
  end
59
60
  end
60
61
 
61
62
  def add_contributions
62
63
  client.on(
63
64
  "--[no-]contributions",
64
- "Add CONTRIBUTING documentation. #{default __method__}."
65
+ "Add contributions documentation. #{default __method__}."
65
66
  ) do |value|
66
- configuration.build_contributions = value
67
+ configuration.merge! build_contributions: value
67
68
  end
68
69
  end
69
70
 
@@ -72,16 +73,43 @@ module Rubysmith
72
73
  "--[no-]circle_ci",
73
74
  "Add Circle CI configuration and badge. #{default __method__}."
74
75
  ) do |value|
75
- configuration.build_circle_ci = value
76
+ configuration.merge! build_circle_ci: value
77
+ end
78
+ end
79
+
80
+ def add_citation
81
+ client.on(
82
+ "--[no-]citation",
83
+ "Add citation documentation. #{default __method__}."
84
+ ) do |value|
85
+ configuration.merge! build_citation: value
86
+ end
87
+ end
88
+
89
+ def add_community
90
+ client.on(
91
+ "--[no-]community",
92
+ "Add community documentation. #{default __method__}."
93
+ ) do |value|
94
+ configuration.merge! build_community: value
76
95
  end
77
96
  end
78
97
 
79
98
  def add_conduct
80
99
  client.on(
81
100
  "--[no-]conduct",
82
- "Add CODE_OF_CONDUCT documentation. #{default __method__}."
101
+ "Add code of conduct documentation. #{default __method__}."
83
102
  ) do |value|
84
- configuration.build_conduct = value
103
+ configuration.merge! build_conduct: value
104
+ end
105
+ end
106
+
107
+ def add_dead_end
108
+ client.on(
109
+ "--[no-]dead_end",
110
+ "Add Dead End gem. #{default __method__}."
111
+ ) do |value|
112
+ configuration.merge! build_dead_end: value
85
113
  end
86
114
  end
87
115
 
@@ -90,7 +118,7 @@ module Rubysmith
90
118
  "--[no-]debug",
91
119
  "Add Debug gem. #{default __method__}."
92
120
  ) do |value|
93
- configuration.build_debug = value
121
+ configuration.merge! build_debug: value
94
122
  end
95
123
  end
96
124
 
@@ -99,7 +127,7 @@ module Rubysmith
99
127
  "--[no-]git",
100
128
  "Add Git. #{default __method__}."
101
129
  ) do |value|
102
- configuration.build_git = value
130
+ configuration.merge! build_git: value
103
131
  end
104
132
  end
105
133
 
@@ -108,7 +136,7 @@ module Rubysmith
108
136
  "--[no-]git_hub",
109
137
  "Add GitHub templates. #{default __method__}."
110
138
  ) do |value|
111
- configuration.build_git_hub = value
139
+ configuration.merge! build_git_hub: value
112
140
  end
113
141
  end
114
142
 
@@ -117,7 +145,7 @@ module Rubysmith
117
145
  "--[no-]git-lint",
118
146
  "Add Git Lint gem. #{default __method__}."
119
147
  ) do |value|
120
- configuration.build_git_lint = value
148
+ configuration.merge! build_git_lint: value
121
149
  end
122
150
  end
123
151
 
@@ -126,16 +154,16 @@ module Rubysmith
126
154
  "--[no-]guard",
127
155
  "Add Guard gem. #{default __method__}."
128
156
  ) do |value|
129
- configuration.build_guard = value
157
+ configuration.merge! build_guard: value
130
158
  end
131
159
  end
132
160
 
133
161
  def add_license
134
162
  client.on(
135
163
  "--[no-]license",
136
- "Add LICENSE documentation. #{default __method__}."
164
+ "Add license documentation. #{default __method__}."
137
165
  ) do |value|
138
- configuration.build_license = value
166
+ configuration.merge! build_license: value
139
167
  end
140
168
  end
141
169
 
@@ -143,8 +171,8 @@ module Rubysmith
143
171
  client.on(
144
172
  "--max",
145
173
  "Use maximum/enabled options. #{default __method__}."
146
- ) do |value|
147
- configuration.maximize.build_maximum = value
174
+ ) do
175
+ configuration.merge!(**configuration.maximize.to_h)
148
176
  end
149
177
  end
150
178
 
@@ -152,8 +180,8 @@ module Rubysmith
152
180
  client.on(
153
181
  "--min",
154
182
  "Use minimum/disabled options. #{default __method__}."
155
- ) do |value|
156
- configuration.minimize.build_minimum = value
183
+ ) do
184
+ configuration.merge!(**configuration.minimize.to_h)
157
185
  end
158
186
  end
159
187
 
@@ -162,16 +190,16 @@ module Rubysmith
162
190
  "--[no-]rake",
163
191
  "Add Rake gem. #{default __method__}."
164
192
  ) do |value|
165
- configuration.build_rake = value
193
+ configuration.merge! build_rake: value
166
194
  end
167
195
  end
168
196
 
169
197
  def add_readme
170
198
  client.on(
171
199
  "--[no-]readme",
172
- "Add README documentation. #{default __method__}."
200
+ "Add readme documentation. #{default __method__}."
173
201
  ) do |value|
174
- configuration.build_readme = value
202
+ configuration.merge! build_readme: value
175
203
  end
176
204
  end
177
205
 
@@ -180,7 +208,7 @@ module Rubysmith
180
208
  "--[no-]reek",
181
209
  "Add Reek gem. #{default __method__}."
182
210
  ) do |value|
183
- configuration.build_reek = value
211
+ configuration.merge! build_reek: value
184
212
  end
185
213
  end
186
214
 
@@ -189,7 +217,7 @@ module Rubysmith
189
217
  "--[no-]refinements",
190
218
  "Add Refinements gem. #{default __method__}."
191
219
  ) do |value|
192
- configuration.build_refinements = value
220
+ configuration.merge! build_refinements: value
193
221
  end
194
222
  end
195
223
 
@@ -198,16 +226,16 @@ module Rubysmith
198
226
  "--[no-]rspec",
199
227
  "Add RSpec gem. #{default __method__}."
200
228
  ) do |value|
201
- configuration.build_rspec = value
229
+ configuration.merge! build_rspec: value
202
230
  end
203
231
  end
204
232
 
205
233
  def add_rubocop
206
234
  client.on(
207
235
  "--[no-]rubocop",
208
- "Add Rubocop gems. #{default __method__}."
236
+ "Add RuboCop gems. #{default __method__}."
209
237
  ) do |value|
210
- configuration.build_rubocop = value
238
+ configuration.merge! build_rubocop: value
211
239
  end
212
240
  end
213
241
 
@@ -216,7 +244,7 @@ module Rubysmith
216
244
  "--[no-]setup",
217
245
  "Add setup script. #{default __method__}."
218
246
  ) do |value|
219
- configuration.build_setup = value
247
+ configuration.merge! build_setup: value
220
248
  end
221
249
  end
222
250
 
@@ -225,7 +253,25 @@ module Rubysmith
225
253
  "--[no-]simple_cov",
226
254
  "Add SimpleCov gem. #{default __method__}."
227
255
  ) do |value|
228
- configuration.build_simple_cov = value
256
+ configuration.merge! build_simple_cov: value
257
+ end
258
+ end
259
+
260
+ def add_versions
261
+ client.on(
262
+ "--[no-]versions",
263
+ "Add version history. #{default __method__}."
264
+ ) do |value|
265
+ configuration.merge! build_versions: value
266
+ end
267
+ end
268
+
269
+ def add_yard
270
+ client.on(
271
+ "--[no-]yard",
272
+ "Add Yard gem. #{default __method__}."
273
+ ) do |value|
274
+ configuration.merge! build_yard: value
229
275
  end
230
276
  end
231
277
 
@@ -234,7 +280,7 @@ module Rubysmith
234
280
  "--[no-]zeitwerk",
235
281
  "Add Zeitwerk gem. #{default __method__}."
236
282
  ) do |value|
237
- configuration.build_zeitwerk = value
283
+ configuration.merge! build_zeitwerk: value
238
284
  end
239
285
  end
240
286
 
@@ -246,8 +292,6 @@ module Rubysmith
246
292
  .then { |colored_boolean| "Default: #{colored_boolean}" }
247
293
  end
248
294
 
249
- def configuration = container[__method__]
250
-
251
295
  def colorizer = container[__method__]
252
296
  end
253
297
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubysmith/identity"
4
3
  require "refinements/structs"
5
4
 
6
5
  module Rubysmith
@@ -12,21 +11,22 @@ module Rubysmith
12
11
 
13
12
  def self.call(...) = new(...).call
14
13
 
15
- def initialize client: CLIENT, container: Container
14
+ def initialize configuration = Container[:configuration], client: Parser::CLIENT
15
+ @configuration = configuration
16
16
  @client = client
17
- @container = container
18
17
  end
19
18
 
20
19
  def call arguments = []
21
20
  client.banner = "#{Identity::LABEL} - #{Identity::SUMMARY}"
22
21
  client.separator "\nUSAGE:\n"
23
22
  collate
24
- arguments.empty? ? arguments : client.parse!(arguments)
23
+ client.parse arguments
24
+ configuration
25
25
  end
26
26
 
27
27
  private
28
28
 
29
- attr_reader :client, :container
29
+ attr_reader :configuration, :client
30
30
 
31
31
  def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
32
32
 
@@ -35,7 +35,7 @@ module Rubysmith
35
35
  "--config ACTION",
36
36
  %i[edit view],
37
37
  "Manage gem configuration: edit or view." do |action|
38
- configuration.action_config = action
38
+ configuration.merge! action_config: action
39
39
  end
40
40
  end
41
41
 
@@ -45,19 +45,23 @@ module Rubysmith
45
45
  end
46
46
  end
47
47
 
48
+ def add_publish
49
+ client.on "-p", "--publish VERSION", "Publish project." do |version|
50
+ configuration.merge! action_publish: true, project_version: version
51
+ end
52
+ end
53
+
48
54
  def add_version
49
55
  client.on "-v", "--version", "Show gem version." do
50
- configuration.action_version = true
56
+ configuration.merge! action_version: true
51
57
  end
52
58
  end
53
59
 
54
60
  def add_help
55
61
  client.on "-h", "--help", "Show this message." do
56
- configuration.action_help = true
62
+ configuration.merge! action_help: true
57
63
  end
58
64
  end
59
-
60
- def configuration = container[__method__]
61
65
  end
62
66
  end
63
67
  end
@@ -1,43 +1,50 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "milestoner"
4
+
3
5
  module Rubysmith
4
6
  module CLI
5
7
  # The main Command Line Interface (CLI) object.
6
8
  class Shell
7
- ACTIONS = {config: Actions::Config.new, build: Actions::Build.new}.freeze
9
+ ACTIONS = {
10
+ config: Actions::Config.new,
11
+ build: Actions::Build.new,
12
+ publish: Actions::Publish.new
13
+ }.freeze
8
14
 
9
- def initialize parser: Parsers::Assembler.new, actions: ACTIONS, container: Container
15
+ def initialize parser: Parser.new, actions: ACTIONS, container: Container
10
16
  @parser = parser
11
17
  @actions = actions
12
18
  @container = container
13
19
  end
14
20
 
15
21
  def call arguments = []
16
- case parse arguments
17
- in action_config: Symbol => action then config action
18
- in action_build: true then build
19
- in action_version: true then logger.info configuration.version
20
- else usage
21
- end
22
+ perform parser.call(arguments)
23
+ rescue OptionParser::ParseError, Milestoner::Error => error
24
+ logger.error { error.message }
22
25
  end
23
26
 
24
27
  private
25
28
 
26
29
  attr_reader :parser, :actions, :container
27
30
 
28
- def parse arguments = []
29
- parser.call arguments
30
- rescue StandardError => error
31
- logger.error error.message
31
+ def perform configuration
32
+ case configuration
33
+ in action_config: Symbol => action then config action
34
+ in action_build: true then build configuration
35
+ in action_publish: true then publish configuration
36
+ in action_version: true then logger.info Identity::VERSION_LABEL
37
+ else usage
38
+ end
32
39
  end
33
40
 
34
41
  def config(action) = actions.fetch(__method__).call(action)
35
42
 
36
- def build = actions.fetch(__method__).call
43
+ def build(configuration) = actions.fetch(__method__).call(configuration)
37
44
 
38
- def usage = logger.unknown(parser.to_s)
45
+ def publish(configuration) = actions.fetch(__method__).call(configuration)
39
46
 
40
- def configuration = container[__method__]
47
+ def usage = logger.unknown(parser.to_s)
41
48
 
42
49
  def logger = container[__method__]
43
50
  end