rubysmith 0.9.1 → 0.13.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +34 -20
- data/bin/rubysmith +0 -1
- data/lib/rubysmith/builder.rb +17 -35
- data/lib/rubysmith/builders/bundler.rb +7 -9
- data/lib/rubysmith/builders/console.rb +6 -8
- data/lib/rubysmith/builders/core.rb +11 -8
- data/lib/rubysmith/builders/documentation.rb +16 -21
- data/lib/rubysmith/builders/git/commit.rb +7 -11
- data/lib/rubysmith/builders/git/setup.rb +6 -8
- data/lib/rubysmith/builders/guard.rb +9 -9
- data/lib/rubysmith/builders/pragma.rb +8 -13
- data/lib/rubysmith/builders/rake.rb +7 -7
- data/lib/rubysmith/builders/reek.rb +6 -8
- data/lib/rubysmith/builders/rspec/context.rb +10 -11
- data/lib/rubysmith/builders/rspec/helper.rb +6 -8
- data/lib/rubysmith/builders/rubocop/formatter.rb +5 -7
- data/lib/rubysmith/builders/rubocop/setup.rb +7 -9
- data/lib/rubysmith/builders/setup.rb +8 -8
- data/lib/rubysmith/cli/actions/build.rb +42 -0
- data/lib/rubysmith/cli/actions/config.rb +33 -0
- data/lib/rubysmith/cli/configuration/content.rb +78 -0
- data/lib/rubysmith/cli/{defaults.yml → configuration/defaults.yml} +3 -3
- data/lib/rubysmith/cli/configuration/loader.rb +38 -0
- data/lib/rubysmith/cli/parsers/assembler.rb +11 -18
- data/lib/rubysmith/cli/parsers/build.rb +40 -41
- data/lib/rubysmith/cli/parsers/core.rb +15 -14
- data/lib/rubysmith/cli/parsers.rb +11 -0
- data/lib/rubysmith/cli/shell.rb +14 -35
- data/lib/rubysmith/container.rb +37 -0
- data/lib/rubysmith/identity.rb +2 -2
- data/lib/rubysmith/pathway.rb +3 -9
- data/lib/rubysmith/renderers/erb.rb +7 -9
- data/lib/rubysmith/renderers/namespace.rb +2 -4
- data/lib/rubysmith/templates/%project_name%/.rubocop.yml.erb +1 -1
- data/lib/rubysmith/templates/%project_name%/CHANGES.adoc.erb +1 -1
- data/lib/rubysmith/templates/%project_name%/CHANGES.md.erb +1 -1
- data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.adoc.erb +2 -2
- data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.md.erb +1 -1
- data/lib/rubysmith/templates/%project_name%/Gemfile.erb +46 -50
- data/lib/rubysmith/templates/%project_name%/LICENSE-apache.adoc.erb +1 -1
- data/lib/rubysmith/templates/%project_name%/LICENSE-apache.md.erb +1 -1
- data/lib/rubysmith/templates/%project_name%/LICENSE-mit.adoc.erb +1 -1
- data/lib/rubysmith/templates/%project_name%/LICENSE-mit.md.erb +1 -1
- data/lib/rubysmith/templates/%project_name%/README.adoc.erb +5 -5
- data/lib/rubysmith/templates/%project_name%/README.md.erb +5 -5
- data/lib/rubysmith/templates/%project_name%/Rakefile.erb +11 -23
- data/lib/rubysmith/templates/%project_name%/bin/console.erb +1 -1
- data/lib/rubysmith/templates/%project_name%/lib/%project_path%.rb.erb +12 -0
- data/lib/rubysmith/templates/%project_name%/spec/spec_helper.rb.erb +6 -4
- data/lib/rubysmith/templates/%project_name%/spec/support/shared_contexts/temp_dir.rb.erb +3 -3
- data/lib/rubysmith.rb +10 -30
- data.tar.gz.sig +0 -0
- metadata +55 -13
- metadata.gz.sig +0 -0
- data/lib/rubysmith/builders/ruby_critic.rb +0 -27
- data/lib/rubysmith/cli/configuration.rb +0 -30
- data/lib/rubysmith/cli/processors/build.rb +0 -58
- data/lib/rubysmith/cli/processors/config.rb +0 -35
- data/lib/rubysmith/realm.rb +0 -74
- data/lib/rubysmith/templates/%project_name%/.rubycritic.yml.erb +0 -3
- data/lib/rubysmith/templates/%project_name%/lib/%project_name%.rb.erb +0 -3
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dry-container"
|
4
|
+
require "logger"
|
5
|
+
require "pastel"
|
6
|
+
|
7
|
+
module Rubysmith
|
8
|
+
# Provides a global gem container for injection into other objects.
|
9
|
+
module Container
|
10
|
+
extend Dry::Container::Mixin
|
11
|
+
|
12
|
+
register(:configuration, memoize: true) { CLI::Configuration::Loader.call }
|
13
|
+
register(:colorizer) { Pastel.new enabled: $stdout.tty? }
|
14
|
+
register(:kernel) { Kernel }
|
15
|
+
|
16
|
+
register :log_colors do
|
17
|
+
{
|
18
|
+
"DEBUG" => self[:colorizer].white.detach,
|
19
|
+
"INFO" => self[:colorizer].green.detach,
|
20
|
+
"WARN" => self[:colorizer].yellow.detach,
|
21
|
+
"ERROR" => self[:colorizer].red.detach,
|
22
|
+
"FATAL" => self[:colorizer].white.bold.on_red.detach,
|
23
|
+
"ANY" => self[:colorizer].white.bold.detach
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
register :logger do
|
28
|
+
Logger.new $stdout,
|
29
|
+
level: Logger.const_get(ENV.fetch("LOG_LEVEL", "INFO")),
|
30
|
+
formatter: (
|
31
|
+
lambda do |severity, _at, _name, message|
|
32
|
+
self[:log_colors][severity].call "#{message}\n"
|
33
|
+
end
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/rubysmith/identity.rb
CHANGED
@@ -4,8 +4,8 @@ module Rubysmith
|
|
4
4
|
module Identity
|
5
5
|
NAME = "rubysmith"
|
6
6
|
LABEL = "Rubysmith"
|
7
|
-
VERSION = "0.
|
8
|
-
VERSION_LABEL = "#{LABEL} #{VERSION}"
|
7
|
+
VERSION = "0.13.0"
|
8
|
+
VERSION_LABEL = "#{LABEL} #{VERSION}".freeze
|
9
9
|
SUMMARY = "A command line interface for smithing Ruby projects."
|
10
10
|
end
|
11
11
|
end
|
data/lib/rubysmith/pathway.rb
CHANGED
@@ -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
|
10
|
-
|
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 :
|
22
|
+
attr_reader :configuration, :scope, :client
|
23
23
|
|
24
|
-
def namespace
|
25
|
-
self.buffer = scope.call yield
|
26
|
-
end
|
24
|
+
def namespace = self.buffer = block_given? ? scope.call(yield) : buffer + scope.call
|
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 = nil) = "#{prefix}#{body content}#{suffix}"
|
20
18
|
|
21
19
|
private
|
22
20
|
|
@@ -30,7 +28,7 @@ module Rubysmith
|
|
30
28
|
|
31
29
|
# :reek:FeatureEnvy
|
32
30
|
def body content
|
33
|
-
content.lstrip.split("\n").reduce "" do |snippet, line|
|
31
|
+
String(content).lstrip.split("\n").reduce "" do |snippet, line|
|
34
32
|
next "#{snippet}\n" if line.blank?
|
35
33
|
|
36
34
|
"#{snippet}#{line.gsub(/^\s{2}/, "").indent depth + 1}\n"
|
@@ -2,6 +2,6 @@ inherit_from:
|
|
2
2
|
- https://raw.githubusercontent.com/bkuhlmann/code_quality/main/configurations/rubocop/ruby.yml
|
3
3
|
- https://raw.githubusercontent.com/bkuhlmann/code_quality/main/configurations/rubocop/rake.yml
|
4
4
|
- https://raw.githubusercontent.com/bkuhlmann/code_quality/main/configurations/rubocop/performance.yml
|
5
|
-
<% if
|
5
|
+
<% if configuration.build_rspec %>
|
6
6
|
- https://raw.githubusercontent.com/bkuhlmann/code_quality/main/configurations/rubocop/rspec.yml
|
7
7
|
<% end %>
|
@@ -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:<%=
|
55
|
-
|
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 [<%=
|
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
|
|
@@ -2,60 +2,56 @@ ruby File.read(".ruby-version").strip
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
<%
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
<% if configuration.build_refinements %>
|
6
|
+
gem "refinements", "~> 8.0"
|
7
|
+
<% end %>
|
8
|
+
<% if configuration.build_zeitwerk %>
|
9
|
+
gem "zeitwerk", "~> 2.4"
|
10
|
+
<% end %>
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
gem "rubycritic", "~> 4.5", require: false
|
33
|
-
<% end %>
|
34
|
-
<% if realm.build_simple_cov %>
|
35
|
-
gem "simplecov", "~> 0.20"
|
36
|
-
<% end %>
|
37
|
-
end
|
12
|
+
group :code_quality do
|
13
|
+
<% if configuration.build_bundler_leak %>
|
14
|
+
gem "bundler-leak", "~> 0.2"
|
15
|
+
<% end %>
|
16
|
+
<% if configuration.build_git && configuration.build_git_lint %>
|
17
|
+
gem "git-lint", "~> 2.0"
|
18
|
+
<% end %>
|
19
|
+
<% if configuration.build_reek %>
|
20
|
+
gem "reek", "~> 6.0"
|
21
|
+
<% end %>
|
22
|
+
<% if configuration.build_rubocop %>
|
23
|
+
gem "rubocop", "~> 1.20"
|
24
|
+
gem "rubocop-performance", "~> 1.11"
|
25
|
+
gem "rubocop-rake", "~> 0.6"
|
26
|
+
<% end %>
|
27
|
+
<% if configuration.build_rspec && configuration.build_rubocop %>
|
28
|
+
gem "rubocop-rspec", "~> 2.4"
|
29
|
+
<% end %>
|
30
|
+
<% if configuration.build_simple_cov %>
|
31
|
+
gem "simplecov", "~> 0.20"
|
32
|
+
<% end %>
|
33
|
+
end
|
38
34
|
|
35
|
+
<% if configuration.build_rake %>
|
39
36
|
group :development do
|
40
37
|
gem "rake", "~> 13.0"
|
41
38
|
end
|
39
|
+
<% end %>
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
41
|
+
group :test do
|
42
|
+
<% if configuration.build_guard %>
|
43
|
+
gem "guard-rspec", "~> 4.7", require: false
|
44
|
+
<% end %>
|
45
|
+
<% if configuration.build_rspec %>
|
46
|
+
gem "rspec", "~> 3.10"
|
47
|
+
<% end %>
|
48
|
+
end
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
61
|
-
<% end %>
|
50
|
+
group :tools do
|
51
|
+
<% if configuration.build_amazing_print %>
|
52
|
+
gem "amazing_print", "~> 1.3"
|
53
|
+
<% end %>
|
54
|
+
<% if configuration.build_debug %>
|
55
|
+
gem "debug", "~> 1.1"
|
56
|
+
<% end %>
|
57
|
+
end
|
@@ -150,7 +150,7 @@ additional liability.
|
|
150
150
|
|
151
151
|
END OF TERMS AND CONDITIONS
|
152
152
|
|
153
|
-
Copyright <%=
|
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 <%=
|
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 <%=
|
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 <%=
|
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
|
-
= <%=
|
5
|
+
= <%= configuration.project_label %>
|
6
6
|
|
7
|
-
<% if
|
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
|
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
|
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:<%=
|
83
|
+
Engineered by link:<%= configuration.author_url %>[<%= configuration.author_name %>].
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# <%=
|
1
|
+
# <%= configuration.project_label %>
|
2
2
|
|
3
|
-
<% if
|
3
|
+
<% if configuration.build_rubocop %>
|
4
4
|
[](https://www.alchemists.io/projects/code_quality)
|
5
5
|
<% end %>
|
6
6
|
|
@@ -16,7 +16,7 @@
|
|
16
16
|
1. [Ruby](https://www.ruby-lang.org)
|
17
17
|
|
18
18
|
## Setup
|
19
|
-
<% if
|
19
|
+
<% if configuration.build_setup %>
|
20
20
|
|
21
21
|
To set up the project, run:
|
22
22
|
|
@@ -26,7 +26,7 @@ To set up the project, run:
|
|
26
26
|
## Usage
|
27
27
|
|
28
28
|
## Development
|
29
|
-
<% if
|
29
|
+
<% if configuration.build_console %>
|
30
30
|
|
31
31
|
You can also use the IRB console for direct access to all objects:
|
32
32
|
|
@@ -67,4 +67,4 @@ Built with [Rubysmith](https://www.alchemists.io/projects/rubysmith).
|
|
67
67
|
|
68
68
|
## Credits
|
69
69
|
|
70
|
-
Engineered by [<%=
|
70
|
+
Engineered by [<%= configuration.author_name %>](<%= configuration.author_url %>).
|
@@ -1,47 +1,35 @@
|
|
1
1
|
require "bundler/setup"
|
2
2
|
|
3
|
-
<% if
|
4
|
-
require "bundler/audit/task"
|
5
|
-
<% end %>
|
6
|
-
<% if realm.build_bundler_leak %>
|
3
|
+
<% if configuration.build_bundler_leak %>
|
7
4
|
require "bundler/plumber/task"
|
8
5
|
<% end %>
|
9
|
-
<% if
|
6
|
+
<% if configuration.build_git && configuration.build_git_lint %>
|
10
7
|
require "git/lint/rake/setup"
|
11
8
|
<% end %>
|
12
|
-
<% if
|
9
|
+
<% if configuration.build_reek %>
|
13
10
|
require "reek/rake/task"
|
14
11
|
<% end %>
|
15
|
-
<% if
|
12
|
+
<% if configuration.build_rspec %>
|
16
13
|
require "rspec/core/rake_task"
|
17
14
|
<% end %>
|
18
|
-
<% if
|
15
|
+
<% if configuration.build_rubocop %>
|
19
16
|
require "rubocop/rake_task"
|
20
17
|
<% end %>
|
21
|
-
<% if realm.build_ruby_critic %>
|
22
|
-
require "rubycritic/rake_task"
|
23
|
-
<% end %>
|
24
18
|
|
25
|
-
<% if
|
26
|
-
Bundler::Audit::Task.new
|
27
|
-
<% end %>
|
28
|
-
<% if realm.build_bundler_leak %>
|
19
|
+
<% if configuration.build_bundler_leak %>
|
29
20
|
Bundler::Plumber::Task.new
|
30
21
|
<% end %>
|
31
|
-
<% if
|
22
|
+
<% if configuration.build_reek %>
|
32
23
|
Reek::Rake::Task.new
|
33
24
|
<% end %>
|
34
|
-
<% if
|
25
|
+
<% if configuration.build_rspec %>
|
35
26
|
RSpec::Core::RakeTask.new :spec
|
36
27
|
<% end %>
|
37
|
-
<% if
|
28
|
+
<% if configuration.build_rubocop %>
|
38
29
|
RuboCop::RakeTask.new
|
39
30
|
<% end %>
|
40
|
-
<% if realm.build_ruby_critic %>
|
41
|
-
RubyCritic::RakeTask.new
|
42
|
-
<% end %>
|
43
31
|
|
44
32
|
desc "Run code quality checks"
|
45
|
-
task code_quality: %i[<% if
|
33
|
+
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 %>]
|
46
34
|
|
47
|
-
task default: %i[code_quality <% if
|
35
|
+
task default: %i[code_quality <% if configuration.build_rspec %>spec<% end %>]
|