rubysmith 0.9.1 → 0.10.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.tar.gz.sig +0 -0
- data/bin/rubysmith +0 -1
- data/lib/rubysmith.rb +3 -2
- data/lib/rubysmith/builder.rb +13 -26
- data/lib/rubysmith/builders/bundler.rb +6 -8
- data/lib/rubysmith/builders/console.rb +6 -8
- data/lib/rubysmith/builders/core.rb +7 -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 +5 -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/ruby_critic.rb +6 -8
- data/lib/rubysmith/builders/setup.rb +8 -8
- data/lib/rubysmith/cli/configuration/content.rb +69 -0
- data/lib/rubysmith/cli/{defaults.yml → configuration/defaults.yml} +0 -0
- data/lib/rubysmith/cli/configuration/loader.rb +35 -0
- data/lib/rubysmith/cli/parsers.rb +11 -0
- data/lib/rubysmith/cli/parsers/assembler.rb +10 -15
- data/lib/rubysmith/cli/parsers/build.rb +4 -6
- data/lib/rubysmith/cli/parsers/core.rb +5 -9
- data/lib/rubysmith/cli/processors/build.rb +9 -8
- data/lib/rubysmith/cli/processors/config.rb +3 -7
- data/lib/rubysmith/cli/shell.rb +7 -14
- data/lib/rubysmith/identity.rb +1 -1
- data/lib/rubysmith/pathway.rb +3 -9
- data/lib/rubysmith/renderers/erb.rb +7 -9
- data/lib/rubysmith/renderers/namespace.rb +1 -3
- 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 +14 -14
- 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 +15 -15
- data/lib/rubysmith/templates/%project_name%/bin/console.erb +1 -1
- data/lib/rubysmith/templates/%project_name%/lib/%project_name%.rb.erb +1 -1
- 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
- metadata +7 -6
- metadata.gz.sig +0 -0
- data/lib/rubysmith/cli/configuration.rb +0 -30
- data/lib/rubysmith/realm.rb +0 -74
@@ -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
|
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
|
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 :
|
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,
|
@@ -37,21 +41,18 @@ module Rubysmith
|
|
37
41
|
new builders: MINIMUM
|
38
42
|
end
|
39
43
|
|
40
|
-
def initialize builders: MAXIMUM
|
44
|
+
def initialize configuration: Configuration::Loader.call, builders: MAXIMUM
|
45
|
+
@configuration = configuration
|
41
46
|
@builders = builders
|
42
47
|
end
|
43
48
|
|
44
|
-
def call options
|
45
|
-
Realm[**options].then { |realm| process realm }
|
46
|
-
end
|
49
|
+
def call(options) = configuration.merge(**options).then { |config| process config }
|
47
50
|
|
48
51
|
private
|
49
52
|
|
50
|
-
attr_reader :builders
|
53
|
+
attr_reader :configuration, :builders
|
51
54
|
|
52
|
-
def process
|
53
|
-
builders.each { |builder| builder.call realm }
|
54
|
-
end
|
55
|
+
def process(config) = builders.each { |builder| builder.call config }
|
55
56
|
end
|
56
57
|
end
|
57
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
|
data/lib/rubysmith/cli/shell.rb
CHANGED
@@ -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
|
-
#
|
7
|
+
# The main Command Line Interface (CLI) object.
|
9
8
|
class Shell
|
10
9
|
using Refinements::Hashes
|
11
10
|
|
@@ -24,10 +23,10 @@ module Rubysmith
|
|
24
23
|
parse arguments
|
25
24
|
|
26
25
|
case options
|
27
|
-
in config: action then process_config action
|
26
|
+
in config: Symbol => action then process_config action
|
28
27
|
in build_minimum: true then process_build :build_minimum, options
|
29
28
|
in build: then process_build :build_maximum, options
|
30
|
-
in version: then puts version
|
29
|
+
in version: String => version then puts version
|
31
30
|
in help: then usage
|
32
31
|
else usage
|
33
32
|
end
|
@@ -35,7 +34,7 @@ module Rubysmith
|
|
35
34
|
|
36
35
|
private
|
37
36
|
|
38
|
-
attr_reader :parser, :processors
|
37
|
+
attr_reader :parser, :processors
|
39
38
|
|
40
39
|
def parse arguments = []
|
41
40
|
parser.call arguments
|
@@ -43,22 +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
48
|
processors.fetch(kind).call settings.transform_keys(build: :project_name)
|
52
49
|
.merge(now: Time.now)
|
53
50
|
end
|
54
51
|
|
55
|
-
def options
|
56
|
-
parser.to_h
|
57
|
-
end
|
52
|
+
def options = parser.to_h
|
58
53
|
|
59
|
-
def usage
|
60
|
-
puts parser.to_s
|
61
|
-
end
|
54
|
+
def usage = puts(parser.to_s)
|
62
55
|
end
|
63
56
|
end
|
64
57
|
end
|
data/lib/rubysmith/identity.rb
CHANGED
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 = scope.call(yield)
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
@@ -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,36 +2,36 @@ ruby File.read(".ruby-version").strip
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
<% unless
|
6
|
-
<% if
|
5
|
+
<% unless configuration.build_minimum %>
|
6
|
+
<% if configuration.build_refinements %>
|
7
7
|
gem "refinements", "~> 8.0"
|
8
8
|
<% end %>
|
9
9
|
|
10
10
|
group :code_quality do
|
11
|
-
<% if
|
11
|
+
<% if configuration.build_bundler_audit %>
|
12
12
|
gem "bundler-audit", "~> 0.7"
|
13
13
|
<% end %>
|
14
|
-
<% if
|
14
|
+
<% if configuration.build_bundler_leak %>
|
15
15
|
gem "bundler-leak", "~> 0.2"
|
16
16
|
<% end %>
|
17
|
-
<% if
|
17
|
+
<% if configuration.build_git && configuration.build_git_lint %>
|
18
18
|
gem "git-lint", "~> 2.0"
|
19
19
|
<% end %>
|
20
|
-
<% if
|
20
|
+
<% if configuration.build_reek %>
|
21
21
|
gem "reek", "~> 6.0"
|
22
22
|
<% end %>
|
23
|
-
<% if
|
23
|
+
<% if configuration.build_rubocop %>
|
24
24
|
gem "rubocop", "~> 1.10"
|
25
25
|
gem "rubocop-performance", "~> 1.9"
|
26
26
|
gem "rubocop-rake", "~> 0.5"
|
27
27
|
<% end %>
|
28
|
-
<% if
|
28
|
+
<% if configuration.build_rspec && configuration.build_rubocop %>
|
29
29
|
gem "rubocop-rspec", "~> 2.0"
|
30
30
|
<% end %>
|
31
|
-
<% if
|
31
|
+
<% if configuration.build_ruby_critic %>
|
32
32
|
gem "rubycritic", "~> 4.5", require: false
|
33
33
|
<% end %>
|
34
|
-
<% if
|
34
|
+
<% if configuration.build_simple_cov %>
|
35
35
|
gem "simplecov", "~> 0.20"
|
36
36
|
<% end %>
|
37
37
|
end
|
@@ -41,19 +41,19 @@ source "https://rubygems.org"
|
|
41
41
|
end
|
42
42
|
|
43
43
|
group :test do
|
44
|
-
<% if
|
44
|
+
<% if configuration.build_guard %>
|
45
45
|
gem "guard-rspec", "~> 4.7", require: false
|
46
46
|
<% end %>
|
47
|
-
<% if
|
47
|
+
<% if configuration.build_rspec %>
|
48
48
|
gem "rspec", "~> 3.10"
|
49
49
|
<% end %>
|
50
50
|
end
|
51
51
|
|
52
52
|
group :tools do
|
53
|
-
<% if
|
53
|
+
<% if configuration.build_amazing_print %>
|
54
54
|
gem "amazing_print", "~> 1.2"
|
55
55
|
<% end %>
|
56
|
-
<% if
|
56
|
+
<% if configuration.build_pry %>
|
57
57
|
gem "pry", "~> 0.13"
|
58
58
|
gem "pry-byebug", "~> 3.9"
|
59
59
|
<% 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 %>).
|