rubysmith 0.16.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
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 +1 -2
  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 +37 -0
  43. data/lib/rubysmith/extensions/pragmater.rb +36 -0
  44. data/lib/rubysmith/extensions/rubocop.rb +29 -0
  45. data/lib/rubysmith/extensions/tocer.rb +39 -0
  46. data/lib/rubysmith/identity.rb +1 -1
  47. data/lib/rubysmith/renderers/erb.rb +9 -1
  48. data/lib/rubysmith/templates/%project_name%/.github/ISSUE_TEMPLATE.md.erb +1 -4
  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 +18 -9
  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 +2 -3
  62. metadata +59 -40
  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
@@ -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
@@ -0,0 +1,174 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require "refinements/arrays"
5
+ require "refinements/strings"
6
+ require "refinements/structs"
7
+
8
+ module Rubysmith
9
+ # rubocop:disable Metrics/ModuleLength
10
+ module Configuration
11
+ # Defines the common configuration content for use throughout the gem.
12
+ Content = Struct.new(
13
+ :action_build,
14
+ :action_config,
15
+ :action_edit,
16
+ :action_help,
17
+ :action_install,
18
+ :action_publish,
19
+ :action_version,
20
+ :action_view,
21
+ :author_email,
22
+ :author_family_name,
23
+ :author_given_name,
24
+ :author_url,
25
+ :build_amazing_print,
26
+ :build_bundler_leak,
27
+ :build_circle_ci,
28
+ :build_citation,
29
+ :build_cli,
30
+ :build_community,
31
+ :build_conduct,
32
+ :build_console,
33
+ :build_contributions,
34
+ :build_dead_end,
35
+ :build_debug,
36
+ :build_git,
37
+ :build_git_hub,
38
+ :build_git_lint,
39
+ :build_guard,
40
+ :build_license,
41
+ :build_maximum,
42
+ :build_minimum,
43
+ :build_rake,
44
+ :build_readme,
45
+ :build_reek,
46
+ :build_refinements,
47
+ :build_rspec,
48
+ :build_rubocop,
49
+ :build_security,
50
+ :build_setup,
51
+ :build_simple_cov,
52
+ :build_versions,
53
+ :build_yard,
54
+ :build_zeitwerk,
55
+ :citation_affiliation,
56
+ :citation_message,
57
+ :citation_orcid,
58
+ :documentation_format,
59
+ :extensions_milestoner_documentation_format,
60
+ :extensions_milestoner_prefixes,
61
+ :extensions_milestoner_sign,
62
+ :extensions_pragmater_comments,
63
+ :extensions_pragmater_includes,
64
+ :extensions_tocer_includes,
65
+ :extensions_tocer_label,
66
+ :git_hub_user,
67
+ :license_label,
68
+ :license_name,
69
+ :license_version,
70
+ :now,
71
+ :project_name,
72
+ :project_url_community,
73
+ :project_url_conduct,
74
+ :project_url_contributions,
75
+ :project_url_download,
76
+ :project_url_home,
77
+ :project_url_issues,
78
+ :project_url_license,
79
+ :project_url_security,
80
+ :project_url_source,
81
+ :project_url_versions,
82
+ :project_version,
83
+ :target_root,
84
+ :template_path,
85
+ :template_roots,
86
+ keyword_init: true
87
+ ) do
88
+ using Refinements::Arrays
89
+ using Refinements::Strings
90
+ using Refinements::Structs
91
+
92
+ def initialize *arguments
93
+ super
94
+
95
+ self[:template_roots] ||= [Pathname(__dir__).join("../templates")]
96
+ self[:target_root] ||= Pathname.pwd
97
+ freeze
98
+ end
99
+
100
+ def add_template_roots paths
101
+ Array(paths).map { |path| Pathname path }
102
+ .including(template_roots)
103
+ .then { |roots| dup.merge! template_roots: roots }
104
+ end
105
+
106
+ def maximize = update_build_options(true)
107
+
108
+ def minimize = update_build_options(false)
109
+
110
+ def author_name = [author_given_name, author_family_name].compress.join(" ")
111
+
112
+ def license_label_version = [license_label, license_version].compress.join("-")
113
+
114
+ def project_label = project_name.titleize
115
+
116
+ def project_class = project_name.camelcase
117
+
118
+ def project_root = target_root.join(project_name)
119
+
120
+ def project_path = project_name.snakecase
121
+
122
+ def computed_project_url_community = format_url(__method__)
123
+
124
+ def computed_project_url_conduct = format_url(__method__)
125
+
126
+ def computed_project_url_contributions = format_url(__method__)
127
+
128
+ def computed_project_url_download = format_url(__method__)
129
+
130
+ def computed_project_url_home = format_url(__method__)
131
+
132
+ def computed_project_url_issues = format_url(__method__)
133
+
134
+ def computed_project_url_license = format_url(__method__)
135
+
136
+ def computed_project_url_security = format_url(__method__)
137
+
138
+ def computed_project_url_source = format_url(__method__)
139
+
140
+ def computed_project_url_versions = format_url(__method__)
141
+
142
+ def ascii_doc? = documentation_format == "adoc"
143
+
144
+ def markdown? = documentation_format == "md"
145
+
146
+ def pathway
147
+ Pathway[start_root: template_root, start_path: template_path, end_root: target_root]
148
+ end
149
+
150
+ def template_root
151
+ template_roots.map(&:expand_path)
152
+ .find { |path| path.join(String(template_path)).exist? }
153
+ end
154
+
155
+ private
156
+
157
+ def format_url kind
158
+ kind.to_s
159
+ .sub("computed_", "")
160
+ .then { |method| public_send method }
161
+ .then { |url| String url }
162
+ .then { |url| url.sub "%project_name%", project_name }
163
+ end
164
+
165
+ def update_build_options value
166
+ to_h.select { |key, _value| key.start_with? "build_" }
167
+ .transform_values { value }
168
+ .then { |attributes| dup.merge!(**attributes, build_minimum: !value) }
169
+ .freeze
170
+ end
171
+ end
172
+ end
173
+ # rubocop:enable Metrics/ModuleLength
174
+ end