rubysmith 0.11.0 → 0.15.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 (60) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.adoc +109 -36
  4. data/lib/rubysmith/builder.rb +11 -14
  5. data/lib/rubysmith/builders/bundler.rb +3 -3
  6. data/lib/rubysmith/builders/{ruby_critic.rb → circle_ci.rb} +6 -5
  7. data/lib/rubysmith/builders/console.rb +1 -1
  8. data/lib/rubysmith/builders/core.rb +6 -2
  9. data/lib/rubysmith/builders/documentation/change.rb +32 -0
  10. data/lib/rubysmith/builders/documentation/conduct.rb +32 -0
  11. data/lib/rubysmith/builders/documentation/contribution.rb +32 -0
  12. data/lib/rubysmith/builders/documentation/license.rb +36 -0
  13. data/lib/rubysmith/builders/documentation/readme.rb +44 -0
  14. data/lib/rubysmith/builders/git/commit.rb +1 -1
  15. data/lib/rubysmith/builders/git/setup.rb +1 -1
  16. data/lib/rubysmith/builders/git_hub.rb +34 -0
  17. data/lib/rubysmith/builders/guard.rb +1 -1
  18. data/lib/rubysmith/builders/pragma.rb +1 -1
  19. data/lib/rubysmith/builders/rake.rb +3 -1
  20. data/lib/rubysmith/builders/reek.rb +1 -1
  21. data/lib/rubysmith/builders/rspec/context.rb +1 -1
  22. data/lib/rubysmith/builders/rspec/helper.rb +1 -1
  23. data/lib/rubysmith/builders/rubocop/formatter.rb +1 -1
  24. data/lib/rubysmith/builders/rubocop/setup.rb +1 -1
  25. data/lib/rubysmith/builders/setup.rb +1 -1
  26. data/lib/rubysmith/cli/actions/build.rb +48 -0
  27. data/lib/rubysmith/cli/actions/config.rb +33 -0
  28. data/lib/rubysmith/cli/configuration/content.rb +47 -18
  29. data/lib/rubysmith/cli/configuration/defaults.yml +16 -8
  30. data/lib/rubysmith/cli/configuration/enhancers/current_time.rb +26 -0
  31. data/lib/rubysmith/cli/configuration/enhancers/git_hub_user.rb +33 -0
  32. data/lib/rubysmith/cli/configuration/enhancers/version.rb +26 -0
  33. data/lib/rubysmith/cli/configuration/loader.rb +15 -4
  34. data/lib/rubysmith/cli/parsers/assembler.rb +7 -9
  35. data/lib/rubysmith/cli/parsers/build.rb +176 -45
  36. data/lib/rubysmith/cli/parsers/core.rb +14 -9
  37. data/lib/rubysmith/cli/shell.rb +16 -27
  38. data/lib/rubysmith/container.rb +37 -0
  39. data/lib/rubysmith/identity.rb +2 -2
  40. data/lib/rubysmith/renderers/erb.rb +1 -1
  41. data/lib/rubysmith/renderers/namespace.rb +2 -2
  42. data/lib/rubysmith/templates/%project_name%/.circleci/config.yml.erb +31 -0
  43. data/lib/rubysmith/templates/%project_name%/.github/ISSUE_TEMPLATE.md.erb +14 -0
  44. data/lib/rubysmith/templates/%project_name%/.github/PULL_REQUEST_TEMPLATE.md.erb +11 -0
  45. data/lib/rubysmith/templates/%project_name%/Gemfile.erb +51 -49
  46. data/lib/rubysmith/templates/%project_name%/README.adoc.erb +4 -0
  47. data/lib/rubysmith/templates/%project_name%/README.md.erb +3 -0
  48. data/lib/rubysmith/templates/%project_name%/Rakefile.erb +1 -7
  49. data/lib/rubysmith/templates/%project_name%/bin/console.erb +1 -1
  50. data/lib/rubysmith/templates/%project_name%/lib/%project_path%.rb.erb +12 -0
  51. data/lib/rubysmith/templates/%project_name%/spec/spec_helper.rb.erb +1 -4
  52. data/lib/rubysmith.rb +13 -31
  53. data.tar.gz.sig +0 -0
  54. metadata +94 -13
  55. metadata.gz.sig +0 -0
  56. data/lib/rubysmith/builders/documentation.rb +0 -57
  57. data/lib/rubysmith/cli/processors/build.rb +0 -57
  58. data/lib/rubysmith/cli/processors/config.rb +0 -31
  59. data/lib/rubysmith/templates/%project_name%/.rubycritic.yml.erb +0 -3
  60. data/lib/rubysmith/templates/%project_name%/lib/%project_name%.rb.erb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae1f7e375e5e5d37e378cb82620d52dead76d846f2ea22cbbd32b76f714fc076
4
- data.tar.gz: c2fb2727fd8af69b4cbbc35e55b9ff3dc1cdc96f0d05609d505ffaf10ba2e444
3
+ metadata.gz: dad99d389fc745abc0ee0cbb8543dfee116f171950640c84bfd80bfd9d4cd171
4
+ data.tar.gz: 9b504d057fad0f6fc1a3d5bc55fb61670df147304e12d27ad80541635cad3677
5
5
  SHA512:
6
- metadata.gz: 8ee1ad6e82cac22883971e4cf1ff46c606173385f507908be37cc2839fe9c4b9fd8104c1354a74fb7784c592f2cf0bcae44ae5feee71f4db12892c4a971b9fef
7
- data.tar.gz: e29e0e144ca76fe0819bfceb8ca936171b0267c67c144acfd6c5aebc6cca8d84f3ecb165cd9f7f69f142a6c28685d2be20c45b68f605d741dfaec25e782eb459
6
+ metadata.gz: 354cbaa3b247d4e12439f3d5927fa1d1c13542d8ae791e80660632910e3caf22abb748c4572baf565ca44ff89fe6a312bae8aafe9898329f1e28beadfbe1984c
7
+ data.tar.gz: 19098dd6c0b04959583c241628c71126adf97b6f0e0d5023c28828aeab92a7fd4d55c0c01361222bcc809052ebb5a90b3ea1e4ee2548ee9050e7bcedce07cce8
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -15,8 +15,11 @@ Rubysmith is a command line interface for smithing Ruby projects.
15
15
 
16
16
  This gem is useful in situations in which you need something more sophisticated than a
17
17
  link:https://bundler.io/guides/bundler_in_a_single_file_ruby_script.html[Bundler Inline] script but
18
- less complicated than a Ruby Gem as provided by
19
- link:https://www.alchemists.io/projects/gemsmith[Gemsmith].
18
+ less complicated than a link:https://www.alchemists.io/projects/gemsmith[Gemsmith] gem. Rubysmith is
19
+ the foundation of Gemsmith and provides a lot of the same functionality as Gemsmith but solely
20
+ tailored for pure Ruby projects. Again, this is a great tool for spiking quick Ruby implementations,
21
+ sharing code snippets with others, or building full blown Ruby projects for collaboration with
22
+ others.
20
23
 
21
24
  toc::[]
22
25
 
@@ -27,10 +30,13 @@ toc::[]
27
30
  * Uses link:https://www.alchemists.io/projects/pragmater[Pragmater] for Ruby source pragma directives.
28
31
  * Supports link:https://github.com/amazing-print/amazing_print[Amazing Print].
29
32
  * Supports link:https://github.com/rubymem/bundler-leak[Bundler Leak].
33
+ * Supports link:https://circleci.com[Circle CI].
34
+ * Supports link:https://github.com/ruby/debug[Debug].
30
35
  * Supports link:https://git-scm.com[Git].
36
+ * Supports link:https://github.com[GitHub].
31
37
  * Supports link:https://www.alchemists.io/projects/git-lint[Git Lint].
32
38
  * Supports link:https://github.com/guard/guard[Guard].
33
- * Supports link:http://pryrepl.org[Pry].
39
+ * Supports link:https://github.com/ruby/rake[Rake].
34
40
  * Supports link:https://github.com/troessner/reek[Reek].
35
41
  * Supports link:https://www.alchemists.io/projects/refinements[Refinements].
36
42
  * Supports link:https://rspec.info[RSpec].
@@ -38,14 +44,14 @@ toc::[]
38
44
  * Supports link:https://docs.rubocop.org/rubocop-performance[Rubocop Performance].
39
45
  * Supports link:https://github.com/rubocop-hq/rubocop-rake[Rubocop Rake].
40
46
  * Supports link:https://github.com/rubocop-hq/rubocop-rspec[Rubocop RSpec].
41
- * Supports link:https://github.com/whitesmith/RubyCritic[RubyCritic].
42
47
  * Supports link:https://github.com/simplecov-ruby/simplecov[SimpleCov].
48
+ * Supports link:https://github.com/fxn/zeitwerk[Zeitwerk].
43
49
  * Supports common settings and a structured layout for building projects.
44
50
  * Provides common documentation:
45
51
  ** README
46
52
  ** CHANGES
47
- ** CONTRIBUTING
48
53
  ** CODE OF CONDUCT
54
+ ** CONTRIBUTING
49
55
  ** LICENSE
50
56
 
51
57
  // == Screencasts
@@ -83,22 +89,30 @@ USAGE:
83
89
  -v, --version Show gem version.
84
90
 
85
91
  BUILD OPTIONS:
86
- --[no-]amazing_print Add Amazing Print.
87
- --[no-]bundler-leak Add Bundler Leak.
88
- --[no-]console Add console script.
89
- --[no-]documentation Add documentation.
90
- --[no-]git Add Git.
91
- --[no-]git-lint Add Git Lint.
92
- --[no-]guard Add Guard.
93
- --[no-]pry Add Pry.
94
- --[no-]reek Add Reek.
95
- --[no-]refinements Add Refinements.
96
- --[no-]rspec Add RSpec.
97
- --[no-]rubocop Add Rubocop.
98
- --[no-]ruby_critic Add RubyCritic.
99
- --[no-]setup Add setup script.
100
- --[no-]simple_cov Add SimpleCov.
101
- --min Use minimum/no options.
92
+ --[no-]amazing_print Add Amazing Print gem. Default: true.
93
+ --[no-]bundler-leak Add Bundler Leak gem. Default: true.
94
+ --[no-]changes Add CHANGES documentation. Default: true.
95
+ --[no-]circle_ci Add Circle CI configuration and badge. Default: false.
96
+ --[no-]conduct Add CODE_OF_CONDUCT documentation. Default: true.
97
+ --[no-]console Add console script. Default: true.
98
+ --[no-]contributions Add CONTRIBUTING documentation. Default: true.
99
+ --[no-]debug Add Debug gem. Default: true.
100
+ --[no-]git Add Git. Default: true.
101
+ --[no-]git_hub Add GitHub templates. Default: false.
102
+ --[no-]git-lint Add Git Lint gem. Default: true.
103
+ --[no-]guard Add Guard gem. Default: true.
104
+ --[no-]license Add LICENSE documentation. Default: true.
105
+ --max Use maximum/enabled options. Default: false.
106
+ --min Use minimum/disabled options. Default: false.
107
+ --[no-]rake Add Rake gem. Default: true.
108
+ --[no-]readme Add README documentation. Default: true.
109
+ --[no-]reek Add Reek gem. Default: true.
110
+ --[no-]refinements Add Refinements gem. Default: true.
111
+ --[no-]rspec Add RSpec gem. Default: true.
112
+ --[no-]rubocop Add Rubocop gems. Default: true.
113
+ --[no-]setup Add setup script. Default: true.
114
+ --[no-]simple_cov Add SimpleCov gem. Default: true.
115
+ --[no-]zeitwerk Add Zeitwerk gem. Default: true.
102
116
  ....
103
117
 
104
118
  === Building
@@ -116,12 +130,12 @@ to disable specific options, you can use the `--no-*` prefix. Example:
116
130
 
117
131
  [source,bash]
118
132
  ----
119
- rubysmith --build demo --no-pry --no-guard
133
+ rubysmith --build demo --no-debug --no-guard
120
134
  ----
121
135
 
122
- With the above example, both Pry and Guard support would have been disabled when building the `demo`
123
- project. Taking this a step further, you can also use the `--min` option to generate a project with
124
- bare minimum of options. Example:
136
+ With the above example, both Debug and Guard support would have been disabled when building the
137
+ `demo` project. Taking this a step further, you can also use the `--min` option to generate a
138
+ project with bare minimum of options. Example:
125
139
 
126
140
  [source,bash]
127
141
  ----
@@ -132,8 +146,20 @@ The above is essentially the same as building with _all_ options disabled. This
132
146
  situations where you need to quickly script something up for sharing with others yet still want to
133
147
  avoid using a Bundler Inline script so gem dependencies are not installed each time the code is run.
134
148
 
135
- To have specific options enabled/disabled _every time_ you build a new Ruby project, you can edit
136
- your global configuration for making these settings permanent (see below for details).
149
+ As shown earlier, you can combine options but be aware that order matters. Take the following, for
150
+ example, where both minimum and maximum options are used in conjunction with other options:
151
+
152
+ [source,bash]
153
+ ----
154
+ rubysmith --build demo --min --zeitwerk
155
+ rubysmith --build demo --max --no-debug
156
+ ----
157
+
158
+ With the above examples, the first line will _disable_ all options except for Zeitwerk while the
159
+ second line will _enable_ all options except for Debug. This can be a handy way to build a new
160
+ project with all options either disabled or enabled with only a few select options modified. To have
161
+ specific options enabled/disabled _every time_ you build a new Ruby project, you can edit your
162
+ global configuration for making these settings permanent (see below for details).
137
163
 
138
164
  === Configuration
139
165
 
@@ -144,9 +170,7 @@ $HOME/.config/rubysmith/configuration.yml
144
170
  ....
145
171
 
146
172
  It can also be configured via link:https://www.alchemists.io/projects/xdg[XDG] environment
147
- variables.
148
-
149
- The default configuration is as follows:
173
+ variables. The default configuration is as follows:
150
174
 
151
175
  [source,yaml]
152
176
  ----
@@ -154,26 +178,31 @@ The default configuration is as follows:
154
178
  :name:
155
179
  :email:
156
180
  :url:
157
- :documentation:
158
- :format: "md"
159
- :license: "mit"
160
181
  :build:
161
182
  :amazing_print: true
162
183
  :bundler_leak: true
184
+ :changes: true
185
+ :circle_ci: false
186
+ :conduct: true
163
187
  :console: true
164
- :documentation: true
188
+ :contributions: true
189
+ :debug: true
165
190
  :git: true
191
+ :git_hub: false
166
192
  :git_lint: true
167
193
  :guard: true
194
+ :license: true
195
+ :maximum: false
168
196
  :minimum: false
169
- :pry: true
197
+ :rake: true
198
+ :readme: true
170
199
  :reek: true
171
200
  :refinements: true
172
201
  :rspec: true
173
202
  :rubocop: true
174
- :ruby_critic: true
175
203
  :setup: true
176
204
  :simple_cov: true
205
+ :zeitwerk: true
177
206
  :builders:
178
207
  :pragmater:
179
208
  :comments:
@@ -186,11 +215,55 @@ The default configuration is as follows:
186
215
  - "**/*Gemfile"
187
216
  - "**/*Guardfile"
188
217
  - "**/*Rakefile"
218
+ :documentation:
219
+ :format: "md"
220
+ :license: "mit"
221
+ :git_hub:
222
+ :user:
189
223
  ----
190
224
 
191
225
  Feel free to take this default configuration, modify, and save as your own custom
192
226
  `configuration.yml`.
193
227
 
228
+ ==== Author
229
+
230
+ Author information is used when generating project documentation and is recommended you fill this
231
+ information in before building a project. Example:
232
+
233
+ :author:
234
+ :name: Jill Smith
235
+ :email: jsmith@example.com
236
+ :url: https://www.exmaple.com/team/jsmith
237
+
238
+ ==== Build
239
+
240
+ Build options are booleans so can only be `true` or `false` by default. Should you want a different
241
+ configuration than what is enabled/disabled by default, you'll want to customize these options as
242
+ you see fit. When changing build options, they will dynamically show up when viewing usage (i.e.
243
+ `rubysmith --help`).
244
+
245
+ ==== Builders
246
+
247
+ Builders are additional tooling which can be configured specifically for Rubysmith. At the moment,
248
+ only link:https://www.alchemists.io/projects/pragmater[Pragmater] is supported so view the Pragmater
249
+ project page to learn more.
250
+
251
+ ==== Documentation
252
+
253
+ Documentation can be configured as follows:
254
+
255
+ * *Format*: Use `md` for Markdown or `adoc` for ASCCI Doc.
256
+ * *License*: Use `mit` for MIT or `Apache` for Apache 2.0.0 license.
257
+
258
+ No other licenses are supported at this time but might be expanded up on in the future.
259
+
260
+ ==== GitHub
261
+
262
+ Your GitHub user is whatever handle you setup when you creating your GitHub account. This
263
+ information is used for documentation purposes and Circle CI badge association. If you don't define
264
+ this information, Rubysmith will automatically fallback to pulling this information from your Git
265
+ configuration (i.e. `github.user`). If all else fails, then nothing will be used.
266
+
194
267
  == Development
195
268
 
196
269
  To contribute, run:
@@ -10,20 +10,14 @@ module Rubysmith
10
10
  class Builder
11
11
  using Refinements::Pathnames
12
12
 
13
- LOGGER = Logger.new(STDOUT, formatter: ->(_severity, _at, _program, message) { "#{message}\n" })
13
+ HELPERS = {inserter: Text::Inserter, renderer: Renderers::ERB, kernel: Open3}.freeze
14
14
 
15
- HELPERS = {
16
- inserter: Text::Inserter,
17
- renderer: Renderers::ERB,
18
- kernel: Open3,
19
- logger: LOGGER
20
- }.freeze
15
+ def self.call(...) = new(...)
21
16
 
22
- def self.call(configuration, helpers: HELPERS) = new(configuration, helpers: helpers)
23
-
24
- def initialize configuration, helpers: HELPERS
17
+ def initialize configuration, helpers: HELPERS, container: Container
25
18
  @configuration = configuration
26
19
  @helpers = helpers
20
+ @container = container
27
21
  end
28
22
 
29
23
  def append content
@@ -100,7 +94,7 @@ module Rubysmith
100
94
 
101
95
  private
102
96
 
103
- attr_reader :configuration, :helpers
97
+ attr_reader :configuration, :helpers, :container
104
98
 
105
99
  def execute *command
106
100
  kernel.capture2e(*command).then do |result, status|
@@ -114,12 +108,15 @@ module Rubysmith
114
108
 
115
109
  def kernel = helpers.fetch(__method__)
116
110
 
117
- def logger = helpers.fetch(__method__)
111
+ def logger = container[__method__]
118
112
 
119
- def relative_build_path = build_path.relative_path_from(configuration.build_root)
113
+ def relative_build_path = build_path.relative_path_from(configuration.target_root)
120
114
 
121
115
  def build_path
122
- pathway.end_path.gsub("%project_name%", configuration.project_name).sub ".erb", ""
116
+ pathway.end_path
117
+ .gsub("%project_name%", configuration.project_name)
118
+ .sub("%project_path%", configuration.project_path)
119
+ .sub ".erb", ""
123
120
  end
124
121
 
125
122
  def pathway = configuration.to_pathway
@@ -10,7 +10,7 @@ module Rubysmith
10
10
  class Bundler
11
11
  using Refinements::Pathnames
12
12
 
13
- def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
13
+ def self.call(...) = new(...).call
14
14
 
15
15
  def initialize configuration, builder: Builder, client: ::Bundler::CLI
16
16
  @configuration = configuration
@@ -23,9 +23,9 @@ module Rubysmith
23
23
  .render
24
24
  .replace(/\n\s+group/, "\n\ngroup")
25
25
  .replace(/\n\s+gem/, "\n gem")
26
- .replace(/ (?=.+refinements)/, "")
26
+ .replace(/ (?=.+(refinements|zeitwerk))/, "")
27
27
  .replace(/(\n+|\s+)end/, "\nend")
28
- .replace(/\n\ngroup :(code_quality|test|tools) do\nend/, "")
28
+ .replace(/\n\ngroup :(code_quality|development|test|tools) do\nend/, "")
29
29
  .replace(/org"\n+/, "org\"\n\n")
30
30
 
31
31
  configuration.project_root.change_dir { client.start %w[install --quiet] }
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Rubysmith
4
4
  module Builders
5
- # Builds project skeleton RubyCritic code quality support.
6
- class RubyCritic
7
- def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
5
+ # Builds project skeleton Circle CI configuration.
6
+ class CircleCI
7
+ def self.call(...) = new(...).call
8
8
 
9
9
  def initialize configuration, builder: Builder
10
10
  @configuration = configuration
@@ -12,9 +12,10 @@ module Rubysmith
12
12
  end
13
13
 
14
14
  def call
15
- return unless configuration.build_ruby_critic
15
+ return unless configuration.build_circle_ci
16
16
 
17
- builder.call(configuration.with(template_path: "%project_name%/.rubycritic.yml.erb")).render
17
+ builder.call(configuration.with(template_path: "%project_name%/.circleci/config.yml.erb"))
18
+ .render
18
19
  end
19
20
 
20
21
  private
@@ -4,7 +4,7 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton console for object inspection and exploration.
6
6
  class Console
7
- def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
7
+ def self.call(...) = new(...).call
8
8
 
9
9
  def initialize configuration, builder: Builder
10
10
  @configuration = configuration
@@ -4,7 +4,7 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton core structure and minimum file support.
6
6
  class Core
7
- def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
7
+ def self.call(...) = new(...).call
8
8
 
9
9
  def initialize configuration, builder: Builder
10
10
  @configuration = configuration
@@ -12,8 +12,12 @@ module Rubysmith
12
12
  end
13
13
 
14
14
  def call
15
- builder.call(configuration.with(template_path: "%project_name%/lib/%project_name%.rb.erb"))
15
+ builder.call(configuration.with(template_path: "%project_name%/lib/%project_path%.rb.erb"))
16
16
  .render
17
+ .replace(" require", "require")
18
+ .replace(/ (?=(Zeit|\.tap|\.setup))/, "")
19
+ .replace("\n \n", "\n\n")
20
+
17
21
  builder.call(configuration.with(template_path: "%project_name%/.ruby-version.erb")).render
18
22
  nil
19
23
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tocer"
4
+
5
+ module Rubysmith
6
+ module Builders
7
+ module Documentation
8
+ # Builds project skeleton CHANGES documentation.
9
+ class Change
10
+ def self.call(...) = new(...).call
11
+
12
+ def initialize configuration, builder: Builder
13
+ @configuration = configuration
14
+ @builder = builder
15
+ end
16
+
17
+ def call
18
+ return unless configuration.build_changes
19
+
20
+ builder.call(configuration.with(template_path: "%project_name%/CHANGES.#{kind}.erb"))
21
+ .render
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :configuration, :builder
27
+
28
+ def kind = configuration.documentation_format || "md"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tocer"
4
+
5
+ module Rubysmith
6
+ module Builders
7
+ module Documentation
8
+ # Builds project skeleton CODE_OF_CONDUCT documentation.
9
+ class Conduct
10
+ def self.call(...) = new(...).call
11
+
12
+ def initialize configuration, builder: Builder
13
+ @configuration = configuration
14
+ @builder = builder
15
+ end
16
+
17
+ def call
18
+ return unless configuration.build_conduct
19
+
20
+ configuration.with(template_path: "%project_name%/CODE_OF_CONDUCT.#{kind}.erb")
21
+ .then { |updated_configuration| builder.call(updated_configuration).render }
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :configuration, :builder
27
+
28
+ def kind = configuration.documentation_format || "md"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tocer"
4
+
5
+ module Rubysmith
6
+ module Builders
7
+ module Documentation
8
+ # Builds project skeleton CONTRIBUTING documentation.
9
+ class Contribution
10
+ def self.call(...) = new(...).call
11
+
12
+ def initialize configuration, builder: Builder
13
+ @configuration = configuration
14
+ @builder = builder
15
+ end
16
+
17
+ def call
18
+ return unless configuration.build_contributions
19
+
20
+ builder.call(configuration.with(template_path: "%project_name%/CONTRIBUTING.#{kind}.erb"))
21
+ .render
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :configuration, :builder
27
+
28
+ def kind = configuration.documentation_format || "md"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tocer"
4
+
5
+ module Rubysmith
6
+ module Builders
7
+ module Documentation
8
+ # Builds project skeleton LICENSE documentation.
9
+ class License
10
+ def self.call(...) = new(...).call
11
+
12
+ def initialize configuration, builder: Builder
13
+ @configuration = configuration
14
+ @builder = builder
15
+ end
16
+
17
+ def call
18
+ return unless configuration.build_license
19
+
20
+ configuration.with(template_path: "%project_name%/LICENSE-#{license}.#{kind}.erb")
21
+ .then do |updated_configuration|
22
+ builder.call(updated_configuration).render.rename "LICENSE.#{kind}"
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ attr_reader :configuration, :builder
29
+
30
+ def kind = configuration.documentation_format || "md"
31
+
32
+ def license = configuration.documentation_license || "mit"
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tocer"
4
+
5
+ module Rubysmith
6
+ module Builders
7
+ module Documentation
8
+ # Builds project skeleton README documentation.
9
+ class Readme
10
+ def self.call(...) = new(...).call
11
+
12
+ def initialize configuration, builder: Builder, tocer: Tocer::Writer.new
13
+ @configuration = configuration
14
+ @builder = builder
15
+ @tocer = tocer
16
+ end
17
+
18
+ def call
19
+ return unless configuration.build_readme
20
+
21
+ private_methods.sort.grep(/render_/).each { |method| __send__ method }
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :configuration, :builder, :tocer
27
+
28
+ def render_content
29
+ builder.call(configuration.with(template_path: "%project_name%/README.#{kind}.erb"))
30
+ .render
31
+ .replace("\n\n\n", "\n\n")
32
+ end
33
+
34
+ def render_table_of_contents
35
+ configuration.project_root
36
+ .join("README.md")
37
+ .then { |path| tocer.call path if path.exist? }
38
+ end
39
+
40
+ def kind = configuration.documentation_format || "md"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -5,7 +5,7 @@ module Rubysmith
5
5
  module Git
6
6
  # Builds project skeleton initial Git commit message.
7
7
  class Commit
8
- def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
8
+ def self.call(...) = new(...).call
9
9
 
10
10
  def initialize configuration, builder: Builder
11
11
  @configuration = configuration
@@ -5,7 +5,7 @@ module Rubysmith
5
5
  module Git
6
6
  # Initializes project skeleton as a Git repository.
7
7
  class Setup
8
- def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
8
+ def self.call(...) = new(...).call
9
9
 
10
10
  def initialize configuration, builder: Builder
11
11
  @configuration = configuration
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rubysmith
4
+ module Builders
5
+ # Builds project skeleton GitHub templates.
6
+ class GitHub
7
+ def self.call(...) = new(...).call
8
+
9
+ def initialize configuration, builder: Builder
10
+ @configuration = configuration
11
+ @builder = builder
12
+ end
13
+
14
+ def call
15
+ return unless configuration.build_git_hub
16
+
17
+ builder.call(with_issue_template).render
18
+ builder.call(with_pull_request_template).render
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :configuration, :builder
24
+
25
+ def with_issue_template
26
+ configuration.with template_path: "%project_name%/.github/ISSUE_TEMPLATE.md.erb"
27
+ end
28
+
29
+ def with_pull_request_template
30
+ configuration.with template_path: "%project_name%/.github/PULL_REQUEST_TEMPLATE.md.erb"
31
+ end
32
+ end
33
+ end
34
+ end
@@ -4,7 +4,7 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton Guard support for a red, green, refactor loop.
6
6
  class Guard
7
- def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
7
+ def self.call(...) = new(...).call
8
8
 
9
9
  def initialize configuration, builder: Builder
10
10
  @configuration = configuration
@@ -6,7 +6,7 @@ module Rubysmith
6
6
  module Builders
7
7
  # Builds project skeleton pragmas so all Ruby strings are frozen by default.
8
8
  class Pragma
9
- def self.call(configuration) = new(configuration).call
9
+ def self.call(...) = new(...).call
10
10
 
11
11
  def initialize configuration, client: Pragmater::Runner
12
12
  @configuration = configuration
@@ -4,7 +4,7 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton Rake support.
6
6
  class Rake
7
- def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
7
+ def self.call(...) = new(...).call
8
8
 
9
9
  def initialize configuration, builder: Builder
10
10
  @configuration = configuration
@@ -12,6 +12,8 @@ module Rubysmith
12
12
  end
13
13
 
14
14
  def call
15
+ return unless configuration.build_rake
16
+
15
17
  builder.call(configuration.with(template_path: "%project_name%/Rakefile.erb"))
16
18
  .render
17
19
  .replace(/\[\s+/, "[")
@@ -4,7 +4,7 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton Reek code quality support.
6
6
  class Reek
7
- def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
7
+ def self.call(...) = new(...).call
8
8
 
9
9
  def initialize configuration, builder: Builder
10
10
  @configuration = configuration