rubysmith 0.8.0 → 0.11.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 (58) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.adoc +2 -5
  5. data/bin/rubysmith +0 -4
  6. data/lib/rubysmith.rb +3 -2
  7. data/lib/rubysmith/builder.rb +12 -27
  8. data/lib/rubysmith/builders/bundler.rb +11 -9
  9. data/lib/rubysmith/builders/console.rb +6 -8
  10. data/lib/rubysmith/builders/core.rb +7 -8
  11. data/lib/rubysmith/builders/documentation.rb +16 -21
  12. data/lib/rubysmith/builders/git/commit.rb +7 -11
  13. data/lib/rubysmith/builders/git/setup.rb +6 -8
  14. data/lib/rubysmith/builders/guard.rb +9 -9
  15. data/lib/rubysmith/builders/pragma.rb +9 -14
  16. data/lib/rubysmith/builders/rake.rb +5 -7
  17. data/lib/rubysmith/builders/reek.rb +6 -8
  18. data/lib/rubysmith/builders/rspec/context.rb +10 -11
  19. data/lib/rubysmith/builders/rspec/helper.rb +6 -8
  20. data/lib/rubysmith/builders/rubocop/formatter.rb +5 -7
  21. data/lib/rubysmith/builders/rubocop/setup.rb +7 -9
  22. data/lib/rubysmith/builders/ruby_critic.rb +6 -8
  23. data/lib/rubysmith/builders/setup.rb +8 -8
  24. data/lib/rubysmith/cli/configuration/content.rb +68 -0
  25. data/lib/rubysmith/cli/{defaults.yml → configuration/defaults.yml} +0 -1
  26. data/lib/rubysmith/cli/configuration/loader.rb +35 -0
  27. data/lib/rubysmith/cli/parsers.rb +11 -0
  28. data/lib/rubysmith/cli/parsers/assembler.rb +10 -15
  29. data/lib/rubysmith/cli/parsers/build.rb +4 -12
  30. data/lib/rubysmith/cli/parsers/core.rb +5 -9
  31. data/lib/rubysmith/cli/processors/build.rb +10 -11
  32. data/lib/rubysmith/cli/processors/config.rb +3 -7
  33. data/lib/rubysmith/cli/shell.rb +9 -17
  34. data/lib/rubysmith/identity.rb +1 -1
  35. data/lib/rubysmith/pathway.rb +3 -9
  36. data/lib/rubysmith/renderers/erb.rb +7 -9
  37. data/lib/rubysmith/renderers/namespace.rb +1 -3
  38. data/lib/rubysmith/templates/%project_name%/.rubocop.yml.erb +5 -5
  39. data/lib/rubysmith/templates/%project_name%/CHANGES.adoc.erb +1 -1
  40. data/lib/rubysmith/templates/%project_name%/CHANGES.md.erb +1 -1
  41. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.adoc.erb +2 -2
  42. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.md.erb +1 -1
  43. data/lib/rubysmith/templates/%project_name%/Gemfile.erb +16 -17
  44. data/lib/rubysmith/templates/%project_name%/LICENSE-apache.adoc.erb +1 -1
  45. data/lib/rubysmith/templates/%project_name%/LICENSE-apache.md.erb +1 -1
  46. data/lib/rubysmith/templates/%project_name%/LICENSE-mit.adoc.erb +1 -1
  47. data/lib/rubysmith/templates/%project_name%/LICENSE-mit.md.erb +1 -1
  48. data/lib/rubysmith/templates/%project_name%/README.adoc.erb +5 -5
  49. data/lib/rubysmith/templates/%project_name%/README.md.erb +5 -5
  50. data/lib/rubysmith/templates/%project_name%/Rakefile.erb +13 -19
  51. data/lib/rubysmith/templates/%project_name%/bin/console.erb +1 -1
  52. data/lib/rubysmith/templates/%project_name%/lib/%project_name%.rb.erb +1 -1
  53. data/lib/rubysmith/templates/%project_name%/spec/spec_helper.rb.erb +8 -3
  54. data/lib/rubysmith/templates/%project_name%/spec/support/shared_contexts/temp_dir.rb.erb +4 -4
  55. metadata +19 -18
  56. metadata.gz.sig +0 -0
  57. data/lib/rubysmith/cli/configuration.rb +0 -30
  58. data/lib/rubysmith/realm.rb +0 -74
@@ -6,13 +6,11 @@ module Rubysmith
6
6
  # Handles parsing of Command Line Interface (CLI) build options.
7
7
  # :reek:TooManyMethods
8
8
  class Build
9
- def self.call client:, options:
10
- new(client: client, options: options).call
11
- end
9
+ def self.call(options: {}, client: CLIENT) = new(options: options, client: client).call
12
10
 
13
- def initialize client: CLIENT, options: {}
14
- @client = client
11
+ def initialize options: {}, client: CLIENT
15
12
  @options = options
13
+ @client = client
16
14
  end
17
15
 
18
16
  def call arguments = []
@@ -23,7 +21,7 @@ module Rubysmith
23
21
 
24
22
  private
25
23
 
26
- attr_reader :client, :options
24
+ attr_reader :options, :client
27
25
 
28
26
  def add_minimum
29
27
  client.on "--min", "Use minimum/no options." do |value|
@@ -37,12 +35,6 @@ module Rubysmith
37
35
  end
38
36
  end
39
37
 
40
- def add_bundler_audit
41
- client.on "--[no-]bundler-audit", "Add Bundler Audit." do |value|
42
- options[:build_bundler_audit] = value
43
- end
44
- end
45
-
46
38
  def add_bundler_leak
47
39
  client.on "--[no-]bundler-leak", "Add Bundler Leak." do |value|
48
40
  options[:build_bundler_leak] = value
@@ -7,13 +7,11 @@ module Rubysmith
7
7
  module Parsers
8
8
  # Handles parsing of Command Line Interface (CLI) core options.
9
9
  class Core
10
- def self.call client:, options:
11
- new(client: client, options: options).call
12
- end
10
+ def self.call(options: {}, client: CLIENT) = new(options: options, client: client).call
13
11
 
14
- def initialize client: CLIENT, options: {}
15
- @client = client
12
+ def initialize options: {}, client: CLIENT
16
13
  @options = options
14
+ @client = client
17
15
  end
18
16
 
19
17
  def call arguments = []
@@ -25,11 +23,9 @@ module Rubysmith
25
23
 
26
24
  private
27
25
 
28
- attr_reader :client, :options
26
+ attr_reader :options, :client
29
27
 
30
- def collate
31
- private_methods.sort.grep(/add_/).each { |method| __send__ method }
32
- end
28
+ def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
33
29
 
34
30
  def add_config
35
31
  client.on "-c",
@@ -1,10 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+
3
5
  module Rubysmith
4
6
  module CLI
5
7
  module Processors
6
8
  # Handles the Command Line Interface (CLI) for building of a project skeleton.
7
9
  class Build
10
+ using Refinements::Structs
11
+
8
12
  # Order is important.
9
13
  MINIMUM = [
10
14
  Builders::Core,
@@ -33,25 +37,20 @@ module Rubysmith
33
37
  Builders::Git::Commit
34
38
  ].freeze
35
39
 
36
- def self.with_minimum
37
- new builders: MINIMUM
38
- end
40
+ def self.with_minimum = new(builders: MINIMUM)
39
41
 
40
- def initialize builders: MAXIMUM
42
+ def initialize configuration: Configuration::Loader.call, builders: MAXIMUM
43
+ @configuration = configuration
41
44
  @builders = builders
42
45
  end
43
46
 
44
- def call options
45
- Realm[**options].then { |realm| process realm }
46
- end
47
+ def call(options) = configuration.merge(**options).then { |config| process config }
47
48
 
48
49
  private
49
50
 
50
- attr_reader :builders
51
+ attr_reader :configuration, :builders
51
52
 
52
- def process realm
53
- builders.each { |builder| builder.call realm }
54
- end
53
+ def process(config) = builders.each { |builder| builder.call config }
55
54
  end
56
55
  end
57
56
  end
@@ -5,7 +5,7 @@ module Rubysmith
5
5
  module Processors
6
6
  # Handles the Command Line Interface (CLI) configuration processing.
7
7
  class Config
8
- def initialize configuration: CLI::Configuration::CLIENT, kernel: Kernel
8
+ def initialize configuration: CLI::Configuration::Loader::CLIENT, kernel: Kernel
9
9
  @configuration = configuration
10
10
  @kernel = kernel
11
11
  end
@@ -22,13 +22,9 @@ module Rubysmith
22
22
 
23
23
  attr_reader :configuration, :kernel
24
24
 
25
- def edit
26
- kernel.system "$EDITOR #{configuration.current}"
27
- end
25
+ def edit = kernel.system("$EDITOR #{configuration.current}")
28
26
 
29
- def view
30
- kernel.system "cat #{configuration.current}"
31
- end
27
+ def view = kernel.system("cat #{configuration.current}")
32
28
  end
33
29
  end
34
30
  end
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "optparse"
4
3
  require "refinements/hashes"
5
4
 
6
5
  module Rubysmith
7
6
  module CLI
8
- # Represents the Command Line Interface (CLI) for this gem.
7
+ # The main Command Line Interface (CLI) object.
9
8
  class Shell
10
9
  using Refinements::Hashes
11
10
 
@@ -24,18 +23,17 @@ module Rubysmith
24
23
  parse arguments
25
24
 
26
25
  case options
27
- in config: action, **remainder then process_config action
28
- in build_minimum: true, **remainder then process_build :build_minimum, options
29
- in build:, **remainder then process_build :build_maximum, options
30
- in version:, **remainder then puts version
31
- in help:, **remainder then usage
26
+ in config: Symbol => action then process_config action
27
+ in build_minimum: true then process_build :build_minimum, options
28
+ in build: then process_build :build_maximum, options
29
+ in version: String => version then puts version
32
30
  else usage
33
31
  end
34
32
  end
35
33
 
36
34
  private
37
35
 
38
- attr_reader :parser, :processors, :exceptions
36
+ attr_reader :parser, :processors
39
37
 
40
38
  def parse arguments = []
41
39
  parser.call arguments
@@ -43,22 +41,16 @@ module Rubysmith
43
41
  puts error.message
44
42
  end
45
43
 
46
- def process_config action
47
- processors.fetch(:config).call action
48
- end
44
+ def process_config(action) = processors.fetch(:config).call(action)
49
45
 
50
46
  def process_build kind, settings
51
47
  processors.fetch(kind).call settings.transform_keys(build: :project_name)
52
48
  .merge(now: Time.now)
53
49
  end
54
50
 
55
- def options
56
- parser.to_h
57
- end
51
+ def options = parser.to_h
58
52
 
59
- def usage
60
- puts parser.to_s
61
- end
53
+ def usage = puts(parser.to_s)
62
54
  end
63
55
  end
64
56
  end
@@ -4,7 +4,7 @@ module Rubysmith
4
4
  module Identity
5
5
  NAME = "rubysmith"
6
6
  LABEL = "Rubysmith"
7
- VERSION = "0.8.0"
7
+ VERSION = "0.11.0"
8
8
  VERSION_LABEL = "#{LABEL} #{VERSION}"
9
9
  SUMMARY = "A command line interface for smithing Ruby projects."
10
10
  end
@@ -14,17 +14,11 @@ module Rubysmith
14
14
  freeze
15
15
  end
16
16
 
17
- def with attributes
18
- self.class.new to_h.merge(attributes)
19
- end
17
+ def with(attributes) = self.class.new(to_h.merge(attributes))
20
18
 
21
- def end_path
22
- end_root.join from_parent, start_path.basename
23
- end
19
+ def end_path = end_root.join(from_parent, start_path.basename)
24
20
 
25
- def partial?
26
- start_path.basename.fnmatch? "_*"
27
- end
21
+ def partial? = start_path.basename.fnmatch?("_*")
28
22
 
29
23
  private
30
24
 
@@ -6,24 +6,22 @@ module Rubysmith
6
6
  module Renderers
7
7
  # Renders ERB templates as fully functional files.
8
8
  class ERB
9
- def initialize realm, scope: Renderers::Namespace.new(realm.project_class), client: ::ERB
10
- @realm = realm
9
+ def initialize configuration,
10
+ scope: Renderers::Namespace.new(configuration.project_class),
11
+ client: ::ERB
12
+ @configuration = configuration
11
13
  @scope = scope
12
14
  @client = client
13
15
  end
14
16
 
15
- def call content
16
- client.new(content, trim_mode: "<>", eoutvar: "@buffer").result binding
17
- end
17
+ def call(content) = client.new(content, trim_mode: "<>", eoutvar: "@buffer").result(binding)
18
18
 
19
19
  private
20
20
 
21
21
  attr_accessor :buffer
22
- attr_reader :realm, :scope, :client
22
+ attr_reader :configuration, :scope, :client
23
23
 
24
- def namespace
25
- self.buffer = scope.call yield
26
- end
24
+ def namespace = self.buffer = scope.call(yield)
27
25
  end
28
26
  end
29
27
  end
@@ -14,9 +14,7 @@ module Rubysmith
14
14
  @depth = namespace.scan("::").length
15
15
  end
16
16
 
17
- def call content
18
- "#{prefix}#{body content}#{suffix.chomp}"
19
- end
17
+ def call(content) = "#{prefix}#{body content}#{suffix.chomp}"
20
18
 
21
19
  private
22
20
 
@@ -1,7 +1,7 @@
1
1
  inherit_from:
2
- - https://raw.githubusercontent.com/bkuhlmann/code_quality/master/configurations/rubocop/ruby.yml
3
- - https://raw.githubusercontent.com/bkuhlmann/code_quality/master/configurations/rubocop/rake.yml
4
- - https://raw.githubusercontent.com/bkuhlmann/code_quality/master/configurations/rubocop/performance.yml
5
- <% if realm.build_rspec %>
6
- - https://raw.githubusercontent.com/bkuhlmann/code_quality/master/configurations/rubocop/rspec.yml
2
+ - https://raw.githubusercontent.com/bkuhlmann/code_quality/main/configurations/rubocop/ruby.yml
3
+ - https://raw.githubusercontent.com/bkuhlmann/code_quality/main/configurations/rubocop/rake.yml
4
+ - https://raw.githubusercontent.com/bkuhlmann/code_quality/main/configurations/rubocop/performance.yml
5
+ <% if configuration.build_rspec %>
6
+ - https://raw.githubusercontent.com/bkuhlmann/code_quality/main/configurations/rubocop/rspec.yml
7
7
  <% end %>
@@ -1,5 +1,5 @@
1
1
  = Changes
2
2
 
3
- == 0.1.0 (<%= realm.now.strftime "%Y-%m-%d" %>)
3
+ == 0.1.0 (<%= configuration.now.strftime "%Y-%m-%d" %>)
4
4
 
5
5
  * Added initial implementation.
@@ -1,5 +1,5 @@
1
1
  # Changes
2
2
 
3
- ## 0.1.0 (<%= realm.now.strftime "%Y-%m-%d" %>)
3
+ ## 0.1.0 (<%= configuration.now.strftime "%Y-%m-%d" %>)
4
4
 
5
5
  - Added initial implementation.
@@ -51,8 +51,8 @@ an appointed representative at an online or offline event.
51
51
  == Enforcement
52
52
 
53
53
  Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community
54
- leaders responsible for enforcement at link:mailto:<%= realm.author_email %>?subject=Conduct[<%=
55
- realm.author_name %>].
54
+ leaders responsible for enforcement at link:mailto:<%= configuration.author_email %>?subject=Conduct[<%=
55
+ configuration.author_name %>].
56
56
 
57
57
  All complaints will be reviewed and investigated promptly and fairly.
58
58
 
@@ -51,7 +51,7 @@ an appointed representative at an online or offline event.
51
51
  ## Enforcement
52
52
 
53
53
  Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community
54
- leaders responsible for enforcement at [<%= realm.author_name %>](mailto:<%= realm.author_email
54
+ leaders responsible for enforcement at [<%= configuration.author_name %>](mailto:<%= configuration.author_email
55
55
  %>?subject=Conduct).
56
56
  All complaints will be reviewed and investigated promptly and fairly.
57
57
 
@@ -1,35 +1,34 @@
1
+ ruby File.read(".ruby-version").strip
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
- <% unless realm.build_minimum %>
4
- <% if realm.build_refinements %>
5
+ <% unless configuration.build_minimum %>
6
+ <% if configuration.build_refinements %>
5
7
  gem "refinements", "~> 8.0"
6
8
  <% end %>
7
9
 
8
10
  group :code_quality do
9
- <% if realm.build_bundler_audit %>
10
- gem "bundler-audit", "~> 0.7"
11
- <% end %>
12
- <% if realm.build_bundler_leak %>
11
+ <% if configuration.build_bundler_leak %>
13
12
  gem "bundler-leak", "~> 0.2"
14
13
  <% end %>
15
- <% if realm.build_git && realm.build_git_lint %>
14
+ <% if configuration.build_git && configuration.build_git_lint %>
16
15
  gem "git-lint", "~> 2.0"
17
16
  <% end %>
18
- <% if realm.build_reek %>
17
+ <% if configuration.build_reek %>
19
18
  gem "reek", "~> 6.0"
20
19
  <% end %>
21
- <% if realm.build_rubocop %>
22
- gem "rubocop", "~> 1.5"
20
+ <% if configuration.build_rubocop %>
21
+ gem "rubocop", "~> 1.14"
23
22
  gem "rubocop-performance", "~> 1.9"
24
23
  gem "rubocop-rake", "~> 0.5"
25
24
  <% end %>
26
- <% if realm.build_rspec && realm.build_rubocop %>
25
+ <% if configuration.build_rspec && configuration.build_rubocop %>
27
26
  gem "rubocop-rspec", "~> 2.0"
28
27
  <% end %>
29
- <% if realm.build_ruby_critic %>
28
+ <% if configuration.build_ruby_critic %>
30
29
  gem "rubycritic", "~> 4.5", require: false
31
30
  <% end %>
32
- <% if realm.build_simple_cov %>
31
+ <% if configuration.build_simple_cov %>
33
32
  gem "simplecov", "~> 0.20"
34
33
  <% end %>
35
34
  end
@@ -39,19 +38,19 @@ source "https://rubygems.org"
39
38
  end
40
39
 
41
40
  group :test do
42
- <% if realm.build_guard %>
41
+ <% if configuration.build_guard %>
43
42
  gem "guard-rspec", "~> 4.7", require: false
44
43
  <% end %>
45
- <% if realm.build_rspec %>
44
+ <% if configuration.build_rspec %>
46
45
  gem "rspec", "~> 3.10"
47
46
  <% end %>
48
47
  end
49
48
 
50
49
  group :tools do
51
- <% if realm.build_amazing_print %>
50
+ <% if configuration.build_amazing_print %>
52
51
  gem "amazing_print", "~> 1.2"
53
52
  <% end %>
54
- <% if realm.build_pry %>
53
+ <% if configuration.build_pry %>
55
54
  gem "pry", "~> 0.13"
56
55
  gem "pry-byebug", "~> 3.9"
57
56
  <% end %>
@@ -150,7 +150,7 @@ additional liability.
150
150
 
151
151
  END OF TERMS AND CONDITIONS
152
152
 
153
- Copyright <%= realm.now.strftime "%Y" %> link:<%= realm.author_url %>[<%= realm.author_name %>].
153
+ Copyright <%= configuration.now.strftime "%Y" %> link:<%= configuration.author_url %>[<%= configuration.author_name %>].
154
154
 
155
155
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
156
156
  compliance with the License. You may obtain a link:https://www.apache.org/licenses/LICENSE-2.0[copy]
@@ -150,7 +150,7 @@ additional liability.
150
150
 
151
151
  END OF TERMS AND CONDITIONS
152
152
 
153
- Copyright <%= realm.now.strftime "%Y" %> [<%= realm.author_name %>](<%= realm.author_url %>).
153
+ Copyright <%= configuration.now.strftime "%Y" %> [<%= configuration.author_name %>](<%= configuration.author_url %>).
154
154
 
155
155
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
156
156
  compliance with the License. You may obtain a [copy](https://www.apache.org/licenses/LICENSE-2.0) of
@@ -1,4 +1,4 @@
1
- Copyright <%= realm.now.strftime "%Y" %> link:<%= realm.author_url %>[<%= realm.author_name %>].
1
+ Copyright <%= configuration.now.strftime "%Y" %> link:<%= configuration.author_url %>[<%= configuration.author_name %>].
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- Copyright <%= realm.now.strftime "%Y" %> [<%= realm.author_name %>](<%= realm.author_url %>).
1
+ Copyright <%= configuration.now.strftime "%Y" %> [<%= configuration.author_name %>](<%= configuration.author_url %>).
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -2,9 +2,9 @@
2
2
  :toclevels: 5
3
3
  :figure-caption!:
4
4
 
5
- = <%= realm.project_label %>
5
+ = <%= configuration.project_label %>
6
6
 
7
- <% if realm.build_rubocop %>
7
+ <% if configuration.build_rubocop %>
8
8
  [link=https://www.alchemists.io/projects/code_quality]
9
9
  image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchemists Style Guide]
10
10
  <% end %>
@@ -20,7 +20,7 @@ toc::[]
20
20
  . link:https://www.ruby-lang.org[Ruby].
21
21
 
22
22
  == Setup
23
- <% if realm.build_setup %>
23
+ <% if configuration.build_setup %>
24
24
 
25
25
  To set up the project, run:
26
26
 
@@ -33,7 +33,7 @@ bin/setup
33
33
  == Usage
34
34
 
35
35
  == Development
36
- <% if realm.build_console %>
36
+ <% if configuration.build_console %>
37
37
 
38
38
  You can also use the IRB console for direct access to all objects:
39
39
 
@@ -80,4 +80,4 @@ Built with link:https://www.alchemists.io/projects/rubysmith[Rubysmith].
80
80
 
81
81
  == Credits
82
82
 
83
- Engineered by link:<%= realm.author_url %>[<%= realm.author_name %>].
83
+ Engineered by link:<%= configuration.author_url %>[<%= configuration.author_name %>].