rubysmith 0.16.1 → 1.2.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/LICENSE.adoc +207 -155
- data/README.adoc +360 -104
- data/exe/rubysmith +0 -1
- data/lib/rubysmith/builder.rb +1 -2
- data/lib/rubysmith/builders/bundler.rb +7 -11
- data/lib/rubysmith/builders/circle_ci.rb +8 -2
- data/lib/rubysmith/builders/console.rb +8 -2
- data/lib/rubysmith/builders/core.rb +14 -4
- data/lib/rubysmith/builders/documentation/{change.rb → citation.rb} +8 -8
- data/lib/rubysmith/builders/documentation/license.rb +9 -4
- data/lib/rubysmith/builders/documentation/readme.rb +12 -18
- data/lib/rubysmith/builders/documentation/{contribution.rb → version.rb} +10 -5
- data/lib/rubysmith/builders/git/commit.rb +5 -3
- data/lib/rubysmith/builders/{rubocop/setup.rb → git/ignore.rb} +11 -7
- data/lib/rubysmith/builders/git/setup.rb +2 -1
- data/lib/rubysmith/builders/git_hub.rb +8 -3
- data/lib/rubysmith/builders/guard.rb +9 -3
- data/lib/rubysmith/builders/rake.rb +9 -3
- data/lib/rubysmith/builders/reek.rb +7 -2
- data/lib/rubysmith/builders/rspec/context.rb +8 -2
- data/lib/rubysmith/builders/rspec/helper.rb +8 -2
- data/lib/rubysmith/builders/rubocop.rb +34 -0
- data/lib/rubysmith/builders/setup.rb +8 -2
- data/lib/rubysmith/builders/version.rb +28 -0
- data/lib/rubysmith/cli/actions/build.rb +12 -12
- data/lib/rubysmith/cli/actions/config.rb +4 -2
- data/lib/rubysmith/cli/actions/publish.rb +21 -0
- data/lib/rubysmith/cli/parser.rb +31 -0
- data/lib/rubysmith/cli/parsers/build.rb +98 -45
- data/lib/rubysmith/cli/parsers/core.rb +18 -9
- data/lib/rubysmith/cli/shell.rb +23 -14
- data/lib/rubysmith/configuration/content.rb +174 -0
- data/lib/rubysmith/configuration/defaults.yml +91 -0
- data/lib/rubysmith/configuration/enhancers/current_time.rb +24 -0
- data/lib/rubysmith/configuration/enhancers/git_email.rb +31 -0
- data/lib/rubysmith/configuration/enhancers/git_hub_user.rb +31 -0
- data/lib/rubysmith/configuration/enhancers/git_user.rb +33 -0
- data/lib/rubysmith/configuration/loader.rb +48 -0
- data/lib/rubysmith/container.rb +4 -1
- data/lib/rubysmith/extensions/bundler.rb +30 -0
- data/lib/rubysmith/extensions/milestoner.rb +37 -0
- data/lib/rubysmith/extensions/pragmater.rb +36 -0
- data/lib/rubysmith/extensions/rubocop.rb +29 -0
- data/lib/rubysmith/extensions/tocer.rb +39 -0
- data/lib/rubysmith/renderers/erb.rb +9 -1
- data/lib/rubysmith/templates/%project_name%/.github/ISSUE_TEMPLATE.md.erb +1 -4
- data/lib/rubysmith/templates/%project_name%/.gitignore.erb +11 -0
- data/lib/rubysmith/templates/%project_name%/.rubocop.yml.erb +2 -0
- data/lib/rubysmith/templates/%project_name%/CITATION.cff.erb +16 -0
- data/lib/rubysmith/templates/%project_name%/Gemfile.erb +19 -10
- data/lib/rubysmith/templates/%project_name%/LICENSE-hippocratic.adoc.erb +214 -0
- data/lib/rubysmith/templates/%project_name%/LICENSE-hippocratic.md.erb +214 -0
- data/lib/rubysmith/templates/%project_name%/README.adoc.erb +20 -21
- data/lib/rubysmith/templates/%project_name%/README.md.erb +20 -21
- data/lib/rubysmith/templates/%project_name%/Rakefile.erb +9 -0
- data/lib/rubysmith/templates/%project_name%/VERSIONS.adoc.erb +5 -0
- data/lib/rubysmith/templates/%project_name%/VERSIONS.md.erb +5 -0
- data/lib/rubysmith/templates/%project_name%/bin/rubocop.erb +0 -1
- data/lib/rubysmith/templates/%project_name%/lib/%project_path%.rb.erb +4 -4
- data/rubysmith.gemspec +42 -0
- data.tar.gz.sig +0 -0
- metadata +59 -39
- metadata.gz.sig +0 -0
- data/lib/rubysmith/builders/documentation/conduct.rb +0 -32
- data/lib/rubysmith/builders/pragma.rb +0 -32
- data/lib/rubysmith/builders/rubocop/formatter.rb +0 -31
- data/lib/rubysmith/cli/configuration/content.rb +0 -97
- data/lib/rubysmith/cli/configuration/defaults.yml +0 -46
- data/lib/rubysmith/cli/configuration/enhancers/current_time.rb +0 -26
- data/lib/rubysmith/cli/configuration/enhancers/git_hub_user.rb +0 -33
- data/lib/rubysmith/cli/configuration/enhancers/version.rb +0 -26
- data/lib/rubysmith/cli/configuration/loader.rb +0 -46
- data/lib/rubysmith/cli/parsers/assembler.rb +0 -32
- data/lib/rubysmith/cli/parsers.rb +0 -11
- data/lib/rubysmith/identity.rb +0 -11
- data/lib/rubysmith/templates/%project_name%/CHANGES.adoc.erb +0 -5
- data/lib/rubysmith/templates/%project_name%/CHANGES.md.erb +0 -5
- data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.adoc.erb +0 -114
- data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.md.erb +0 -115
- data/lib/rubysmith/templates/%project_name%/CONTRIBUTING.adoc.erb +0 -22
- data/lib/rubysmith/templates/%project_name%/CONTRIBUTING.md.erb +0 -22
@@ -8,12 +8,13 @@ module Rubysmith
|
|
8
8
|
# Order is important.
|
9
9
|
BUILDERS = [
|
10
10
|
Builders::Core,
|
11
|
+
Builders::Version,
|
11
12
|
Builders::Documentation::Readme,
|
12
|
-
Builders::Documentation::
|
13
|
-
Builders::Documentation::Conduct,
|
14
|
-
Builders::Documentation::Contribution,
|
13
|
+
Builders::Documentation::Citation,
|
15
14
|
Builders::Documentation::License,
|
15
|
+
Builders::Documentation::Version,
|
16
16
|
Builders::Git::Setup,
|
17
|
+
Builders::Git::Ignore,
|
17
18
|
Builders::Bundler,
|
18
19
|
Builders::Rake,
|
19
20
|
Builders::Console,
|
@@ -24,24 +25,23 @@ module Rubysmith
|
|
24
25
|
Builders::Reek,
|
25
26
|
Builders::RSpec::Context,
|
26
27
|
Builders::RSpec::Helper,
|
27
|
-
Builders::
|
28
|
-
|
29
|
-
|
28
|
+
Builders::Rubocop,
|
29
|
+
Extensions::Bundler,
|
30
|
+
Extensions::Pragmater,
|
31
|
+
Extensions::Tocer,
|
32
|
+
Extensions::Rubocop,
|
30
33
|
Builders::Git::Commit
|
31
34
|
].freeze
|
32
35
|
|
33
|
-
def initialize builders: BUILDERS
|
36
|
+
def initialize builders: BUILDERS
|
34
37
|
@builders = builders
|
35
|
-
@container = container
|
36
38
|
end
|
37
39
|
|
38
|
-
def call = builders.each { |builder| builder.call configuration }
|
40
|
+
def call(configuration) = builders.each { |builder| builder.call configuration }
|
39
41
|
|
40
42
|
private
|
41
43
|
|
42
|
-
attr_reader :
|
43
|
-
|
44
|
-
def configuration = container[__method__]
|
44
|
+
attr_reader :configuration, :builders
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -5,7 +5,7 @@ module Rubysmith
|
|
5
5
|
module Actions
|
6
6
|
# Handles the config action.
|
7
7
|
class Config
|
8
|
-
def initialize client:
|
8
|
+
def initialize client: Configuration::Loader::CLIENT, container: Container
|
9
9
|
@client = client
|
10
10
|
@container = container
|
11
11
|
end
|
@@ -14,7 +14,7 @@ module Rubysmith
|
|
14
14
|
case selection
|
15
15
|
when :edit then edit
|
16
16
|
when :view then view
|
17
|
-
else
|
17
|
+
else logger.error { "Invalid configuration selection: #{selection}." }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -27,6 +27,8 @@ module Rubysmith
|
|
27
27
|
def view = kernel.system("cat #{client.current}")
|
28
28
|
|
29
29
|
def kernel = container[__method__]
|
30
|
+
|
31
|
+
def logger = container[__method__]
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubysmith
|
4
|
+
module CLI
|
5
|
+
module Actions
|
6
|
+
# Handles parsing of Command Line Interface (CLI) publish options.
|
7
|
+
class Publish
|
8
|
+
def initialize extension: Extensions::Milestoner, container: Container
|
9
|
+
@extension = extension
|
10
|
+
@container = container
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(configuration) = extension.call(configuration)
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
attr_reader :extension, :container
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
|
5
|
+
module Rubysmith
|
6
|
+
module CLI
|
7
|
+
# Assembles and parses all Command Line Interface (CLI) options.
|
8
|
+
class Parser
|
9
|
+
CLIENT = OptionParser.new nil, 40, " "
|
10
|
+
SECTIONS = [Parsers::Core, Parsers::Build].freeze # Order is important.
|
11
|
+
|
12
|
+
def initialize sections: SECTIONS, client: CLIENT, container: Container
|
13
|
+
@sections = sections
|
14
|
+
@client = client
|
15
|
+
@configuration = container[:configuration].dup
|
16
|
+
end
|
17
|
+
|
18
|
+
def call arguments = []
|
19
|
+
sections.each { |section| section.call configuration, client: }
|
20
|
+
client.parse arguments
|
21
|
+
configuration.freeze
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s = client.to_s
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :sections, :client, :configuration
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,33 +1,43 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "refinements/structs"
|
4
|
+
|
3
5
|
module Rubysmith
|
4
6
|
module CLI
|
5
7
|
module Parsers
|
6
8
|
# Handles parsing of Command Line Interface (CLI) build options.
|
7
9
|
class Build
|
10
|
+
using Refinements::Structs
|
11
|
+
|
8
12
|
def self.call(...) = new(...).call
|
9
13
|
|
10
|
-
def initialize
|
14
|
+
def initialize configuration = Container[:configuration],
|
15
|
+
client: Parser::CLIENT,
|
16
|
+
container: Container
|
17
|
+
@configuration = configuration
|
11
18
|
@client = client
|
12
19
|
@container = container
|
13
20
|
end
|
14
21
|
|
15
22
|
def call arguments = []
|
16
23
|
client.separator "\nBUILD OPTIONS:\n"
|
17
|
-
|
18
|
-
|
24
|
+
collate
|
25
|
+
client.parse arguments
|
26
|
+
configuration
|
19
27
|
end
|
20
28
|
|
21
29
|
private
|
22
30
|
|
23
|
-
attr_reader :client, :container
|
31
|
+
attr_reader :configuration, :client, :container
|
32
|
+
|
33
|
+
def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
|
24
34
|
|
25
35
|
def add_amazing_print
|
26
36
|
client.on(
|
27
37
|
"--[no-]amazing_print",
|
28
38
|
"Add Amazing Print gem. #{default __method__}."
|
29
39
|
) do |value|
|
30
|
-
configuration.build_amazing_print
|
40
|
+
configuration.merge! build_amazing_print: value
|
31
41
|
end
|
32
42
|
end
|
33
43
|
|
@@ -36,16 +46,7 @@ module Rubysmith
|
|
36
46
|
"--[no-]bundler-leak",
|
37
47
|
"Add Bundler Leak gem. #{default __method__}."
|
38
48
|
) do |value|
|
39
|
-
configuration.build_bundler_leak
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def add_changes
|
44
|
-
client.on(
|
45
|
-
"--[no-]changes",
|
46
|
-
"Add CHANGES documentation. #{default __method__}."
|
47
|
-
) do |value|
|
48
|
-
configuration.build_changes = value
|
49
|
+
configuration.merge! build_bundler_leak: value
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -54,16 +55,16 @@ module Rubysmith
|
|
54
55
|
"--[no-]console",
|
55
56
|
"Add console script. #{default __method__}."
|
56
57
|
) do |value|
|
57
|
-
configuration.build_console
|
58
|
+
configuration.merge! build_console: value
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
61
62
|
def add_contributions
|
62
63
|
client.on(
|
63
64
|
"--[no-]contributions",
|
64
|
-
"Add
|
65
|
+
"Add contributions documentation. #{default __method__}."
|
65
66
|
) do |value|
|
66
|
-
configuration.build_contributions
|
67
|
+
configuration.merge! build_contributions: value
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
@@ -72,16 +73,43 @@ module Rubysmith
|
|
72
73
|
"--[no-]circle_ci",
|
73
74
|
"Add Circle CI configuration and badge. #{default __method__}."
|
74
75
|
) do |value|
|
75
|
-
configuration.build_circle_ci
|
76
|
+
configuration.merge! build_circle_ci: value
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def add_citation
|
81
|
+
client.on(
|
82
|
+
"--[no-]citation",
|
83
|
+
"Add citation documentation. #{default __method__}."
|
84
|
+
) do |value|
|
85
|
+
configuration.merge! build_citation: value
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def add_community
|
90
|
+
client.on(
|
91
|
+
"--[no-]community",
|
92
|
+
"Add community documentation. #{default __method__}."
|
93
|
+
) do |value|
|
94
|
+
configuration.merge! build_community: value
|
76
95
|
end
|
77
96
|
end
|
78
97
|
|
79
98
|
def add_conduct
|
80
99
|
client.on(
|
81
100
|
"--[no-]conduct",
|
82
|
-
"Add
|
101
|
+
"Add code of conduct documentation. #{default __method__}."
|
83
102
|
) do |value|
|
84
|
-
configuration.build_conduct
|
103
|
+
configuration.merge! build_conduct: value
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def add_dead_end
|
108
|
+
client.on(
|
109
|
+
"--[no-]dead_end",
|
110
|
+
"Add Dead End gem. #{default __method__}."
|
111
|
+
) do |value|
|
112
|
+
configuration.merge! build_dead_end: value
|
85
113
|
end
|
86
114
|
end
|
87
115
|
|
@@ -90,7 +118,7 @@ module Rubysmith
|
|
90
118
|
"--[no-]debug",
|
91
119
|
"Add Debug gem. #{default __method__}."
|
92
120
|
) do |value|
|
93
|
-
configuration.build_debug
|
121
|
+
configuration.merge! build_debug: value
|
94
122
|
end
|
95
123
|
end
|
96
124
|
|
@@ -99,7 +127,7 @@ module Rubysmith
|
|
99
127
|
"--[no-]git",
|
100
128
|
"Add Git. #{default __method__}."
|
101
129
|
) do |value|
|
102
|
-
configuration.build_git
|
130
|
+
configuration.merge! build_git: value
|
103
131
|
end
|
104
132
|
end
|
105
133
|
|
@@ -108,7 +136,7 @@ module Rubysmith
|
|
108
136
|
"--[no-]git_hub",
|
109
137
|
"Add GitHub templates. #{default __method__}."
|
110
138
|
) do |value|
|
111
|
-
configuration.build_git_hub
|
139
|
+
configuration.merge! build_git_hub: value
|
112
140
|
end
|
113
141
|
end
|
114
142
|
|
@@ -117,7 +145,7 @@ module Rubysmith
|
|
117
145
|
"--[no-]git-lint",
|
118
146
|
"Add Git Lint gem. #{default __method__}."
|
119
147
|
) do |value|
|
120
|
-
configuration.build_git_lint
|
148
|
+
configuration.merge! build_git_lint: value
|
121
149
|
end
|
122
150
|
end
|
123
151
|
|
@@ -126,16 +154,16 @@ module Rubysmith
|
|
126
154
|
"--[no-]guard",
|
127
155
|
"Add Guard gem. #{default __method__}."
|
128
156
|
) do |value|
|
129
|
-
configuration.build_guard
|
157
|
+
configuration.merge! build_guard: value
|
130
158
|
end
|
131
159
|
end
|
132
160
|
|
133
161
|
def add_license
|
134
162
|
client.on(
|
135
163
|
"--[no-]license",
|
136
|
-
"Add
|
164
|
+
"Add license documentation. #{default __method__}."
|
137
165
|
) do |value|
|
138
|
-
configuration.build_license
|
166
|
+
configuration.merge! build_license: value
|
139
167
|
end
|
140
168
|
end
|
141
169
|
|
@@ -143,8 +171,8 @@ module Rubysmith
|
|
143
171
|
client.on(
|
144
172
|
"--max",
|
145
173
|
"Use maximum/enabled options. #{default __method__}."
|
146
|
-
) do
|
147
|
-
configuration.maximize.
|
174
|
+
) do
|
175
|
+
configuration.merge!(**configuration.maximize.to_h)
|
148
176
|
end
|
149
177
|
end
|
150
178
|
|
@@ -152,8 +180,8 @@ module Rubysmith
|
|
152
180
|
client.on(
|
153
181
|
"--min",
|
154
182
|
"Use minimum/disabled options. #{default __method__}."
|
155
|
-
) do
|
156
|
-
configuration.minimize.
|
183
|
+
) do
|
184
|
+
configuration.merge!(**configuration.minimize.to_h)
|
157
185
|
end
|
158
186
|
end
|
159
187
|
|
@@ -162,16 +190,16 @@ module Rubysmith
|
|
162
190
|
"--[no-]rake",
|
163
191
|
"Add Rake gem. #{default __method__}."
|
164
192
|
) do |value|
|
165
|
-
configuration.build_rake
|
193
|
+
configuration.merge! build_rake: value
|
166
194
|
end
|
167
195
|
end
|
168
196
|
|
169
197
|
def add_readme
|
170
198
|
client.on(
|
171
199
|
"--[no-]readme",
|
172
|
-
"Add
|
200
|
+
"Add readme documentation. #{default __method__}."
|
173
201
|
) do |value|
|
174
|
-
configuration.build_readme
|
202
|
+
configuration.merge! build_readme: value
|
175
203
|
end
|
176
204
|
end
|
177
205
|
|
@@ -180,7 +208,7 @@ module Rubysmith
|
|
180
208
|
"--[no-]reek",
|
181
209
|
"Add Reek gem. #{default __method__}."
|
182
210
|
) do |value|
|
183
|
-
configuration.build_reek
|
211
|
+
configuration.merge! build_reek: value
|
184
212
|
end
|
185
213
|
end
|
186
214
|
|
@@ -189,7 +217,7 @@ module Rubysmith
|
|
189
217
|
"--[no-]refinements",
|
190
218
|
"Add Refinements gem. #{default __method__}."
|
191
219
|
) do |value|
|
192
|
-
configuration.build_refinements
|
220
|
+
configuration.merge! build_refinements: value
|
193
221
|
end
|
194
222
|
end
|
195
223
|
|
@@ -198,16 +226,25 @@ module Rubysmith
|
|
198
226
|
"--[no-]rspec",
|
199
227
|
"Add RSpec gem. #{default __method__}."
|
200
228
|
) do |value|
|
201
|
-
configuration.build_rspec
|
229
|
+
configuration.merge! build_rspec: value
|
202
230
|
end
|
203
231
|
end
|
204
232
|
|
205
233
|
def add_rubocop
|
206
234
|
client.on(
|
207
235
|
"--[no-]rubocop",
|
208
|
-
"Add
|
236
|
+
"Add RuboCop gems. #{default __method__}."
|
237
|
+
) do |value|
|
238
|
+
configuration.merge! build_rubocop: value
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def add_security
|
243
|
+
client.on(
|
244
|
+
"--[no-]security",
|
245
|
+
"Add security. #{default __method__}."
|
209
246
|
) do |value|
|
210
|
-
configuration.
|
247
|
+
configuration.merge! build_security: value
|
211
248
|
end
|
212
249
|
end
|
213
250
|
|
@@ -216,7 +253,7 @@ module Rubysmith
|
|
216
253
|
"--[no-]setup",
|
217
254
|
"Add setup script. #{default __method__}."
|
218
255
|
) do |value|
|
219
|
-
configuration.build_setup
|
256
|
+
configuration.merge! build_setup: value
|
220
257
|
end
|
221
258
|
end
|
222
259
|
|
@@ -225,7 +262,25 @@ module Rubysmith
|
|
225
262
|
"--[no-]simple_cov",
|
226
263
|
"Add SimpleCov gem. #{default __method__}."
|
227
264
|
) do |value|
|
228
|
-
configuration.build_simple_cov
|
265
|
+
configuration.merge! build_simple_cov: value
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
def add_versions
|
270
|
+
client.on(
|
271
|
+
"--[no-]versions",
|
272
|
+
"Add version history. #{default __method__}."
|
273
|
+
) do |value|
|
274
|
+
configuration.merge! build_versions: value
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
def add_yard
|
279
|
+
client.on(
|
280
|
+
"--[no-]yard",
|
281
|
+
"Add Yard gem. #{default __method__}."
|
282
|
+
) do |value|
|
283
|
+
configuration.merge! build_yard: value
|
229
284
|
end
|
230
285
|
end
|
231
286
|
|
@@ -234,7 +289,7 @@ module Rubysmith
|
|
234
289
|
"--[no-]zeitwerk",
|
235
290
|
"Add Zeitwerk gem. #{default __method__}."
|
236
291
|
) do |value|
|
237
|
-
configuration.build_zeitwerk
|
292
|
+
configuration.merge! build_zeitwerk: value
|
238
293
|
end
|
239
294
|
end
|
240
295
|
|
@@ -246,8 +301,6 @@ module Rubysmith
|
|
246
301
|
.then { |colored_boolean| "Default: #{colored_boolean}" }
|
247
302
|
end
|
248
303
|
|
249
|
-
def configuration = container[__method__]
|
250
|
-
|
251
304
|
def colorizer = container[__method__]
|
252
305
|
end
|
253
306
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "rubysmith/identity"
|
4
3
|
require "refinements/structs"
|
5
4
|
|
6
5
|
module Rubysmith
|
@@ -12,21 +11,25 @@ module Rubysmith
|
|
12
11
|
|
13
12
|
def self.call(...) = new(...).call
|
14
13
|
|
15
|
-
def initialize
|
14
|
+
def initialize configuration = Container[:configuration],
|
15
|
+
client: Parser::CLIENT,
|
16
|
+
container: Container
|
17
|
+
@configuration = configuration
|
16
18
|
@client = client
|
17
19
|
@container = container
|
18
20
|
end
|
19
21
|
|
20
22
|
def call arguments = []
|
21
|
-
client.banner = "
|
23
|
+
client.banner = "Rubysmith - #{specification.summary}"
|
22
24
|
client.separator "\nUSAGE:\n"
|
23
25
|
collate
|
24
|
-
|
26
|
+
client.parse arguments
|
27
|
+
configuration
|
25
28
|
end
|
26
29
|
|
27
30
|
private
|
28
31
|
|
29
|
-
attr_reader :client, :container
|
32
|
+
attr_reader :configuration, :client, :container
|
30
33
|
|
31
34
|
def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
|
32
35
|
|
@@ -35,7 +38,7 @@ module Rubysmith
|
|
35
38
|
"--config ACTION",
|
36
39
|
%i[edit view],
|
37
40
|
"Manage gem configuration: edit or view." do |action|
|
38
|
-
configuration.action_config
|
41
|
+
configuration.merge! action_config: action
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
@@ -45,19 +48,25 @@ module Rubysmith
|
|
45
48
|
end
|
46
49
|
end
|
47
50
|
|
51
|
+
def add_publish
|
52
|
+
client.on "-p", "--publish VERSION", "Publish project." do |version|
|
53
|
+
configuration.merge! action_publish: true, project_version: version
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
48
57
|
def add_version
|
49
58
|
client.on "-v", "--version", "Show gem version." do
|
50
|
-
configuration.action_version
|
59
|
+
configuration.merge! action_version: true
|
51
60
|
end
|
52
61
|
end
|
53
62
|
|
54
63
|
def add_help
|
55
64
|
client.on "-h", "--help", "Show this message." do
|
56
|
-
configuration.action_help
|
65
|
+
configuration.merge! action_help: true
|
57
66
|
end
|
58
67
|
end
|
59
68
|
|
60
|
-
def
|
69
|
+
def specification = container[__method__]
|
61
70
|
end
|
62
71
|
end
|
63
72
|
end
|
data/lib/rubysmith/cli/shell.rb
CHANGED
@@ -1,43 +1,52 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "milestoner"
|
4
|
+
|
3
5
|
module Rubysmith
|
4
6
|
module CLI
|
5
7
|
# The main Command Line Interface (CLI) object.
|
6
8
|
class Shell
|
7
|
-
ACTIONS = {
|
9
|
+
ACTIONS = {
|
10
|
+
config: Actions::Config.new,
|
11
|
+
build: Actions::Build.new,
|
12
|
+
publish: Actions::Publish.new
|
13
|
+
}.freeze
|
8
14
|
|
9
|
-
def initialize parser:
|
15
|
+
def initialize parser: Parser.new, actions: ACTIONS, container: Container
|
10
16
|
@parser = parser
|
11
17
|
@actions = actions
|
12
18
|
@container = container
|
13
19
|
end
|
14
20
|
|
15
21
|
def call arguments = []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
in action_version: true then logger.info configuration.version
|
20
|
-
else usage
|
21
|
-
end
|
22
|
+
perform parser.call(arguments)
|
23
|
+
rescue OptionParser::ParseError, Milestoner::Error => error
|
24
|
+
logger.error { error.message }
|
22
25
|
end
|
23
26
|
|
24
27
|
private
|
25
28
|
|
26
29
|
attr_reader :parser, :actions, :container
|
27
30
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
def perform configuration
|
32
|
+
case configuration
|
33
|
+
in action_config: Symbol => action then config action
|
34
|
+
in action_build: true then build configuration
|
35
|
+
in action_publish: true then publish configuration
|
36
|
+
in action_version: true then logger.info { "Rubysmith #{specification.version}" }
|
37
|
+
else usage
|
38
|
+
end
|
32
39
|
end
|
33
40
|
|
34
41
|
def config(action) = actions.fetch(__method__).call(action)
|
35
42
|
|
36
|
-
def build = actions.fetch(__method__).call
|
43
|
+
def build(configuration) = actions.fetch(__method__).call(configuration)
|
44
|
+
|
45
|
+
def publish(configuration) = actions.fetch(__method__).call(configuration)
|
37
46
|
|
38
47
|
def usage = logger.unknown(parser.to_s)
|
39
48
|
|
40
|
-
def
|
49
|
+
def specification = container[__method__]
|
41
50
|
|
42
51
|
def logger = container[__method__]
|
43
52
|
end
|