rubysmith 0.6.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.adoc +4 -2
- data/bin/rubysmith +0 -4
- data/lib/rubysmith.rb +4 -2
- data/lib/rubysmith/builder.rb +14 -30
- data/lib/rubysmith/builders/bundler.rb +11 -9
- data/lib/rubysmith/builders/console.rb +6 -8
- data/lib/rubysmith/builders/core.rb +7 -8
- data/lib/rubysmith/builders/documentation.rb +17 -22
- 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 +9 -14
- 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 +25 -0
- 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} +1 -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 +11 -7
- data/lib/rubysmith/cli/parsers/core.rb +5 -9
- data/lib/rubysmith/cli/processors/build.rb +10 -8
- data/lib/rubysmith/cli/processors/config.rb +3 -7
- data/lib/rubysmith/cli/shell.rb +12 -18
- 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 +5 -5
- data/lib/rubysmith/templates/%project_name%/.rubycritic.yml.erb +3 -0
- 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 +21 -16
- 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 +19 -13
- data/lib/rubysmith/templates/%project_name%/bin/console.erb +1 -1
- data/lib/rubysmith/templates/%project_name%/bin/guard.erb +0 -1
- data/lib/rubysmith/templates/%project_name%/bin/rubocop.erb +0 -1
- data/lib/rubysmith/templates/%project_name%/lib/%project_name%.rb.erb +3 -0
- data/lib/rubysmith/templates/%project_name%/spec/spec_helper.rb.erb +8 -3
- data/lib/rubysmith/templates/%project_name%/spec/support/shared_contexts/temp_dir.rb.erb +4 -4
- metadata +28 -25
- metadata.gz.sig +0 -0
- data/lib/rubysmith/cli/configuration.rb +0 -29
- 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
|
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
|
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 :
|
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
|
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.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
|
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
|
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,18 +23,18 @@ module Rubysmith
|
|
24
23
|
parse arguments
|
25
24
|
|
26
25
|
case options
|
27
|
-
in config: action
|
28
|
-
in build_minimum: true
|
29
|
-
in build
|
30
|
-
in version
|
31
|
-
in help
|
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
|
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.
|
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
|
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
|
@@ -1,7 +1,7 @@
|
|
1
1
|
inherit_from:
|
2
|
-
- https://raw.githubusercontent.com/bkuhlmann/code_quality/
|
3
|
-
- https://raw.githubusercontent.com/bkuhlmann/code_quality/
|
4
|
-
- https://raw.githubusercontent.com/bkuhlmann/code_quality/
|
5
|
-
<% if
|
6
|
-
- https://raw.githubusercontent.com/bkuhlmann/code_quality/
|
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 %>
|
@@ -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
|
|
@@ -1,32 +1,37 @@
|
|
1
|
+
ruby File.read(".ruby-version").strip
|
2
|
+
|
1
3
|
source "https://rubygems.org"
|
2
4
|
|
3
|
-
<% unless
|
4
|
-
<% if
|
5
|
-
gem "refinements", "~>
|
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
|
11
|
+
<% if configuration.build_bundler_audit %>
|
10
12
|
gem "bundler-audit", "~> 0.7"
|
11
13
|
<% end %>
|
12
|
-
<% if
|
14
|
+
<% if configuration.build_bundler_leak %>
|
13
15
|
gem "bundler-leak", "~> 0.2"
|
14
16
|
<% end %>
|
15
|
-
<% if
|
16
|
-
gem "git-lint", "~>
|
17
|
+
<% if configuration.build_git && configuration.build_git_lint %>
|
18
|
+
gem "git-lint", "~> 2.0"
|
17
19
|
<% end %>
|
18
|
-
<% if
|
20
|
+
<% if configuration.build_reek %>
|
19
21
|
gem "reek", "~> 6.0"
|
20
22
|
<% end %>
|
21
|
-
<% if
|
22
|
-
gem "rubocop", "~> 1.
|
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
|
28
|
+
<% if configuration.build_rspec && configuration.build_rubocop %>
|
27
29
|
gem "rubocop-rspec", "~> 2.0"
|
28
30
|
<% end %>
|
29
|
-
<% if
|
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
|
44
|
+
<% if configuration.build_guard %>
|
40
45
|
gem "guard-rspec", "~> 4.7", require: false
|
41
46
|
<% end %>
|
42
|
-
<% if
|
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
|
53
|
+
<% if configuration.build_amazing_print %>
|
49
54
|
gem "amazing_print", "~> 1.2"
|
50
55
|
<% end %>
|
51
|
-
<% if
|
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 <%=
|
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
|