rubysmith 0.6.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) 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 +4 -2
  5. data/bin/rubysmith +0 -4
  6. data/lib/rubysmith.rb +4 -2
  7. data/lib/rubysmith/builder.rb +14 -30
  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 +17 -22
  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 +25 -0
  23. data/lib/rubysmith/builders/setup.rb +8 -8
  24. data/lib/rubysmith/cli/configuration/content.rb +69 -0
  25. data/lib/rubysmith/cli/{defaults.yml → configuration/defaults.yml} +1 -0
  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 +11 -7
  30. data/lib/rubysmith/cli/parsers/core.rb +5 -9
  31. data/lib/rubysmith/cli/processors/build.rb +10 -8
  32. data/lib/rubysmith/cli/processors/config.rb +3 -7
  33. data/lib/rubysmith/cli/shell.rb +12 -18
  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%/.rubycritic.yml.erb +3 -0
  40. data/lib/rubysmith/templates/%project_name%/CHANGES.adoc.erb +1 -1
  41. data/lib/rubysmith/templates/%project_name%/CHANGES.md.erb +1 -1
  42. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.adoc.erb +2 -2
  43. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.md.erb +1 -1
  44. data/lib/rubysmith/templates/%project_name%/Gemfile.erb +21 -16
  45. data/lib/rubysmith/templates/%project_name%/LICENSE-apache.adoc.erb +1 -1
  46. data/lib/rubysmith/templates/%project_name%/LICENSE-apache.md.erb +1 -1
  47. data/lib/rubysmith/templates/%project_name%/LICENSE-mit.adoc.erb +1 -1
  48. data/lib/rubysmith/templates/%project_name%/LICENSE-mit.md.erb +1 -1
  49. data/lib/rubysmith/templates/%project_name%/README.adoc.erb +5 -5
  50. data/lib/rubysmith/templates/%project_name%/README.md.erb +5 -5
  51. data/lib/rubysmith/templates/%project_name%/Rakefile.erb +19 -13
  52. data/lib/rubysmith/templates/%project_name%/bin/console.erb +1 -1
  53. data/lib/rubysmith/templates/%project_name%/bin/guard.erb +0 -1
  54. data/lib/rubysmith/templates/%project_name%/bin/rubocop.erb +0 -1
  55. data/lib/rubysmith/templates/%project_name%/lib/%project_name%.rb.erb +3 -0
  56. data/lib/rubysmith/templates/%project_name%/spec/spec_helper.rb.erb +8 -3
  57. data/lib/rubysmith/templates/%project_name%/spec/support/shared_contexts/temp_dir.rb.erb +4 -4
  58. metadata +28 -25
  59. metadata.gz.sig +0 -0
  60. data/lib/rubysmith/cli/configuration.rb +0 -29
  61. data/lib/rubysmith/realm.rb +0 -73
@@ -6,24 +6,22 @@ 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 = []
19
17
  client.separator "\nBUILD OPTIONS:\n"
20
- private_methods.grep(/add_/).each { |method| __send__ method }
18
+ private_methods.sort.grep(/add_/).each { |method| __send__ method }
21
19
  arguments.empty? ? arguments : client.parse!(arguments)
22
20
  end
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|
@@ -109,6 +107,12 @@ module Rubysmith
109
107
  end
110
108
  end
111
109
 
110
+ def add_ruby_critic
111
+ client.on "--[no-]ruby_critic", "Add RubyCritic." do |value|
112
+ options[:build_ruby_critic] = value
113
+ end
114
+ end
115
+
112
116
  def add_setup
113
117
  client.on "--[no-]setup", "Add setup script." do |value|
114
118
  options[:build_setup] = 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.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,
@@ -29,6 +33,7 @@ module Rubysmith
29
33
  Builders::Pragma,
30
34
  Builders::Rubocop::Setup,
31
35
  Builders::Rubocop::Formatter,
36
+ Builders::RubyCritic,
32
37
  Builders::Git::Commit
33
38
  ].freeze
34
39
 
@@ -36,21 +41,18 @@ module Rubysmith
36
41
  new builders: MINIMUM
37
42
  end
38
43
 
39
- def initialize builders: MAXIMUM
44
+ def initialize configuration: Configuration::Loader.call, builders: MAXIMUM
45
+ @configuration = configuration
40
46
  @builders = builders
41
47
  end
42
48
 
43
- def call options
44
- Realm[**options].then { |realm| process realm }
45
- end
49
+ def call(options) = configuration.merge(**options).then { |config| process config }
46
50
 
47
51
  private
48
52
 
49
- attr_reader :builders
53
+ attr_reader :configuration, :builders
50
54
 
51
- def process realm
52
- builders.each { |builder| builder.call realm }
53
- end
55
+ def process(config) = builders.each { |builder| builder.call config }
54
56
  end
55
57
  end
56
58
  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,18 @@ 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
30
+ in help: then usage
32
31
  else usage
33
32
  end
34
33
  end
35
34
 
36
35
  private
37
36
 
38
- attr_reader :parser, :processors, :exceptions
37
+ attr_reader :parser, :processors
39
38
 
40
39
  def parse arguments = []
41
40
  parser.call arguments
@@ -43,21 +42,16 @@ module Rubysmith
43
42
  puts error.message
44
43
  end
45
44
 
46
- def process_config action
47
- processors.fetch(:config).call action
48
- end
45
+ def process_config(action) = processors.fetch(:config).call(action)
49
46
 
50
47
  def process_build kind, settings
51
- processors.fetch(kind).call settings.rekey(build: :project_name).merge(now: Time.now)
48
+ processors.fetch(kind).call settings.transform_keys(build: :project_name)
49
+ .merge(now: Time.now)
52
50
  end
53
51
 
54
- def options
55
- parser.to_h
56
- end
52
+ def options = parser.to_h
57
53
 
58
- def usage
59
- puts parser.to_s
60
- end
54
+ def usage = puts(parser.to_s)
61
55
  end
62
56
  end
63
57
  end
@@ -4,7 +4,7 @@ module Rubysmith
4
4
  module Identity
5
5
  NAME = "rubysmith"
6
6
  LABEL = "Rubysmith"
7
- VERSION = "0.6.1"
7
+ VERSION = "0.10.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 %>
@@ -0,0 +1,3 @@
1
+ paths:
2
+ - "lib"
3
+ no_browser: true
@@ -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,32 +1,37 @@
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
- gem "refinements", "~> 7.16"
5
+ <% unless configuration.build_minimum %>
6
+ <% if configuration.build_refinements %>
7
+ gem "refinements", "~> 8.0"
6
8
  <% end %>
7
9
 
8
10
  group :code_quality do
9
- <% if realm.build_bundler_audit %>
11
+ <% if configuration.build_bundler_audit %>
10
12
  gem "bundler-audit", "~> 0.7"
11
13
  <% end %>
12
- <% if realm.build_bundler_leak %>
14
+ <% if configuration.build_bundler_leak %>
13
15
  gem "bundler-leak", "~> 0.2"
14
16
  <% end %>
15
- <% if realm.build_git && realm.build_git_lint %>
16
- gem "git-lint", "~> 1.3"
17
+ <% if configuration.build_git && configuration.build_git_lint %>
18
+ gem "git-lint", "~> 2.0"
17
19
  <% end %>
18
- <% if realm.build_reek %>
20
+ <% if configuration.build_reek %>
19
21
  gem "reek", "~> 6.0"
20
22
  <% end %>
21
- <% if realm.build_rubocop %>
22
- gem "rubocop", "~> 1.5"
23
+ <% if configuration.build_rubocop %>
24
+ gem "rubocop", "~> 1.10"
23
25
  gem "rubocop-performance", "~> 1.9"
24
26
  gem "rubocop-rake", "~> 0.5"
25
27
  <% end %>
26
- <% if realm.build_rspec && realm.build_rubocop %>
28
+ <% if configuration.build_rspec && configuration.build_rubocop %>
27
29
  gem "rubocop-rspec", "~> 2.0"
28
30
  <% end %>
29
- <% if realm.build_simple_cov %>
31
+ <% if configuration.build_ruby_critic %>
32
+ gem "rubycritic", "~> 4.5", require: false
33
+ <% end %>
34
+ <% if configuration.build_simple_cov %>
30
35
  gem "simplecov", "~> 0.20"
31
36
  <% end %>
32
37
  end
@@ -36,19 +41,19 @@ source "https://rubygems.org"
36
41
  end
37
42
 
38
43
  group :test do
39
- <% if realm.build_guard %>
44
+ <% if configuration.build_guard %>
40
45
  gem "guard-rspec", "~> 4.7", require: false
41
46
  <% end %>
42
- <% if realm.build_rspec %>
47
+ <% if configuration.build_rspec %>
43
48
  gem "rspec", "~> 3.10"
44
49
  <% end %>
45
50
  end
46
51
 
47
52
  group :tools do
48
- <% if realm.build_amazing_print %>
53
+ <% if configuration.build_amazing_print %>
49
54
  gem "amazing_print", "~> 1.2"
50
55
  <% end %>
51
- <% if realm.build_pry %>
56
+ <% if configuration.build_pry %>
52
57
  gem "pry", "~> 0.13"
53
58
  gem "pry-byebug", "~> 3.9"
54
59
  <% 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