rubysmith 0.10.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.adoc +111 -41
  4. data/lib/rubysmith/builder.rb +11 -16
  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 -19
  29. data/lib/rubysmith/cli/configuration/defaults.yml +16 -9
  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 +174 -49
  36. data/lib/rubysmith/cli/parsers/core.rb +14 -9
  37. data/lib/rubysmith/cli/shell.rb +16 -28
  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 -52
  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 -13
  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 -1
  52. data/lib/rubysmith.rb +13 -31
  53. data.tar.gz.sig +0 -0
  54. metadata +92 -11
  55. metadata.gz.sig +0 -0
  56. data/lib/rubysmith/builders/documentation.rb +0 -57
  57. data/lib/rubysmith/cli/processors/build.rb +0 -59
  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: c99851111508a1453340fd292981281260eb2b197e1c3685fd40207078cfeee5
4
- data.tar.gz: e5781a5bf2f57c8129b1049ac817abdb60a2a2548f7a52fcbd29596587f4701c
3
+ metadata.gz: '0803a284b4191d1a3e08664747ddbb8bc743529a93d8d7f393b21dc0b488bead'
4
+ data.tar.gz: 1769e77743e2d90d262fc609dc0ca80a3b60f53400e977bde321d5b0b24e8e9a
5
5
  SHA512:
6
- metadata.gz: 9dcbcf78f012f5fc4eb2409bd7d69ecb42e6033df93a227c510226621d56f8d291458c5528c33bf89673bf81f9849017a003fb8a8fdab649f706c725af862ffe
7
- data.tar.gz: f6f050ce4b479505bbdff25a34a880e8ce72afc48524c283692f34d255686dd4eab037b365019b4fbd83fce9dccce9e1394ea1b47295908b0c29d7d27db56c55
6
+ metadata.gz: b1e9a371e502cb7f14359b2d9c9c4ead3703f2c02b70864e192a1a894a4e5e046e8146d8698edc4ea89570edba94e610b2108a7736ce13341fd08dcd858e705a
7
+ data.tar.gz: 297b580c0a5c44a53d705d3b27f1f3da6590cd067da2d36d7bbbd630f5debb03aea8bd37e858ec79038f3db25cbe5cd28ec5406a6bd7f389ef6877aafd68c455
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
 
@@ -26,12 +29,14 @@ toc::[]
26
29
  * Uses link:https://www.alchemists.io/projects/runcom[Runcom] for resource configuration management.
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
- * Supports link:https://github.com/rubysec/bundler-audit[Bundler Audit].
30
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].
31
35
  * Supports link:https://git-scm.com[Git].
36
+ * Supports link:https://github.com[GitHub].
32
37
  * Supports link:https://www.alchemists.io/projects/git-lint[Git Lint].
33
38
  * Supports link:https://github.com/guard/guard[Guard].
34
- * Supports link:http://pryrepl.org[Pry].
39
+ * Supports link:https://github.com/ruby/rake[Rake].
35
40
  * Supports link:https://github.com/troessner/reek[Reek].
36
41
  * Supports link:https://www.alchemists.io/projects/refinements[Refinements].
37
42
  * Supports link:https://rspec.info[RSpec].
@@ -39,14 +44,14 @@ toc::[]
39
44
  * Supports link:https://docs.rubocop.org/rubocop-performance[Rubocop Performance].
40
45
  * Supports link:https://github.com/rubocop-hq/rubocop-rake[Rubocop Rake].
41
46
  * Supports link:https://github.com/rubocop-hq/rubocop-rspec[Rubocop RSpec].
42
- * Supports link:https://github.com/whitesmith/RubyCritic[RubyCritic].
43
47
  * Supports link:https://github.com/simplecov-ruby/simplecov[SimpleCov].
48
+ * Supports link:https://github.com/fxn/zeitwerk[Zeitwerk].
44
49
  * Supports common settings and a structured layout for building projects.
45
50
  * Provides common documentation:
46
51
  ** README
47
52
  ** CHANGES
48
- ** CONTRIBUTING
49
53
  ** CODE OF CONDUCT
54
+ ** CONTRIBUTING
50
55
  ** LICENSE
51
56
 
52
57
  // == Screencasts
@@ -79,28 +84,35 @@ From the command line, type: `rubysmith --help`
79
84
  ....
80
85
  USAGE:
81
86
  -b, --build NAME [options] Build new project.
82
- -v, --version Show gem version.
83
- -h, --help Show this message.
84
87
  -c, --config ACTION Manage gem configuration: edit or view.
88
+ -h, --help Show this message.
89
+ -v, --version Show gem version.
85
90
 
86
91
  BUILD OPTIONS:
87
- --[no-]amazing_print Add Amazing Print.
88
- --[no-]bundler-audit Add Bundler Audit.
89
- --[no-]bundler-leak Add Bundler Leak.
90
- --[no-]console Add console script.
91
- --[no-]documentation Add documentation.
92
- --[no-]git Add Git.
93
- --[no-]git-lint Add Git Lint.
94
- --[no-]guard Add Guard.
95
- --[no-]pry Add Pry.
96
- --[no-]reek Add Reek.
97
- --[no-]refinements Add Refinements.
98
- --[no-]rspec Add RSpec.
99
- --[no-]rubocop Add Rubocop.
100
- --[no-]ruby_critic Add RubyCritic.
101
- --[no-]setup Add setup script.
102
- --[no-]simple_cov Add SimpleCov.
103
- --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.
104
116
  ....
105
117
 
106
118
  === Building
@@ -118,12 +130,12 @@ to disable specific options, you can use the `--no-*` prefix. Example:
118
130
 
119
131
  [source,bash]
120
132
  ----
121
- rubysmith --build demo --no-pry --no-guard
133
+ rubysmith --build demo --no-debug --no-guard
122
134
  ----
123
135
 
124
- With the above example, both Pry and Guard support would have been disabled when building the `demo`
125
- project. Taking this a step further, you can also use the `--min` option to generate a project with
126
- 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:
127
139
 
128
140
  [source,bash]
129
141
  ----
@@ -134,8 +146,20 @@ The above is essentially the same as building with _all_ options disabled. This
134
146
  situations where you need to quickly script something up for sharing with others yet still want to
135
147
  avoid using a Bundler Inline script so gem dependencies are not installed each time the code is run.
136
148
 
137
- To have specific options enabled/disabled _every time_ you build a new Ruby project, you can edit
138
- 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).
139
163
 
140
164
  === Configuration
141
165
 
@@ -146,9 +170,7 @@ $HOME/.config/rubysmith/configuration.yml
146
170
  ....
147
171
 
148
172
  It can also be configured via link:https://www.alchemists.io/projects/xdg[XDG] environment
149
- variables.
150
-
151
- The default configuration is as follows:
173
+ variables. The default configuration is as follows:
152
174
 
153
175
  [source,yaml]
154
176
  ----
@@ -156,27 +178,31 @@ The default configuration is as follows:
156
178
  :name:
157
179
  :email:
158
180
  :url:
159
- :documentation:
160
- :format: "md"
161
- :license: "mit"
162
181
  :build:
163
182
  :amazing_print: true
164
- :bundler_audit: true
165
183
  :bundler_leak: true
184
+ :changes: true
185
+ :circle_ci: false
186
+ :conduct: true
166
187
  :console: true
167
- :documentation: true
188
+ :contributions: true
189
+ :debug: true
168
190
  :git: true
191
+ :git_hub: false
169
192
  :git_lint: true
170
193
  :guard: true
194
+ :license: true
195
+ :maximum: false
171
196
  :minimum: false
172
- :pry: true
197
+ :rake: true
198
+ :readme: true
173
199
  :reek: true
174
200
  :refinements: true
175
201
  :rspec: true
176
202
  :rubocop: true
177
- :ruby_critic: true
178
203
  :setup: true
179
204
  :simple_cov: true
205
+ :zeitwerk: true
180
206
  :builders:
181
207
  :pragmater:
182
208
  :comments:
@@ -189,11 +215,55 @@ The default configuration is as follows:
189
215
  - "**/*Gemfile"
190
216
  - "**/*Guardfile"
191
217
  - "**/*Rakefile"
218
+ :documentation:
219
+ :format: "md"
220
+ :license: "mit"
221
+ :git_hub:
222
+ :user:
192
223
  ----
193
224
 
194
225
  Feel free to take this default configuration, modify, and save as your own custom
195
226
  `configuration.yml`.
196
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
+
197
267
  == Development
198
268
 
199
269
  To contribute, run:
@@ -10,22 +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
23
- new configuration, helpers: helpers
24
- end
25
-
26
- def initialize configuration, helpers: HELPERS
17
+ def initialize configuration, helpers: HELPERS, container: Container
27
18
  @configuration = configuration
28
19
  @helpers = helpers
20
+ @container = container
29
21
  end
30
22
 
31
23
  def append content
@@ -102,7 +94,7 @@ module Rubysmith
102
94
 
103
95
  private
104
96
 
105
- attr_reader :configuration, :helpers
97
+ attr_reader :configuration, :helpers, :container
106
98
 
107
99
  def execute *command
108
100
  kernel.capture2e(*command).then do |result, status|
@@ -116,12 +108,15 @@ module Rubysmith
116
108
 
117
109
  def kernel = helpers.fetch(__method__)
118
110
 
119
- def logger = helpers.fetch(__method__)
111
+ def logger = container[__method__]
120
112
 
121
- 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)
122
114
 
123
115
  def build_path
124
- 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", ""
125
120
  end
126
121
 
127
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