rubysmith 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.adoc +40 -38
  4. data/exe/rubysmith +0 -1
  5. data/lib/rubysmith/builders/{rubocop.rb → caliber.rb} +3 -3
  6. data/lib/rubysmith/builders/core.rb +9 -2
  7. data/lib/rubysmith/builders/git/commit.rb +2 -2
  8. data/lib/rubysmith/builders/version.rb +30 -0
  9. data/lib/rubysmith/cli/actions/build.rb +2 -1
  10. data/lib/rubysmith/cli/parsers/build.rb +13 -4
  11. data/lib/rubysmith/cli/parsers/core.rb +8 -3
  12. data/lib/rubysmith/cli/shell.rb +3 -1
  13. data/lib/rubysmith/configuration/content.rb +8 -4
  14. data/lib/rubysmith/configuration/defaults.yml +10 -8
  15. data/lib/rubysmith/configuration/loader.rb +1 -1
  16. data/lib/rubysmith/container.rb +2 -0
  17. data/lib/rubysmith/extensions/milestoner.rb +9 -7
  18. data/lib/rubysmith/extensions/pragmater.rb +8 -7
  19. data/lib/rubysmith/extensions/tocer.rb +9 -7
  20. data/lib/rubysmith/renderers/erb.rb +10 -2
  21. data/lib/rubysmith/renderers/namespace.rb +3 -3
  22. data/lib/rubysmith/templates/%project_name%/.gitignore.erb +0 -3
  23. data/lib/rubysmith/templates/%project_name%/.rubocop.yml.erb +2 -9
  24. data/lib/rubysmith/templates/%project_name%/Gemfile.erb +9 -14
  25. data/lib/rubysmith/templates/%project_name%/README.adoc.erb +0 -9
  26. data/lib/rubysmith/templates/%project_name%/README.md.erb +0 -7
  27. data/lib/rubysmith/templates/%project_name%/Rakefile.erb +3 -3
  28. data/lib/rubysmith/templates/%project_name%/lib/%project_path%.rb.erb +5 -5
  29. data/rubysmith.gemspec +41 -0
  30. data.tar.gz.sig +0 -0
  31. metadata +31 -15
  32. metadata.gz.sig +0 -0
  33. data/lib/rubysmith/identity.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de17a0e1a14656faf3c41d6eb187aaa58acd051e1a320b6e8e42c759c8cfc3e8
4
- data.tar.gz: bee0b69eb4affb36042197ac9b7dc0d138b847a229bce03e1a6ac5e53c608192
3
+ metadata.gz: e5486da67dbe6ea1ef0ce376a6d4e59c32fa5a84c46b5fec2eef493339e6ca40
4
+ data.tar.gz: 7fc86c2c1e38733990b2f7236b44b068a9dfaaf38e7b109b923f30e7b548517a
5
5
  SHA512:
6
- metadata.gz: 1a548b6f39715b29606ecc3bfe7a9a211b8b5f43c8adf86f68956e4d35cbf678062178106d1932f78a1173a64482b6b0e83962e923700723f18889e082ac9d13
7
- data.tar.gz: aeea9f7e1e4e9df57f8c118f5c931cde45a071d4c261d6632e03def688b6aba4d9e408c92a4dd68a875d55b99f39928a000b76706d27fa92fa4dc372b3682941
6
+ metadata.gz: 7d156e06cb6dd5003f35cba343887f6b8d1658a5e7b70085237af5ffed9466352c1cb6667259cdf5523786e078f04dcbc6b1f3e2352dd71d79c90a819b01b258
7
+ data.tar.gz: 3a10b92f11bf709ee8922fd85698ade151f6c557148110d2c2ba352ea3221fb2dbce5d2702772d5398c3fd54b26aa95e063157be3a8b7e9d5e5a6ba5385fa42e
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -4,13 +4,6 @@
4
4
 
5
5
  = Rubysmith
6
6
 
7
- [link=http://badge.fury.io/rb/rubysmith]
8
- image::https://badge.fury.io/rb/rubysmith.svg[Gem Version]
9
- [link=https://www.alchemists.io/projects/code_quality]
10
- image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchemists Style Guide]
11
- [link=https://circleci.com/gh/bkuhlmann/rubysmith]
12
- image::https://circleci.com/gh/bkuhlmann/rubysmith.svg?style=svg[Circle CI Status]
13
-
14
7
  Rubysmith is a command line interface for smithing Ruby projects.
15
8
 
16
9
  This gem is useful in situations in which you need something more sophisticated than a
@@ -29,8 +22,9 @@ toc::[]
29
22
  * Uses link:https://www.alchemists.io/projects/pragmater[Pragmater] for Ruby source pragma directives.
30
23
  * Supports link:https://github.com/amazing-print/amazing_print[Amazing Print].
31
24
  * Supports link:https://github.com/rubymem/bundler-leak[Bundler Leak].
25
+ * Supports link:https://www.alchemists.io/projects/caliber[Caliber].
32
26
  * Supports link:https://circleci.com[Circle CI].
33
- * Supports link:https://orcid.org[ORCID Citations].
27
+ * Supports link:https://orcid.org[Citations (ORCID)].
34
28
  * Supports console script for local development.
35
29
  * Supports link:https://rubygems.org/gems/dead_end[DeadEnd].
36
30
  * Supports link:https://github.com/ruby/debug[Debug].
@@ -42,11 +36,9 @@ toc::[]
42
36
  * Supports link:https://github.com/troessner/reek[Reek].
43
37
  * Supports link:https://www.alchemists.io/projects/refinements[Refinements].
44
38
  * Supports link:https://rspec.info[RSpec].
45
- * Supports link:https://github.com/rubocop-hq/rubocop[Rubocop].
46
- * Supports link:https://docs.rubocop.org/rubocop-performance[Rubocop Performance].
47
- * Supports link:https://github.com/rubocop-hq/rubocop-rake[Rubocop Rake].
48
- * Supports link:https://github.com/rubocop-hq/rubocop-rspec[Rubocop RSpec].
39
+ * Supports setup script for project setup.
49
40
  * Supports link:https://github.com/simplecov-ruby/simplecov[SimpleCov].
41
+ * Supports link:https://yardoc.org[YARD].
50
42
  * Supports link:https://github.com/fxn/zeitwerk[Zeitwerk].
51
43
  * Supports common settings and a structured layout for building projects.
52
44
  * Provides common documentation:
@@ -72,6 +64,16 @@ To install, run:
72
64
  gem install rubysmith
73
65
  ----
74
66
 
67
+ == Upgrade
68
+
69
+ If upgrading from 1.0.0 to 2.0.0, you'll need to make the following changes:
70
+
71
+ * README badges are no longer injected so you can customize as desired.
72
+ * The `:rubocop:` build configuration has been removed. Use `:caliber:` instead.
73
+ * The `--rubocop` build option has been removed. Use `--caliber` instead.
74
+ * You no longer have to Git ignore RuboCop cached configurations since this is handled by the
75
+ Caliber gem now.
76
+
75
77
  == Usage
76
78
 
77
79
  === Command Line Interface (CLI)
@@ -89,6 +91,7 @@ USAGE:
89
91
  BUILD OPTIONS:
90
92
  --[no-]amazing_print Add Amazing Print gem. Default: true.
91
93
  --[no-]bundler-leak Add Bundler Leak gem. Default: true.
94
+ --[no-]caliber Add Caliber gem. Default: true.
92
95
  --[no-]circle_ci Add Circle CI configuration and badge. Default: false.
93
96
  --[no-]citation Add citation documentation. Default: true.
94
97
  --[no-]community Add community documentation. Default: false.
@@ -109,7 +112,7 @@ BUILD OPTIONS:
109
112
  --[no-]reek Add Reek gem. Default: true.
110
113
  --[no-]refinements Add Refinements gem. Default: true.
111
114
  --[no-]rspec Add RSpec gem. Default: true.
112
- --[no-]rubocop Add RuboCop gems. Default: true.
115
+ --[no-]security Add security. Default: true.
113
116
  --[no-]setup Add setup script. Default: true.
114
117
  --[no-]simple_cov Add SimpleCov gem. Default: true.
115
118
  --[no-]versions Add version history. Default: true.
@@ -181,11 +184,17 @@ The `--bundler-leak` option allows you to build your project with the
181
184
  link:https://github.com/rubymem/bundler-leak[Bundler Leak] gem which helps detect memory leaks in
182
185
  your gem dependencies.
183
186
 
187
+ ==== Caliber
188
+
189
+ The `--caliber` option allows you to build your project with the
190
+ link:https://www.alchemists.io/projects/caliber[Caliber] gem so you have an immediate working -- and
191
+ high quality -- link:https://docs.rubocop.org/rubocop[RuboCop] configuration. Read the Caliber
192
+ documentation for further customization.
193
+
184
194
  ==== Circle CI
185
195
 
186
196
  The `--circle_ci` option allows you to build your project with link:https://circleci.com[Circle CI]
187
- configured so you can get your project building as quickly as possible. This includes a README badge
188
- and configuration YAML.
197
+ configured so you can get your project building as quickly as possible.
189
198
 
190
199
  ==== Citation
191
200
 
@@ -218,8 +227,8 @@ contribute back to your work.
218
227
  ==== DeadEnd
219
228
 
220
229
  The `--dead_end` option allows you build your project with the
221
- link:https://github.com/zombocom/dead_end[DeadEnd] for debugging purposes since the DeadEnd gem will
222
- show you where you are missing `end`'s and closing statements.
230
+ link:https://github.com/zombocom/dead_end[Dead End] gem for debugging purposes since Dead End will
231
+ show you where you are missing closing `end` statements.
223
232
 
224
233
  ==== Debug
225
234
 
@@ -259,7 +268,7 @@ to build a new project with all options enabled without having to pick and choos
259
268
  ==== Minimum
260
269
 
261
270
  The `--min` option allows you to build your project with _all_ options _disabled_. This is a quick
262
- way to build a new project with the bare minimum of support which is a one step above reaching for
271
+ way to build a new project with the bare minimum of support which is a one step above reaching for a
263
272
  Bundler Inline script.
264
273
 
265
274
  ==== Rake
@@ -287,13 +296,6 @@ Ruby core objects without monkey patching your code.
287
296
  The `--rspec` option allows you add the link:https://rspec.info[RSpec] gem to your project for
288
297
  defining your project specifications and have a framework for testing your code.
289
298
 
290
- ==== Rubocop
291
-
292
- The `--rubocop` option allows you to add the link:https://docs.rubocop.org[RuboCop] gem and suite
293
- of gems to your project for good code quality standards. This the Alchemists style guide, provided
294
- by the link:https://www.alchemists.io/projects/code_quality[Code Quality] project, is what is used
295
- by default.
296
-
297
299
  ==== Setup
298
300
 
299
301
  The `--setup` option allows you to configure you project with automated setup instructions so anyone
@@ -359,6 +361,7 @@ variables. The default configuration is as follows:
359
361
  :build:
360
362
  :amazing_print: true
361
363
  :bundler_leak: true
364
+ :caliber: true
362
365
  :circle_ci: false
363
366
  :citation: true
364
367
  :community: false
@@ -379,7 +382,6 @@ variables. The default configuration is as follows:
379
382
  :reek: true
380
383
  :refinements: true
381
384
  :rspec: true
382
- :rubocop: true
383
385
  :security: true
384
386
  :setup: true
385
387
  :simple_cov: true
@@ -407,15 +409,17 @@ variables. The default configuration is as follows:
407
409
  :comments:
408
410
  - "# frozen_string_literal: true"
409
411
  :includes:
410
- - "**/*.gemspec"
411
412
  - "**/*.rake"
412
413
  - "**/*.rb"
413
- - "**/*bin/console"
414
- - "**/*bin/guard"
415
- - "**/*bin/rubocop"
416
- - "**/*Gemfile"
417
- - "**/*Guardfile"
418
- - "**/*Rakefile"
414
+ - "*.gemspec"
415
+ - "exe/*"
416
+ - bin/console
417
+ - bin/guard
418
+ - bin/rubocop
419
+ - config.ru
420
+ - Gemfile
421
+ - Guardfile
422
+ - Rakefile
419
423
  :tocer:
420
424
  :includes:
421
425
  - "README.md"
@@ -472,7 +476,7 @@ these options are explained in greater detail above.
472
476
 
473
477
  ==== Citations
474
478
 
475
- This section allows you to configure your link:https://orcid.org[ORCiD]
479
+ This section allows you to configure your link:https://orcid.org[ORCID]
476
480
  link:https://citation-file-format.github.io[citation] information used by the research community.
477
481
  You should definitely fill this in. Your author information, detailed above, will be used as well.
478
482
 
@@ -499,9 +503,7 @@ Follow the above links to learn more about each extension's gem configuration.
499
503
  ==== GitHub
500
504
 
501
505
  Your GitHub user is the handle you setup when creating your GitHub account. This information is used
502
- for documentation purposes and Circle CI badge association. If you don't define this information,
503
- Rubysmith will automatically fallback to pulling this information from your Git configuration (i.e.
504
- `github.user`). If all else fails, then nothing will be used.
506
+ for template and/or URL construction purposes.
505
507
 
506
508
  ==== License
507
509
 
@@ -514,7 +516,7 @@ license are available:
514
516
 
515
517
  ==== Project
516
518
 
517
- There are two categories within this section: URLs and version. The URLs allow you to link to
519
+ There are two sub-categories within this section: URLs and version. The URLs allow you to link to
518
520
  specific documentation related to your project. You'll definitely want to customize these as makes
519
521
  sense since these URLs are used for documentation, citations, and general project information. You
520
522
  can also use `%project_name%` as a placeholder anywhere in your URL and Rubysmith will ensure your
data/exe/rubysmith CHANGED
@@ -3,5 +3,4 @@
3
3
 
4
4
  require "rubysmith"
5
5
 
6
- Process.setproctitle Rubysmith::Identity::VERSION_LABEL
7
6
  Rubysmith::CLI::Shell.new.call ARGV
@@ -4,8 +4,8 @@ require "refinements/structs"
4
4
 
5
5
  module Rubysmith
6
6
  module Builders
7
- # Builds project skeleton with RuboCop code quality support.
8
- class Rubocop
7
+ # Builds project skeleton with Caliber style support.
8
+ class Caliber
9
9
  using Refinements::Structs
10
10
 
11
11
  def self.call(...) = new(...).call
@@ -16,7 +16,7 @@ module Rubysmith
16
16
  end
17
17
 
18
18
  def call
19
- return configuration unless configuration.build_rubocop
19
+ return configuration unless configuration.build_caliber
20
20
 
21
21
  builder.call(configuration.merge(template_path: "%project_name%/bin/rubocop.erb"))
22
22
  .render
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/strings"
3
4
  require "refinements/structs"
4
5
 
5
6
  module Rubysmith
6
7
  module Builders
7
8
  # Builds project skeleton core structure and minimum file support.
8
9
  class Core
10
+ using Refinements::Strings
9
11
  using Refinements::Structs
10
12
 
11
13
  def self.call(...) = new(...).call
@@ -19,15 +21,20 @@ module Rubysmith
19
21
  builder.call(configuration.merge(template_path: "%project_name%/lib/%project_path%.rb.erb"))
20
22
  .render
21
23
  .replace(" require", "require")
22
- .replace(/ (?=(Zeit|\.tap|\.setup))/, "")
24
+ .replace(/ (?=(Zeit|loader|end))/, "")
23
25
  .replace("\n \n", "\n\n")
26
+ .insert_before("module #{module_name}", "#{indentation}# Main namespace.\n")
27
+ .replace("end\n end", " end\n end")
24
28
 
25
- builder.call(configuration.merge(template_path: "%project_name%/.ruby-version.erb")).render
26
29
  configuration
27
30
  end
28
31
 
29
32
  private
30
33
 
34
+ def indentation = "".indent configuration.project_levels
35
+
36
+ def module_name = configuration.project_class
37
+
31
38
  attr_reader :configuration, :builder
32
39
  end
33
40
  end
@@ -31,8 +31,8 @@ module Rubysmith
31
31
 
32
32
  def body
33
33
  <<~CONTENT
34
- Generated with [#{Identity::LABEL}]("https://www.alchemists.io/projects/rubysmith")
35
- #{Identity::VERSION}.
34
+ Generated with [Rubysmith](https://www.alchemists.io/projects/rubysmith)
35
+ 1.1.1.
36
36
  CONTENT
37
37
  end
38
38
 
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+
5
+ module Rubysmith
6
+ module Builders
7
+ # Builds project skeleton Ruby version file.
8
+ class Version
9
+ using Refinements::Structs
10
+
11
+ def self.call(...) = new(...).call
12
+
13
+ def initialize configuration, builder: Builder
14
+ @configuration = configuration
15
+ @builder = builder
16
+ end
17
+
18
+ def call
19
+ builder.call(configuration.merge(template_path: "%project_name%/.ruby-version.erb"))
20
+ .render
21
+ .append("\n")
22
+ configuration
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :configuration, :builder
28
+ end
29
+ end
30
+ end
@@ -8,6 +8,7 @@ module Rubysmith
8
8
  # Order is important.
9
9
  BUILDERS = [
10
10
  Builders::Core,
11
+ Builders::Version,
11
12
  Builders::Documentation::Readme,
12
13
  Builders::Documentation::Citation,
13
14
  Builders::Documentation::License,
@@ -24,7 +25,7 @@ module Rubysmith
24
25
  Builders::Reek,
25
26
  Builders::RSpec::Context,
26
27
  Builders::RSpec::Helper,
27
- Builders::Rubocop,
28
+ Builders::Caliber,
28
29
  Extensions::Bundler,
29
30
  Extensions::Pragmater,
30
31
  Extensions::Tocer,
@@ -50,6 +50,15 @@ module Rubysmith
50
50
  end
51
51
  end
52
52
 
53
+ def add_caliber
54
+ client.on(
55
+ "--[no-]caliber",
56
+ "Add Caliber gem. #{default __method__}."
57
+ ) do |value|
58
+ configuration.merge! build_caliber: value
59
+ end
60
+ end
61
+
53
62
  def add_console
54
63
  client.on(
55
64
  "--[no-]console",
@@ -230,12 +239,12 @@ module Rubysmith
230
239
  end
231
240
  end
232
241
 
233
- def add_rubocop
242
+ def add_security
234
243
  client.on(
235
- "--[no-]rubocop",
236
- "Add RuboCop gems. #{default __method__}."
244
+ "--[no-]security",
245
+ "Add security. #{default __method__}."
237
246
  ) do |value|
238
- configuration.merge! build_rubocop: value
247
+ configuration.merge! build_security: value
239
248
  end
240
249
  end
241
250
 
@@ -11,13 +11,16 @@ module Rubysmith
11
11
 
12
12
  def self.call(...) = new(...).call
13
13
 
14
- def initialize configuration = Container[:configuration], client: Parser::CLIENT
14
+ def initialize configuration = Container[:configuration],
15
+ client: Parser::CLIENT,
16
+ container: Container
15
17
  @configuration = configuration
16
18
  @client = client
19
+ @container = container
17
20
  end
18
21
 
19
22
  def call arguments = []
20
- client.banner = "#{Identity::LABEL} - #{Identity::SUMMARY}"
23
+ client.banner = specification.labeled_summary
21
24
  client.separator "\nUSAGE:\n"
22
25
  collate
23
26
  client.parse arguments
@@ -26,7 +29,7 @@ module Rubysmith
26
29
 
27
30
  private
28
31
 
29
- attr_reader :configuration, :client
32
+ attr_reader :configuration, :client, :container
30
33
 
31
34
  def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
32
35
 
@@ -62,6 +65,8 @@ module Rubysmith
62
65
  configuration.merge! action_help: true
63
66
  end
64
67
  end
68
+
69
+ def specification = container[__method__]
65
70
  end
66
71
  end
67
72
  end
@@ -33,7 +33,7 @@ module Rubysmith
33
33
  in action_config: Symbol => action then config action
34
34
  in action_build: true then build configuration
35
35
  in action_publish: true then publish configuration
36
- in action_version: true then logger.info Identity::VERSION_LABEL
36
+ in action_version: true then logger.info { specification.labeled_version }
37
37
  else usage
38
38
  end
39
39
  end
@@ -46,6 +46,8 @@ module Rubysmith
46
46
 
47
47
  def usage = logger.unknown(parser.to_s)
48
48
 
49
+ def specification = container[__method__]
50
+
49
51
  def logger = container[__method__]
50
52
  end
51
53
  end
@@ -24,6 +24,7 @@ module Rubysmith
24
24
  :author_url,
25
25
  :build_amazing_print,
26
26
  :build_bundler_leak,
27
+ :build_caliber,
27
28
  :build_circle_ci,
28
29
  :build_citation,
29
30
  :build_cli,
@@ -45,7 +46,6 @@ module Rubysmith
45
46
  :build_reek,
46
47
  :build_refinements,
47
48
  :build_rspec,
48
- :build_rubocop,
49
49
  :build_security,
50
50
  :build_setup,
51
51
  :build_simple_cov,
@@ -111,14 +111,18 @@ module Rubysmith
111
111
 
112
112
  def license_label_version = [license_label, license_version].compress.join("-")
113
113
 
114
- def project_label = project_name.titleize
114
+ def project_class = project_namespaced_class.split("::").last
115
115
 
116
- def project_class = project_name.camelcase
116
+ def project_namespaced_class = project_name.camelcase
117
117
 
118
- def project_root = target_root.join(project_name)
118
+ def project_label = project_name.titleize
119
+
120
+ def project_levels = project_namespaced_class.split("::").size - 1
119
121
 
120
122
  def project_path = project_name.snakecase
121
123
 
124
+ def project_root = target_root.join(project_name)
125
+
122
126
  def computed_project_url_community = format_url(__method__)
123
127
 
124
128
  def computed_project_url_conduct = format_url(__method__)
@@ -6,6 +6,7 @@
6
6
  :build:
7
7
  :amazing_print: true
8
8
  :bundler_leak: true
9
+ :caliber: true
9
10
  :circle_ci: false
10
11
  :citation: true
11
12
  :cli: false
@@ -27,7 +28,6 @@
27
28
  :reek: true
28
29
  :refinements: true
29
30
  :rspec: true
30
- :rubocop: true
31
31
  :security: true
32
32
  :setup: true
33
33
  :simple_cov: true
@@ -55,15 +55,17 @@
55
55
  :comments:
56
56
  - "# frozen_string_literal: true"
57
57
  :includes:
58
- - "**/*.gemspec"
59
58
  - "**/*.rake"
60
59
  - "**/*.rb"
61
- - "**/*bin/console"
62
- - "**/*bin/guard"
63
- - "**/*bin/rubocop"
64
- - "**/*Gemfile"
65
- - "**/*Guardfile"
66
- - "**/*Rakefile"
60
+ - "*.gemspec"
61
+ - "exe/*"
62
+ - bin/console
63
+ - bin/guard
64
+ - bin/rubocop
65
+ - config.ru
66
+ - Gemfile
67
+ - Guardfile
68
+ - Rakefile
67
69
  :tocer:
68
70
  :includes:
69
71
  - "README.md"
@@ -14,7 +14,7 @@ module Rubysmith
14
14
  using Refinements::Structs
15
15
 
16
16
  DEFAULTS = YAML.load_file(Pathname(__dir__).join("defaults.yml")).freeze
17
- CLIENT = Runcom::Config.new "#{Identity::NAME}/configuration.yml", defaults: DEFAULTS
17
+ CLIENT = Runcom::Config.new "rubysmith/configuration.yml", defaults: DEFAULTS
18
18
 
19
19
  ENHANCERS = [
20
20
  Enhancers::CurrentTime.new,
@@ -3,6 +3,7 @@
3
3
  require "dry-container"
4
4
  require "logger"
5
5
  require "pastel"
6
+ require "spek"
6
7
 
7
8
  module Rubysmith
8
9
  # Provides a global gem container for injection into other objects.
@@ -10,6 +11,7 @@ module Rubysmith
10
11
  extend Dry::Container::Mixin
11
12
 
12
13
  register(:configuration) { Configuration::Loader.call }
14
+ register(:specification) { Spek::Loader.call "#{__dir__}/../../rubysmith.gemspec" }
13
15
  register(:colorizer) { Pastel.new enabled: $stdout.tty? }
14
16
  register(:kernel) { Kernel }
15
17
 
@@ -1,16 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "milestoner"
4
+ require "refinements/structs"
4
5
 
5
6
  module Rubysmith
6
7
  module Extensions
7
8
  # Ensures project can be published (tagged) in a reliable and consistent fashion.
8
9
  class Milestoner
10
+ using Refinements::Structs
11
+
9
12
  def self.call(...) = new(...).call
10
13
 
11
14
  def initialize configuration,
12
15
  client: ::Milestoner::Tags::Publisher.new,
13
- content: ::Milestoner::Configuration::Content
16
+ content: ::Milestoner::Configuration::Content.new
14
17
  @configuration = configuration
15
18
  @client = client
16
19
  @content = content
@@ -23,12 +26,11 @@ module Rubysmith
23
26
  attr_reader :configuration, :client, :content
24
27
 
25
28
  def settings
26
- content[
27
- documentation_format: configuration.extensions_milestoner_documentation_format,
28
- prefixes: configuration.extensions_milestoner_prefixes,
29
- sign: configuration.extensions_milestoner_sign,
30
- version: configuration.project_version
31
- ]
29
+ content.transmute configuration,
30
+ documentation_format: :extensions_milestoner_documentation_format,
31
+ prefixes: :extensions_milestoner_prefixes,
32
+ sign: :extensions_milestoner_sign,
33
+ version: :project_version
32
34
  end
33
35
  end
34
36
  end
@@ -1,16 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "pragmater"
4
+ require "refinements/structs"
4
5
 
5
6
  module Rubysmith
6
7
  module Extensions
7
8
  # Ensures project skeleton has pragmas.
8
9
  class Pragmater
10
+ using Refinements::Structs
11
+
9
12
  def self.call(...) = new(...).call
10
13
 
11
14
  def initialize configuration,
12
15
  client: ::Pragmater::Runner.new,
13
- content: ::Pragmater::Configuration::Content
16
+ content: ::Pragmater::Configuration::Content.new
14
17
  @configuration = configuration
15
18
  @client = client
16
19
  @content = content
@@ -23,12 +26,10 @@ module Rubysmith
23
26
  attr_reader :configuration, :client, :content
24
27
 
25
28
  def settings
26
- content[
27
- action_insert: true,
28
- comments: configuration.extensions_pragmater_comments,
29
- includes: configuration.extensions_pragmater_includes,
30
- root_dir: configuration.project_root
31
- ]
29
+ content.merge(action_insert: true, root_dir: configuration.project_root)
30
+ .transmute! configuration,
31
+ comments: :extensions_pragmater_comments,
32
+ includes: :extensions_pragmater_includes
32
33
  end
33
34
  end
34
35
  end
@@ -1,23 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "tocer"
4
+ require "refinements/structs"
4
5
 
5
6
  module Rubysmith
6
7
  module Extensions
7
8
  # Ensures project skeleton documentation has table of contents.
8
9
  class Tocer
10
+ using Refinements::Structs
11
+
9
12
  def self.call(...) = new(...).call
10
13
 
11
14
  def initialize configuration,
12
15
  client: ::Tocer::Runner.new,
13
- content: ::Tocer::Configuration::Content
16
+ content: ::Tocer::Configuration::Content.new
14
17
  @configuration = configuration
15
18
  @client = client
16
19
  @content = content
17
20
  end
18
21
 
19
22
  def call
20
- client.call(settings) if configuration.build_readme
23
+ client.call settings if configuration.build_readme
21
24
  configuration
22
25
  end
23
26
 
@@ -26,11 +29,10 @@ module Rubysmith
26
29
  attr_reader :configuration, :client, :content
27
30
 
28
31
  def settings
29
- content[
30
- includes: configuration.extensions_tocer_includes,
31
- label: configuration.extensions_tocer_label,
32
- root_dir: configuration.project_root
33
- ]
32
+ content.merge(root_dir: configuration.project_root)
33
+ .transmute! configuration,
34
+ includes: :extensions_tocer_includes,
35
+ label: :extensions_tocer_label
34
36
  end
35
37
  end
36
38
  end
@@ -7,7 +7,7 @@ module Rubysmith
7
7
  # Renders ERB templates as fully functional files.
8
8
  class ERB
9
9
  def initialize configuration,
10
- scope: Renderers::Namespace.new(configuration.project_class),
10
+ scope: Renderers::Namespace.new(configuration.project_namespaced_class),
11
11
  client: ::ERB
12
12
  @configuration = configuration
13
13
  @scope = scope
@@ -21,7 +21,15 @@ module Rubysmith
21
21
  attr_accessor :buffer
22
22
  attr_reader :configuration, :scope, :client
23
23
 
24
- def namespace = self.buffer = block_given? ? scope.call(yield) : buffer + scope.call
24
+ def namespace
25
+ source = buffer.dup
26
+
27
+ self.buffer = source + if block_given?
28
+ scope.call yield.sub(source, "")
29
+ else
30
+ scope.call
31
+ end
32
+ end
25
33
  end
26
34
  end
27
35
  end
@@ -8,10 +8,10 @@ module Rubysmith
8
8
  class Namespace
9
9
  using Refinements::Strings
10
10
 
11
- def initialize namespace
11
+ def initialize namespace, delimiter: "::"
12
12
  @namespace = namespace
13
- @modules = namespace.split "::"
14
- @depth = namespace.scan("::").length
13
+ @modules = namespace.split delimiter
14
+ @depth = namespace.scan(delimiter).length
15
15
  end
16
16
 
17
17
  def call(content = nil) = "#{prefix}#{body content}#{suffix}"
@@ -1,7 +1,4 @@
1
1
  .bundle
2
- <% if configuration.build_rubocop %>
3
- .rubocop-http*
4
- <% end %>
5
2
  <% if configuration.build_yard %>
6
3
  .yardoc
7
4
  <% end %>
@@ -1,9 +1,2 @@
1
- inherit_from:
2
- - https://raw.githubusercontent.com/bkuhlmann/code_quality/main/configurations/rubocop/ruby.yml
3
- <% if configuration.build_rake %>
4
- - https://raw.githubusercontent.com/bkuhlmann/code_quality/main/configurations/rubocop/rake.yml
5
- <% end %>
6
- - https://raw.githubusercontent.com/bkuhlmann/code_quality/main/configurations/rubocop/performance.yml
7
- <% if configuration.build_rspec %>
8
- - https://raw.githubusercontent.com/bkuhlmann/code_quality/main/configurations/rubocop/rspec.yml
9
- <% end %>
1
+ inherit_gem:
2
+ caliber: config/all.yml
@@ -3,7 +3,7 @@ ruby File.read(".ruby-version").strip
3
3
  source "https://rubygems.org"
4
4
 
5
5
  <% if configuration.build_refinements %>
6
- gem "refinements", "~> 9.0"
6
+ gem "refinements", "~> 9.2"
7
7
  <% end %>
8
8
  <% if configuration.build_zeitwerk %>
9
9
  gem "zeitwerk", "~> 2.5"
@@ -13,22 +13,17 @@ group :code_quality do
13
13
  <% if configuration.build_bundler_leak %>
14
14
  gem "bundler-leak", "~> 0.2"
15
15
  <% end %>
16
+ <% if configuration.build_caliber %>
17
+ gem "caliber", "~> 0.1"
18
+ <% end %>
16
19
  <% if configuration.build_dead_end %>
17
- gem "dead_end", "~> 3.0"
20
+ gem "dead_end", "~> 3.1"
18
21
  <% end %>
19
22
  <% if configuration.build_git && configuration.build_git_lint %>
20
- gem "git-lint", "~> 3.0"
23
+ gem "git-lint", "~> 3.2"
21
24
  <% end %>
22
25
  <% if configuration.build_reek %>
23
- gem "reek", "~> 6.0"
24
- <% end %>
25
- <% if configuration.build_rubocop %>
26
- gem "rubocop", "~> 1.24"
27
- gem "rubocop-performance", "~> 1.12"
28
- gem "rubocop-rake", "~> 0.6"
29
- <% end %>
30
- <% if configuration.build_rspec && configuration.build_rubocop %>
31
- gem "rubocop-rspec", "~> 2.6"
26
+ gem "reek", "~> 6.1"
32
27
  <% end %>
33
28
  <% if configuration.build_simple_cov %>
34
29
  gem "simplecov", "~> 0.21"
@@ -43,7 +38,7 @@ group :development do
43
38
  gem "rake", "~> 13.0"
44
39
  <% end %>
45
40
  <% if configuration.markdown? %>
46
- gem "tocer", "~> 13.0"
41
+ gem "tocer", "~> 13.2"
47
42
  <% end %>
48
43
  <% if configuration.build_yard %>
49
44
  gem "yard", "~> 0.9"
@@ -55,7 +50,7 @@ group :test do
55
50
  gem "guard-rspec", "~> 4.7", require: false
56
51
  <% end %>
57
52
  <% if configuration.build_rspec %>
58
- gem "rspec", "~> 3.10"
53
+ gem "rspec", "~> 3.11"
59
54
  <% end %>
60
55
  end
61
56
 
@@ -4,15 +4,6 @@
4
4
 
5
5
  = <%= configuration.project_label %>
6
6
 
7
- <% if configuration.build_rubocop %>
8
- [link=https://www.alchemists.io/projects/code_quality]
9
- image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchemists Style Guide]
10
- <% end %>
11
- <% if configuration.build_circle_ci %>
12
- [link=https://circleci.com/gh/<%= configuration.git_hub_user %>/<%= configuration.project_name %>]
13
- image::https://circleci.com/gh/<%= configuration.git_hub_user %>/<%= configuration.project_name %>.svg?style=svg[Circle CI Status]
14
- <% end %>
15
-
16
7
  toc::[]
17
8
 
18
9
  == Features
@@ -1,12 +1,5 @@
1
1
  # <%= configuration.project_label %>
2
2
 
3
- <% if configuration.build_rubocop %>
4
- [![Alchemists Style Guide](https://img.shields.io/badge/code_style-alchemists-brightgreen.svg)](https://www.alchemists.io/projects/code_quality)
5
- <% end %>
6
- <% if configuration.build_circle_ci %>
7
- [![Circle CI Status](https://circleci.com/gh/<%= configuration.git_hub_user %>/<%= configuration.project_name %>.svg?style=svg)](https://circleci.com/gh/<%= configuration.git_hub_user %>/<%= configuration.project_name %>)
8
- <% end %>
9
-
10
3
  <!-- Tocer[start]: Auto-generated, don't remove. -->
11
4
  <!-- Tocer[finish]: Auto-generated, don't remove. -->
12
5
 
@@ -12,7 +12,7 @@ require "bundler/setup"
12
12
  <% if configuration.build_rspec %>
13
13
  require "rspec/core/rake_task"
14
14
  <% end %>
15
- <% if configuration.build_rubocop %>
15
+ <% if configuration.build_caliber %>
16
16
  require "rubocop/rake_task"
17
17
  <% end %>
18
18
  <% if configuration.build_yard %>
@@ -28,7 +28,7 @@ require "bundler/setup"
28
28
  <% if configuration.build_rspec %>
29
29
  RSpec::Core::RakeTask.new :spec
30
30
  <% end %>
31
- <% if configuration.build_rubocop %>
31
+ <% if configuration.build_caliber %>
32
32
  RuboCop::RakeTask.new
33
33
  <% end %>
34
34
 
@@ -39,6 +39,6 @@ require "bundler/setup"
39
39
  <% end %>
40
40
 
41
41
  desc "Run code quality checks"
42
- task code_quality: %i[<% if configuration.build_bundler_leak %>bundle:leak<% end %> <% if configuration.build_git && configuration.build_git_lint %>git_lint<% end %> <% if configuration.build_reek %>reek<% end %> <% if configuration.build_rubocop %>rubocop<% end %>]
42
+ task code_quality: %i[<% if configuration.build_bundler_leak %>bundle:leak<% end %> <% if configuration.build_git && configuration.build_git_lint %>git_lint<% end %> <% if configuration.build_reek %>reek<% end %> <% if configuration.build_caliber %>rubocop<% end %>]
43
43
 
44
44
  task default: %i[code_quality <% if configuration.build_rspec %>spec<% end %>]
@@ -1,12 +1,12 @@
1
1
  <% if configuration.build_zeitwerk %>
2
2
  require "zeitwerk"
3
- <% if configuration.project_path.include? "/" %>
4
- Zeitwerk::Loader.new
5
- .tap { |loader| loader.push_dir "#{__dir__}/.." }
6
- .setup
3
+ <% if configuration.project_levels.positive? %>
4
+ Zeitwerk::Loader.new.then do |loader|
5
+ loader.push_dir "#{__dir__}<%= Array.new(configuration.project_levels, "/..").join %>"
6
+ loader.setup
7
+ end
7
8
  <% else %>
8
9
  Zeitwerk::Loader.for_gem.setup
9
10
  <% end %>
10
11
  <% end %>
11
- # Main namespace.
12
12
  <% namespace %>
data/rubysmith.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "rubysmith"
5
+ spec.version = "2.0.0"
6
+ spec.authors = ["Brooke Kuhlmann"]
7
+ spec.email = ["brooke@alchemists.io"]
8
+ spec.homepage = "https://github.com/bkuhlmann/rubysmith"
9
+ spec.summary = "A command line interface for smithing Ruby projects."
10
+ spec.license = "Hippocratic-3.0"
11
+
12
+ spec.metadata = {
13
+ "bug_tracker_uri" => "https://github.com/bkuhlmann/rubysmith/issues",
14
+ "changelog_uri" => "https://www.alchemists.io/projects/rubysmith/versions",
15
+ "documentation_uri" => "https://www.alchemists.io/projects/rubysmith",
16
+ "label" => "Rubysmith",
17
+ "rubygems_mfa_required" => "true",
18
+ "source_code_uri" => "https://github.com/bkuhlmann/rubysmith"
19
+ }
20
+
21
+ spec.signing_key = Gem.default_key_path
22
+ spec.cert_chain = [Gem.default_cert_path]
23
+
24
+ spec.required_ruby_version = "~> 3.1"
25
+ spec.add_dependency "dry-container", "~> 0.9"
26
+ spec.add_dependency "git_plus", "~> 1.1"
27
+ spec.add_dependency "milestoner", "~> 13.0"
28
+ spec.add_dependency "pastel", "~> 0.8"
29
+ spec.add_dependency "pragmater", "~> 10.0"
30
+ spec.add_dependency "refinements", "~> 9.2"
31
+ spec.add_dependency "rubocop", "~> 1.25"
32
+ spec.add_dependency "runcom", "~> 8.2"
33
+ spec.add_dependency "spek", "~> 0.0"
34
+ spec.add_dependency "tocer", "~> 13.2"
35
+ spec.add_dependency "zeitwerk", "~> 2.5"
36
+
37
+ spec.bindir = "exe"
38
+ spec.executables << "rubysmith"
39
+ spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
40
+ spec.files = Dir.glob ["*.gemspec", "lib/**/*"], File::FNM_DOTMATCH
41
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,7 +28,7 @@ cert_chain:
28
28
  lkHilIrX69jq8wMPpBhlaw2mRmeSL50Wv5u6xVBvOHhXFSP1crXM95vfLhLyRYod
29
29
  W2A=
30
30
  -----END CERTIFICATE-----
31
- date: 2022-01-09 00:00:00.000000000 Z
31
+ date: 2022-02-12 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: dry-container
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '1.0'
53
+ version: '1.1'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '1.0'
60
+ version: '1.1'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: milestoner
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -106,56 +106,70 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '9.0'
109
+ version: '9.2'
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: '9.0'
116
+ version: '9.2'
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: rubocop
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: '1.24'
123
+ version: '1.25'
124
124
  type: :runtime
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: '1.24'
130
+ version: '1.25'
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: runcom
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: '8.0'
137
+ version: '8.2'
138
138
  type: :runtime
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: '8.0'
144
+ version: '8.2'
145
+ - !ruby/object:Gem::Dependency
146
+ name: spek
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '0.0'
152
+ type: :runtime
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: '0.0'
145
159
  - !ruby/object:Gem::Dependency
146
160
  name: tocer
147
161
  requirement: !ruby/object:Gem::Requirement
148
162
  requirements:
149
163
  - - "~>"
150
164
  - !ruby/object:Gem::Version
151
- version: '13.0'
165
+ version: '13.2'
152
166
  type: :runtime
153
167
  prerelease: false
154
168
  version_requirements: !ruby/object:Gem::Requirement
155
169
  requirements:
156
170
  - - "~>"
157
171
  - !ruby/object:Gem::Version
158
- version: '13.0'
172
+ version: '13.2'
159
173
  - !ruby/object:Gem::Dependency
160
174
  name: zeitwerk
161
175
  requirement: !ruby/object:Gem::Requirement
@@ -186,6 +200,7 @@ files:
186
200
  - lib/rubysmith.rb
187
201
  - lib/rubysmith/builder.rb
188
202
  - lib/rubysmith/builders/bundler.rb
203
+ - lib/rubysmith/builders/caliber.rb
189
204
  - lib/rubysmith/builders/circle_ci.rb
190
205
  - lib/rubysmith/builders/console.rb
191
206
  - lib/rubysmith/builders/core.rb
@@ -202,8 +217,8 @@ files:
202
217
  - lib/rubysmith/builders/reek.rb
203
218
  - lib/rubysmith/builders/rspec/context.rb
204
219
  - lib/rubysmith/builders/rspec/helper.rb
205
- - lib/rubysmith/builders/rubocop.rb
206
220
  - lib/rubysmith/builders/setup.rb
221
+ - lib/rubysmith/builders/version.rb
207
222
  - lib/rubysmith/cli/actions/build.rb
208
223
  - lib/rubysmith/cli/actions/config.rb
209
224
  - lib/rubysmith/cli/actions/publish.rb
@@ -224,7 +239,6 @@ files:
224
239
  - lib/rubysmith/extensions/pragmater.rb
225
240
  - lib/rubysmith/extensions/rubocop.rb
226
241
  - lib/rubysmith/extensions/tocer.rb
227
- - lib/rubysmith/identity.rb
228
242
  - lib/rubysmith/pathway.rb
229
243
  - lib/rubysmith/renderers/erb.rb
230
244
  - lib/rubysmith/renderers/namespace.rb
@@ -257,6 +271,7 @@ files:
257
271
  - lib/rubysmith/templates/%project_name%/spec/spec_helper.rb.erb
258
272
  - lib/rubysmith/templates/%project_name%/spec/support/shared_contexts/temp_dir.rb.erb
259
273
  - lib/rubysmith/text/inserter.rb
274
+ - rubysmith.gemspec
260
275
  homepage: https://github.com/bkuhlmann/rubysmith
261
276
  licenses:
262
277
  - Hippocratic-3.0
@@ -264,6 +279,7 @@ metadata:
264
279
  bug_tracker_uri: https://github.com/bkuhlmann/rubysmith/issues
265
280
  changelog_uri: https://www.alchemists.io/projects/rubysmith/versions
266
281
  documentation_uri: https://www.alchemists.io/projects/rubysmith
282
+ label: Rubysmith
267
283
  rubygems_mfa_required: 'true'
268
284
  source_code_uri: https://github.com/bkuhlmann/rubysmith
269
285
  post_install_message:
@@ -281,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
297
  - !ruby/object:Gem::Version
282
298
  version: '0'
283
299
  requirements: []
284
- rubygems_version: 3.3.4
300
+ rubygems_version: 3.3.7
285
301
  signing_key:
286
302
  specification_version: 4
287
303
  summary: A command line interface for smithing Ruby projects.
metadata.gz.sig CHANGED
Binary file
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rubysmith
4
- module Identity
5
- NAME = "rubysmith"
6
- LABEL = "Rubysmith"
7
- VERSION = "1.1.0"
8
- VERSION_LABEL = "#{LABEL} #{VERSION}".freeze
9
- SUMMARY = "A command line interface for smithing Ruby projects."
10
- end
11
- end