rubysmith 0.9.1 → 0.13.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/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
@@ -9,22 +9,22 @@
|
|
9
9
|
:license: "mit"
|
10
10
|
:build:
|
11
11
|
:amazing_print: true
|
12
|
-
:bundler_audit: true
|
13
12
|
:bundler_leak: true
|
14
13
|
:console: true
|
14
|
+
:debug: true
|
15
15
|
:documentation: true
|
16
16
|
:git: true
|
17
17
|
:git_lint: true
|
18
18
|
:guard: true
|
19
19
|
:minimum: false
|
20
|
-
:
|
20
|
+
:rake: true
|
21
21
|
:reek: true
|
22
22
|
:refinements: true
|
23
23
|
:rspec: true
|
24
24
|
:rubocop: true
|
25
|
-
:ruby_critic: true
|
26
25
|
:setup: true
|
27
26
|
:simple_cov: true
|
27
|
+
:zeitwerk: true
|
28
28
|
:builders:
|
29
29
|
:pragmater:
|
30
30
|
:comments:
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
require "refinements/hashes"
|
5
|
+
require "refinements/structs"
|
6
|
+
require "runcom"
|
7
|
+
require "yaml"
|
8
|
+
|
9
|
+
module Rubysmith
|
10
|
+
module CLI
|
11
|
+
module Configuration
|
12
|
+
# Represents the fully assembled Command Line Interface (CLI) configuration.
|
13
|
+
class Loader
|
14
|
+
using Refinements::Hashes
|
15
|
+
using Refinements::Structs
|
16
|
+
|
17
|
+
DEFAULTS = YAML.load_file(Pathname(__dir__).join("defaults.yml")).freeze
|
18
|
+
CLIENT = Runcom::Config.new "#{Identity::NAME}/configuration.yml", defaults: DEFAULTS
|
19
|
+
|
20
|
+
def self.call(...) = new(...).call
|
21
|
+
|
22
|
+
def self.with_defaults(now: Time.now) = new(now: now, client: DEFAULTS)
|
23
|
+
|
24
|
+
def initialize now: Time.now, content: Content.new, client: CLIENT
|
25
|
+
@now = now
|
26
|
+
@content = content
|
27
|
+
@client = client
|
28
|
+
end
|
29
|
+
|
30
|
+
def call = content.merge(**client.to_h.flatten_keys, now: now)
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_reader :now, :content, :client
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,38 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "runcom"
|
4
|
-
|
5
3
|
module Rubysmith
|
6
4
|
module CLI
|
7
5
|
module Parsers
|
8
|
-
CLIENT = OptionParser.new nil, 40, " "
|
9
|
-
SECTIONS = [Core, Build].freeze # Order is important.
|
10
|
-
|
11
6
|
# Assembles and parses all Command Line Interface (CLI) options.
|
12
7
|
class Assembler
|
13
|
-
|
14
|
-
|
8
|
+
SECTIONS = [Core, Build].freeze # Order is important.
|
9
|
+
|
10
|
+
def initialize sections: SECTIONS, client: CLIENT, container: Container
|
15
11
|
@sections = sections
|
16
|
-
@
|
12
|
+
@client = client
|
13
|
+
@container = container
|
17
14
|
end
|
18
15
|
|
19
16
|
def call arguments = []
|
20
|
-
sections.each { |parser| parser.call client: client
|
17
|
+
sections.each { |parser| parser.call client: client }
|
21
18
|
client.parse! arguments
|
22
|
-
|
19
|
+
configuration
|
23
20
|
end
|
24
21
|
|
25
|
-
def
|
26
|
-
options
|
27
|
-
end
|
28
|
-
|
29
|
-
def to_s
|
30
|
-
client.to_s
|
31
|
-
end
|
22
|
+
def to_s = client.to_s
|
32
23
|
|
33
24
|
private
|
34
25
|
|
35
|
-
attr_reader :
|
26
|
+
attr_reader :sections, :client, :container
|
27
|
+
|
28
|
+
def configuration = container[__method__]
|
36
29
|
end
|
37
30
|
end
|
38
31
|
end
|
@@ -4,15 +4,12 @@ module Rubysmith
|
|
4
4
|
module CLI
|
5
5
|
module Parsers
|
6
6
|
# Handles parsing of Command Line Interface (CLI) build options.
|
7
|
-
# :reek:TooManyMethods
|
8
7
|
class Build
|
9
|
-
def self.call
|
10
|
-
new(client: client, options: options).call
|
11
|
-
end
|
8
|
+
def self.call(...) = new(...).call
|
12
9
|
|
13
|
-
def initialize client: CLIENT,
|
10
|
+
def initialize client: CLIENT, container: Container
|
14
11
|
@client = client
|
15
|
-
@
|
12
|
+
@container = container
|
16
13
|
end
|
17
14
|
|
18
15
|
def call arguments = []
|
@@ -23,109 +20,111 @@ module Rubysmith
|
|
23
20
|
|
24
21
|
private
|
25
22
|
|
26
|
-
attr_reader :client, :
|
27
|
-
|
28
|
-
def add_minimum
|
29
|
-
client.on "--min", "Use minimum/no options." do |value|
|
30
|
-
options[:build_minimum] = value
|
31
|
-
end
|
32
|
-
end
|
23
|
+
attr_reader :client, :container
|
33
24
|
|
34
25
|
def add_amazing_print
|
35
26
|
client.on "--[no-]amazing_print", "Add Amazing Print." do |value|
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def add_bundler_audit
|
41
|
-
client.on "--[no-]bundler-audit", "Add Bundler Audit." do |value|
|
42
|
-
options[:build_bundler_audit] = value
|
27
|
+
configuration.build_amazing_print = value
|
43
28
|
end
|
44
29
|
end
|
45
30
|
|
46
31
|
def add_bundler_leak
|
47
32
|
client.on "--[no-]bundler-leak", "Add Bundler Leak." do |value|
|
48
|
-
|
33
|
+
configuration.build_bundler_leak = value
|
49
34
|
end
|
50
35
|
end
|
51
36
|
|
52
37
|
def add_console
|
53
38
|
client.on "--[no-]console", "Add console script." do |value|
|
54
|
-
|
39
|
+
configuration.build_console = value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_debug
|
44
|
+
client.on "--[no-]debug", "Add Debug." do |value|
|
45
|
+
configuration.build_debug = value
|
55
46
|
end
|
56
47
|
end
|
57
48
|
|
58
49
|
def add_documentation
|
59
50
|
client.on "--[no-]documentation", "Add documentation." do |value|
|
60
|
-
|
51
|
+
configuration.build_documentation = value
|
61
52
|
end
|
62
53
|
end
|
63
54
|
|
64
55
|
def add_git
|
65
56
|
client.on "--[no-]git", "Add Git." do |value|
|
66
|
-
|
57
|
+
configuration.build_git = value
|
67
58
|
end
|
68
59
|
end
|
69
60
|
|
70
61
|
def add_git_lint
|
71
62
|
client.on "--[no-]git-lint", "Add Git Lint." do |value|
|
72
|
-
|
63
|
+
configuration.build_git_lint = value
|
73
64
|
end
|
74
65
|
end
|
75
66
|
|
76
67
|
def add_guard
|
77
68
|
client.on "--[no-]guard", "Add Guard." do |value|
|
78
|
-
|
69
|
+
configuration.build_guard = value
|
79
70
|
end
|
80
71
|
end
|
81
72
|
|
82
|
-
def
|
83
|
-
client.on "--
|
84
|
-
|
73
|
+
def add_minimum
|
74
|
+
client.on "--min", "Use minimum/no options." do |value|
|
75
|
+
configuration.minimize.build_minimum = value
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_rake
|
80
|
+
client.on "--[no-]rake", "Add Rake." do |value|
|
81
|
+
configuration.build_rake = value
|
85
82
|
end
|
86
83
|
end
|
87
84
|
|
88
85
|
def add_reek
|
89
86
|
client.on "--[no-]reek", "Add Reek." do |value|
|
90
|
-
|
87
|
+
configuration.build_reek = value
|
91
88
|
end
|
92
89
|
end
|
93
90
|
|
94
91
|
def add_refinements
|
95
92
|
client.on "--[no-]refinements", "Add Refinements." do |value|
|
96
|
-
|
93
|
+
configuration.build_refinements = value
|
97
94
|
end
|
98
95
|
end
|
99
96
|
|
100
97
|
def add_rspec
|
101
98
|
client.on "--[no-]rspec", "Add RSpec." do |value|
|
102
|
-
|
99
|
+
configuration.build_rspec = value
|
103
100
|
end
|
104
101
|
end
|
105
102
|
|
106
103
|
def add_rubocop
|
107
104
|
client.on "--[no-]rubocop", "Add Rubocop." do |value|
|
108
|
-
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def add_ruby_critic
|
113
|
-
client.on "--[no-]ruby_critic", "Add RubyCritic." do |value|
|
114
|
-
options[:build_ruby_critic] = value
|
105
|
+
configuration.build_rubocop = value
|
115
106
|
end
|
116
107
|
end
|
117
108
|
|
118
109
|
def add_setup
|
119
110
|
client.on "--[no-]setup", "Add setup script." do |value|
|
120
|
-
|
111
|
+
configuration.build_setup = value
|
121
112
|
end
|
122
113
|
end
|
123
114
|
|
124
115
|
def add_simple_cov
|
125
116
|
client.on "--[no-]simple_cov", "Add SimpleCov." do |value|
|
126
|
-
|
117
|
+
configuration.build_simple_cov = value
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def add_zeitwerk
|
122
|
+
client.on "--[no-]zeitwerk", "Add Zeitwerk." do |value|
|
123
|
+
configuration.build_zeitwerk = value
|
127
124
|
end
|
128
125
|
end
|
126
|
+
|
127
|
+
def configuration = container[__method__]
|
129
128
|
end
|
130
129
|
end
|
131
130
|
end
|
@@ -1,19 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "rubysmith/identity"
|
4
|
+
require "refinements/structs"
|
4
5
|
|
5
6
|
module Rubysmith
|
6
7
|
module CLI
|
7
8
|
module Parsers
|
8
9
|
# Handles parsing of Command Line Interface (CLI) core options.
|
9
10
|
class Core
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
using Refinements::Structs
|
12
|
+
|
13
|
+
def self.call(...) = new(...).call
|
13
14
|
|
14
|
-
def initialize client: CLIENT,
|
15
|
+
def initialize client: CLIENT, container: Container
|
15
16
|
@client = client
|
16
|
-
@
|
17
|
+
@container = container
|
17
18
|
end
|
18
19
|
|
19
20
|
def call arguments = []
|
@@ -25,38 +26,38 @@ module Rubysmith
|
|
25
26
|
|
26
27
|
private
|
27
28
|
|
28
|
-
attr_reader :client, :
|
29
|
+
attr_reader :client, :container
|
29
30
|
|
30
|
-
def collate
|
31
|
-
private_methods.sort.grep(/add_/).each { |method| __send__ method }
|
32
|
-
end
|
31
|
+
def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
|
33
32
|
|
34
33
|
def add_config
|
35
34
|
client.on "-c",
|
36
35
|
"--config ACTION",
|
37
36
|
%i[edit view],
|
38
37
|
"Manage gem configuration: edit or view." do |action|
|
39
|
-
|
38
|
+
configuration.action_config = action
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
43
42
|
def add_build
|
44
|
-
client.on "-b", "--build NAME [options]", "Build new project." do |
|
45
|
-
|
43
|
+
client.on "-b", "--build NAME [options]", "Build new project." do |name|
|
44
|
+
configuration.merge! action_build: true, project_name: name
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
49
48
|
def add_version
|
50
49
|
client.on "-v", "--version", "Show gem version." do
|
51
|
-
|
50
|
+
configuration.action_version = Identity::VERSION_LABEL
|
52
51
|
end
|
53
52
|
end
|
54
53
|
|
55
54
|
def add_help
|
56
55
|
client.on "-h", "--help", "Show this message." do
|
57
|
-
|
56
|
+
configuration.action_help = true
|
58
57
|
end
|
59
58
|
end
|
59
|
+
|
60
|
+
def configuration = container[__method__]
|
60
61
|
end
|
61
62
|
end
|
62
63
|
end
|
data/lib/rubysmith/cli/shell.rb
CHANGED
@@ -1,41 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "optparse"
|
4
|
-
require "refinements/hashes"
|
5
|
-
|
6
3
|
module Rubysmith
|
7
4
|
module CLI
|
8
|
-
#
|
5
|
+
# The main Command Line Interface (CLI) object.
|
9
6
|
class Shell
|
10
|
-
|
11
|
-
|
12
|
-
PROCESSORS = {
|
13
|
-
config: Processors::Config.new,
|
14
|
-
build_minimum: Processors::Build.with_minimum,
|
15
|
-
build_maximum: Processors::Build.new
|
16
|
-
}.freeze
|
7
|
+
ACTIONS = {config: Actions::Config.new, build: Actions::Build.new}.freeze
|
17
8
|
|
18
|
-
def initialize parser: Parsers::Assembler.new,
|
9
|
+
def initialize parser: Parsers::Assembler.new, actions: ACTIONS, container: Container
|
19
10
|
@parser = parser
|
20
|
-
@
|
11
|
+
@actions = actions
|
12
|
+
@container = container
|
21
13
|
end
|
22
14
|
|
23
15
|
def call arguments = []
|
24
|
-
parse arguments
|
25
|
-
|
26
|
-
|
27
|
-
in
|
28
|
-
in build_minimum: true then process_build :build_minimum, options
|
29
|
-
in build: then process_build :build_maximum, options
|
30
|
-
in version: then puts version
|
31
|
-
in help: then usage
|
16
|
+
case parse arguments
|
17
|
+
in action_config: Symbol => action then config action
|
18
|
+
in action_build: true then build
|
19
|
+
in action_version: String => version then puts version
|
32
20
|
else usage
|
33
21
|
end
|
34
22
|
end
|
35
23
|
|
36
24
|
private
|
37
25
|
|
38
|
-
attr_reader :parser, :
|
26
|
+
attr_reader :parser, :actions, :container
|
39
27
|
|
40
28
|
def parse arguments = []
|
41
29
|
parser.call arguments
|
@@ -43,22 +31,13 @@ module Rubysmith
|
|
43
31
|
puts error.message
|
44
32
|
end
|
45
33
|
|
46
|
-
def
|
47
|
-
processors.fetch(:config).call action
|
48
|
-
end
|
34
|
+
def config(action) = actions.fetch(__method__).call(action)
|
49
35
|
|
50
|
-
def
|
51
|
-
processors.fetch(kind).call settings.transform_keys(build: :project_name)
|
52
|
-
.merge(now: Time.now)
|
53
|
-
end
|
36
|
+
def build = actions.fetch(__method__).call
|
54
37
|
|
55
|
-
def
|
56
|
-
parser.to_h
|
57
|
-
end
|
38
|
+
def usage = logger.unknown(parser.to_s)
|
58
39
|
|
59
|
-
def
|
60
|
-
puts parser.to_s
|
61
|
-
end
|
40
|
+
def logger = container[__method__]
|
62
41
|
end
|
63
42
|
end
|
64
43
|
end
|