gemsmith 17.0.1 → 18.0.2
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 +71 -30
- data/gemsmith.gemspec +5 -4
- data/lib/gemsmith/builders/circle_ci.rb +4 -1
- data/lib/gemsmith/builders/cli.rb +15 -7
- data/lib/gemsmith/builders/git/commit.rb +6 -5
- data/lib/gemsmith/cli/actions/config.rb +6 -7
- data/lib/gemsmith/cli/actions/container.rb +25 -0
- data/lib/gemsmith/cli/actions/edit.rb +5 -7
- data/lib/gemsmith/cli/actions/import.rb +11 -0
- data/lib/gemsmith/cli/actions/install.rb +5 -5
- data/lib/gemsmith/cli/actions/publish.rb +5 -5
- data/lib/gemsmith/cli/actions/view.rb +5 -7
- data/lib/gemsmith/cli/parser.rb +9 -5
- data/lib/gemsmith/cli/parsers/build.rb +7 -5
- data/lib/gemsmith/cli/parsers/core.rb +6 -5
- data/lib/gemsmith/cli/shell.rb +21 -40
- data/lib/gemsmith/container.rb +1 -1
- data/lib/gemsmith/import.rb +7 -0
- data/lib/gemsmith/templates/%project_name%/%project_name%.gemspec.erb +2 -2
- data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/actions/config.rb.erb +6 -9
- data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/actions/container.rb.erb +18 -0
- data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/actions/import.rb.erb +9 -0
- data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/parser.rb.erb +9 -5
- data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/parsers/core.rb.erb +6 -5
- data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/shell.rb.erb +6 -15
- data/lib/gemsmith/templates/%project_name%/lib/%project_path%/container.rb.erb +3 -25
- data/lib/gemsmith/templates/%project_name%/lib/%project_path%/import.rb.erb +5 -0
- data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/actions/config_spec.rb.erb +3 -3
- data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/parser_spec.rb.erb +1 -1
- data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/parsers/core_spec.rb.erb +1 -1
- data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb +16 -13
- data/lib/gemsmith/templates/%project_name%/spec/support/shared_contexts/application_dependencies.rb.erb +21 -0
- data/lib/gemsmith/tools/editor.rb +2 -9
- data/lib/gemsmith/tools/installer.rb +5 -5
- data/lib/gemsmith/tools/pusher.rb +23 -5
- data/lib/gemsmith/tools/validator.rb +1 -10
- data/lib/gemsmith/tools/versioner.rb +6 -6
- data/lib/gemsmith/tools/viewer.rb +1 -10
- data.tar.gz.sig +0 -0
- metadata +48 -28
- metadata.gz.sig +0 -0
- data/lib/gemsmith/templates/%project_name%/spec/support/shared_contexts/application_container.rb.erb +0 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: badab9b933b3cc8009dcce38b6c849c38e7b6d90fb849bda9ba3426e9d8c76fe
|
|
4
|
+
data.tar.gz: 48386d0058700e7ab46b0ce1189b8264f7c0dcf75f4e2d11b0a702c5bb82a858
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3dcd01d2e1c468062c19c060e080140eb6fd5da9dbbc408bdd0a4bdaa2db6e45e7bfdf066d94719380410a3f96d268a38632ff67bd01f4bfe07cc7fa1899e063
|
|
7
|
+
data.tar.gz: e43ce7b51bb41176925c911f80d40e8c88d464ce84e7effdf03ef4f0d1a09dc40737bf605aefa3db816e8fed511a7a56cef94b82b06f9ee1c90845b58ae6b4a5
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/README.adoc
CHANGED
|
@@ -14,8 +14,7 @@ toc::[]
|
|
|
14
14
|
|
|
15
15
|
== Features
|
|
16
16
|
|
|
17
|
-
* Supports all
|
|
18
|
-
which is used for smithing Ruby projects.
|
|
17
|
+
* Supports all link:https://www.alchemists.io/projects/rubysmith[Rubysmith] features.
|
|
19
18
|
* Supports basic gem skeletons or more advanced Command Line Interface (CLI) skeletons.
|
|
20
19
|
* Supports gem building, installing for local development, and publishing.
|
|
21
20
|
* Supports the editing and viewing of installed gems.
|
|
@@ -37,13 +36,12 @@ gem install gemsmith
|
|
|
37
36
|
|
|
38
37
|
== Upgrade
|
|
39
38
|
|
|
40
|
-
If upgrading from
|
|
39
|
+
If upgrading from 17.0.0 to 18.0.0, you'll want to be aware of the following changes:
|
|
41
40
|
|
|
42
|
-
*
|
|
43
|
-
* The
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
link:https://www.alchemists.io/projects/caliber[Caliber] gem now.
|
|
41
|
+
* The `--dead_end` build option has been removed.
|
|
42
|
+
* The Milestoner configuration has been updated to support ASCII Doc format by default and the
|
|
43
|
+
ability to sign tags has been removed (this happens dynamically based on your Git configuration
|
|
44
|
+
which gives you more flexibility).
|
|
47
45
|
|
|
48
46
|
== Usage
|
|
49
47
|
|
|
@@ -72,7 +70,6 @@ BUILD OPTIONS:
|
|
|
72
70
|
--[no-]conduct Add code of conduct documentation. Default: true.
|
|
73
71
|
--[no-]console Add console script. Default: true.
|
|
74
72
|
--[no-]contributions Add contributions documentation. Default: true.
|
|
75
|
-
--[no-]dead_end Add Dead End gem. Default: true.
|
|
76
73
|
--[no-]debug Add Debug gem. Default: true.
|
|
77
74
|
--[no-]git Add Git. Default: true.
|
|
78
75
|
--[no-]git_hub Add GitHub templates. Default: false.
|
|
@@ -102,7 +99,7 @@ build options allow you to further customize the kind of gem you want to build.
|
|
|
102
99
|
are enabled by default. For detailed documentation on all supported flags, see the
|
|
103
100
|
link:https://www.alchemists.io/projects/rubysmith/#_build[Rubysmith] documentation.
|
|
104
101
|
|
|
105
|
-
The build option
|
|
102
|
+
The build option which is unique to Gemsmith is the `--cli` option. This allows you to build a gem
|
|
106
103
|
which has a Command Line Interface (CLI). There are multiple ways a CLI can be built in Ruby but
|
|
107
104
|
Gemsmith takes an approach which builds upon Ruby's native `OptionParser` with help from
|
|
108
105
|
link:https://dry-rb.org/gems/dry-container[Dry Container]. All of this culminates in a design that
|
|
@@ -293,15 +290,27 @@ gem cert --build you@example.com
|
|
|
293
290
|
chmod 600 gem-*.pem
|
|
294
291
|
----
|
|
295
292
|
|
|
296
|
-
The resulting
|
|
297
|
-
|
|
293
|
+
The resulting `*.pem` key files can be referenced via the `signing_key` and `cert_chain` of your
|
|
294
|
+
`*.gemspec` which Gemsmith provides for you via the `--security` build option. Example:
|
|
295
|
+
|
|
296
|
+
[source,ruby]
|
|
297
|
+
----
|
|
298
|
+
# frozen_string_literal: true
|
|
299
|
+
|
|
300
|
+
Gem::Specification.new do |spec|
|
|
301
|
+
# Truncated for brevity.
|
|
302
|
+
spec.signing_key = Gem.default_key_path
|
|
303
|
+
spec.cert_chain = [Gem.default_cert_path]
|
|
304
|
+
end
|
|
305
|
+
----
|
|
298
306
|
|
|
299
307
|
To learn more about gem certificates, read about RubyGems
|
|
300
308
|
link:https://guides.rubygems.org/security[Security].
|
|
301
309
|
|
|
302
310
|
== Private Gem Servers
|
|
303
311
|
|
|
304
|
-
By default, the following
|
|
312
|
+
By default, the following command will publicly publish your gem to
|
|
313
|
+
link:https://rubygems.org[RubyGems]:
|
|
305
314
|
|
|
306
315
|
[source,bash]
|
|
307
316
|
----
|
|
@@ -319,20 +328,19 @@ Add the following metadata to your gemspec:
|
|
|
319
328
|
[source,ruby]
|
|
320
329
|
----
|
|
321
330
|
Gem::Specification.new do |spec|
|
|
322
|
-
spec.metadata = {
|
|
323
|
-
"allowed_push_key" => "example_key",
|
|
324
|
-
"allowed_push_host" => "https://gems.example.com"
|
|
325
|
-
}
|
|
331
|
+
spec.metadata = {"allowed_push_host" => "https://private.example.com"}
|
|
326
332
|
end
|
|
327
333
|
----
|
|
328
334
|
|
|
329
|
-
The gemspec metadata
|
|
330
|
-
link:https://guides.rubygems.org/specification-reference/#metadata[RubyGems Specification].
|
|
331
|
-
represents the following:
|
|
335
|
+
💡 The gemspec metadata _must_ be strings per the
|
|
336
|
+
link:https://guides.rubygems.org/specification-reference/#metadata[RubyGems Specification].
|
|
332
337
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
*
|
|
338
|
+
Use of the `allowed_push_host` key provides two important capabilities:
|
|
339
|
+
|
|
340
|
+
* Prevents you from accidentally publishing your private gem to the public RubyGems server (default
|
|
341
|
+
behavior).
|
|
342
|
+
* Defines the lookup key in your `$HOME/.gem/credentials` file which contains your private
|
|
343
|
+
credentials for authentication to your private server (more on this below).
|
|
336
344
|
|
|
337
345
|
=== Gem Credentials
|
|
338
346
|
|
|
@@ -340,18 +348,52 @@ With your gem specification metadata established, you are ready to publish your
|
|
|
340
348
|
private server. If this is your first time publishing a gem and no gem credentials have been
|
|
341
349
|
configured, you'll be prompted for them. Gem credentials are stored in the RubyGems
|
|
342
350
|
`$HOME/.gem/credentials` file. From this point forward, future gem publishing will use your stored
|
|
343
|
-
credentials instead.
|
|
344
|
-
|
|
351
|
+
credentials instead.
|
|
352
|
+
|
|
353
|
+
Multiple credentials can be stored in the `$HOME/.gem/credentials` file as well. Example:
|
|
345
354
|
|
|
346
355
|
[source,yaml]
|
|
347
356
|
----
|
|
348
357
|
:rubygems_api_key: 2a0b460650e67d9b85a60e183defa376
|
|
349
|
-
:
|
|
358
|
+
https://private.example.com: Basic dXNlcjpwYXNzd29yZA==
|
|
350
359
|
----
|
|
351
360
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
361
|
+
Notice how the first line contains credentials for the public RubyGems server while the second line
|
|
362
|
+
is for our private example server. You'll also notice that the key is not a symbol but a URL string
|
|
363
|
+
to our private server. This is important as this is how we link our gem specification metadata to
|
|
364
|
+
our private credentials. To illustrate further, here are both files truncated and shown together:
|
|
365
|
+
|
|
366
|
+
....
|
|
367
|
+
# Gem specification metadata which defines the private host to publish to.
|
|
368
|
+
spec.metadata = {"allowed_push_host" => "https://private.example.com"}
|
|
369
|
+
|
|
370
|
+
# Gem credentials where the URL value above becomes the key which enables authentication.
|
|
371
|
+
https://private.example.com: Basic dXNlcjpwYXNzd29yZA==
|
|
372
|
+
....
|
|
373
|
+
|
|
374
|
+
When the above are linked together like this, you enable Gemsmith to publish your gem using only the
|
|
375
|
+
following command:
|
|
376
|
+
|
|
377
|
+
[source,bash]
|
|
378
|
+
----
|
|
379
|
+
gemsmith --publish
|
|
380
|
+
----
|
|
381
|
+
|
|
382
|
+
This is especially powerful when publishing to
|
|
383
|
+
link:https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-rubygems-registry[GitHub's
|
|
384
|
+
Packages registory] which would look like this when properly configured (truncated for brevity):
|
|
385
|
+
|
|
386
|
+
....
|
|
387
|
+
# Gem specification
|
|
388
|
+
spec.metadata = {"allowed_push_host" => "https://rubygems.pkg.github.com/alchemists"}
|
|
389
|
+
|
|
390
|
+
# Gem credentials
|
|
391
|
+
https://rubygems.pkg.github.com/alchemists: Bearer ghp_c5b8d394abefebbf45c7b27b379c74978923
|
|
392
|
+
....
|
|
393
|
+
|
|
394
|
+
Lastly, should you need to delete a credential (due to a bad login/password for example), you can
|
|
395
|
+
open the `$HOME/.gem/credentials` in your default editor and remove the line(s) you don't need. Upon
|
|
396
|
+
next publish of your gem, you'll be prompted for the missing credentials.
|
|
355
397
|
|
|
356
398
|
== Promotion
|
|
357
399
|
|
|
@@ -359,7 +401,6 @@ Once your gem is released, let the world know about your accomplishment by posti
|
|
|
359
401
|
these sites:
|
|
360
402
|
|
|
361
403
|
* link:https://rubyflow.com[RubyFlow]
|
|
362
|
-
* link:https://rubyradar.dev[Ruby Radar]
|
|
363
404
|
* link:https://ruby.libhunt.com[Ruby Library Hunt]
|
|
364
405
|
* link:https://rubydaily.org[RubyDaily]
|
|
365
406
|
* link:https://awesome-ruby.com[Awesome Ruby]
|
data/gemsmith.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = "gemsmith"
|
|
5
|
-
spec.version = "
|
|
5
|
+
spec.version = "18.0.2"
|
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
|
8
8
|
spec.homepage = "https://www.alchemists.io/projects/gemsmith"
|
|
@@ -22,12 +22,13 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.cert_chain = [Gem.default_cert_path]
|
|
23
23
|
|
|
24
24
|
spec.required_ruby_version = "~> 3.1"
|
|
25
|
+
spec.add_dependency "auto_injector", "~> 0.4"
|
|
26
|
+
spec.add_dependency "cogger", "~> 0.0"
|
|
25
27
|
spec.add_dependency "dry-container", "~> 0.9"
|
|
26
28
|
spec.add_dependency "dry-monads", "~> 1.4"
|
|
27
|
-
spec.add_dependency "milestoner", "~>
|
|
28
|
-
spec.add_dependency "pastel", "~> 0.8"
|
|
29
|
+
spec.add_dependency "milestoner", "~> 14.0"
|
|
29
30
|
spec.add_dependency "refinements", "~> 9.2"
|
|
30
|
-
spec.add_dependency "rubysmith", "~>
|
|
31
|
+
spec.add_dependency "rubysmith", "~> 3.0"
|
|
31
32
|
spec.add_dependency "runcom", "~> 8.2"
|
|
32
33
|
spec.add_dependency "spek", "~> 0.2"
|
|
33
34
|
spec.add_dependency "versionaire", "~> 10.0"
|
|
@@ -19,7 +19,8 @@ module Gemsmith
|
|
|
19
19
|
return configuration unless configuration.build_circle_ci
|
|
20
20
|
|
|
21
21
|
builder.call(configuration.merge(template_path: "%project_name%/.circleci/config.yml.erb"))
|
|
22
|
-
.replace("Gemfile.lock"
|
|
22
|
+
.replace %({{checksum "Gemfile.lock"}}),
|
|
23
|
+
%({{checksum "Gemfile"}}-{{checksum "#{project_name}.gemspec"}})
|
|
23
24
|
|
|
24
25
|
configuration
|
|
25
26
|
end
|
|
@@ -27,6 +28,8 @@ module Gemsmith
|
|
|
27
28
|
private
|
|
28
29
|
|
|
29
30
|
attr_reader :configuration, :builder
|
|
31
|
+
|
|
32
|
+
def project_name = configuration.project_name
|
|
30
33
|
end
|
|
31
34
|
end
|
|
32
35
|
end
|
|
@@ -47,16 +47,24 @@ module Gemsmith
|
|
|
47
47
|
CONTENT
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
def
|
|
50
|
+
def render_configuration
|
|
51
51
|
[
|
|
52
|
-
"%project_name%/lib/%project_path%/cli/actions/config.rb.erb",
|
|
53
|
-
"%project_name%/lib/%project_path%/cli/parser.rb.erb",
|
|
54
|
-
"%project_name%/lib/%project_path%/cli/parsers/core.rb.erb",
|
|
55
|
-
"%project_name%/lib/%project_path%/cli/shell.rb.erb",
|
|
56
52
|
"%project_name%/lib/%project_path%/configuration/content.rb.erb",
|
|
57
53
|
"%project_name%/lib/%project_path%/configuration/defaults.yml.erb",
|
|
58
54
|
"%project_name%/lib/%project_path%/configuration/loader.rb.erb",
|
|
59
|
-
"%project_name%/lib/%project_path%/container.rb.erb"
|
|
55
|
+
"%project_name%/lib/%project_path%/container.rb.erb",
|
|
56
|
+
"%project_name%/lib/%project_path%/import.rb.erb"
|
|
57
|
+
].each { |path| builder.call(configuration.merge(template_path: path)).render }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def render_cli
|
|
61
|
+
[
|
|
62
|
+
"%project_name%/lib/%project_path%/cli/actions/config.rb.erb",
|
|
63
|
+
"%project_name%/lib/%project_path%/cli/actions/container.rb.erb",
|
|
64
|
+
"%project_name%/lib/%project_path%/cli/actions/import.rb.erb",
|
|
65
|
+
"%project_name%/lib/%project_path%/cli/parser.rb.erb",
|
|
66
|
+
"%project_name%/lib/%project_path%/cli/parsers/core.rb.erb",
|
|
67
|
+
"%project_name%/lib/%project_path%/cli/shell.rb.erb"
|
|
60
68
|
].each { |path| builder.call(configuration.merge(template_path: path)).render }
|
|
61
69
|
end
|
|
62
70
|
|
|
@@ -77,7 +85,7 @@ module Gemsmith
|
|
|
77
85
|
return unless configuration.build_rspec
|
|
78
86
|
|
|
79
87
|
[
|
|
80
|
-
"%project_name%/spec/support/shared_contexts/
|
|
88
|
+
"%project_name%/spec/support/shared_contexts/application_dependencies.rb.erb",
|
|
81
89
|
"%project_name%/spec/support/shared_examples/a_parser.rb.erb"
|
|
82
90
|
].each { |path| builder.call(configuration.merge(template_path: path)).render }
|
|
83
91
|
end
|
|
@@ -5,12 +5,15 @@ module Gemsmith
|
|
|
5
5
|
module Git
|
|
6
6
|
# Builds project skeleton initial Git commit message.
|
|
7
7
|
class Commit
|
|
8
|
+
include Import[:specification]
|
|
9
|
+
|
|
8
10
|
def self.call(...) = new(...).call
|
|
9
11
|
|
|
10
|
-
def initialize configuration, builder: Rubysmith::Builder,
|
|
12
|
+
def initialize configuration, builder: Rubysmith::Builder, **dependencies
|
|
13
|
+
super(**dependencies)
|
|
14
|
+
|
|
11
15
|
@configuration = configuration
|
|
12
16
|
@builder = builder
|
|
13
|
-
@container = container
|
|
14
17
|
end
|
|
15
18
|
|
|
16
19
|
def call
|
|
@@ -28,7 +31,7 @@ module Gemsmith
|
|
|
28
31
|
|
|
29
32
|
private
|
|
30
33
|
|
|
31
|
-
attr_reader :configuration, :builder
|
|
34
|
+
attr_reader :configuration, :builder
|
|
32
35
|
|
|
33
36
|
def body
|
|
34
37
|
<<~CONTENT
|
|
@@ -38,8 +41,6 @@ module Gemsmith
|
|
|
38
41
|
end
|
|
39
42
|
|
|
40
43
|
def project_name = configuration.project_name
|
|
41
|
-
|
|
42
|
-
def specification = container[__method__]
|
|
43
44
|
end
|
|
44
45
|
end
|
|
45
46
|
end
|
|
@@ -5,9 +5,12 @@ module Gemsmith
|
|
|
5
5
|
module Actions
|
|
6
6
|
# Handles the config action.
|
|
7
7
|
class Config
|
|
8
|
-
|
|
8
|
+
include Gemsmith::Import[:kernel, :logger]
|
|
9
|
+
|
|
10
|
+
def initialize client: Configuration::Loader::CLIENT, **dependencies
|
|
11
|
+
super(**dependencies)
|
|
12
|
+
|
|
9
13
|
@client = client
|
|
10
|
-
@container = container
|
|
11
14
|
end
|
|
12
15
|
|
|
13
16
|
def call selection
|
|
@@ -20,15 +23,11 @@ module Gemsmith
|
|
|
20
23
|
|
|
21
24
|
private
|
|
22
25
|
|
|
23
|
-
attr_reader :client
|
|
26
|
+
attr_reader :client
|
|
24
27
|
|
|
25
28
|
def edit = kernel.system("$EDITOR #{client.current}")
|
|
26
29
|
|
|
27
30
|
def view = kernel.system("cat #{client.current}")
|
|
28
|
-
|
|
29
|
-
def kernel = container[__method__]
|
|
30
|
-
|
|
31
|
-
def logger = container[__method__]
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
33
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "dry/container"
|
|
4
|
+
|
|
5
|
+
module Gemsmith
|
|
6
|
+
module CLI
|
|
7
|
+
module Actions
|
|
8
|
+
# Provides a single container with application and action specific dependencies.
|
|
9
|
+
module Container
|
|
10
|
+
extend Dry::Container::Mixin
|
|
11
|
+
|
|
12
|
+
config.registry = ->(container, key, value, _options) { container[key.to_s] = value }
|
|
13
|
+
|
|
14
|
+
merge Gemsmith::Container
|
|
15
|
+
|
|
16
|
+
register(:config) { Config.new }
|
|
17
|
+
register(:build) { Build.new }
|
|
18
|
+
register(:install) { Install.new }
|
|
19
|
+
register(:publish) { Publish.new }
|
|
20
|
+
register(:edit) { Edit.new }
|
|
21
|
+
register(:view) { View.new }
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -8,12 +8,14 @@ module Gemsmith
|
|
|
8
8
|
module Actions
|
|
9
9
|
# Handles the edit action for editing an installed gem.
|
|
10
10
|
class Edit
|
|
11
|
+
include Gemsmith::Import[:kernel, :logger]
|
|
11
12
|
include Dry::Monads[:result]
|
|
12
13
|
|
|
13
|
-
def initialize picker: Spek::Picker, editor: Tools::Editor.new,
|
|
14
|
+
def initialize picker: Spek::Picker, editor: Tools::Editor.new, **dependencies
|
|
15
|
+
super(**dependencies)
|
|
16
|
+
|
|
14
17
|
@picker = picker
|
|
15
18
|
@editor = editor
|
|
16
|
-
@container = container
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def call gem_name
|
|
@@ -26,13 +28,9 @@ module Gemsmith
|
|
|
26
28
|
|
|
27
29
|
private
|
|
28
30
|
|
|
29
|
-
attr_reader :picker, :editor
|
|
31
|
+
attr_reader :picker, :editor
|
|
30
32
|
|
|
31
33
|
def error(&) = logger.error(&)
|
|
32
|
-
|
|
33
|
-
def kernel = container[__method__]
|
|
34
|
-
|
|
35
|
-
def logger = container[__method__]
|
|
36
34
|
end
|
|
37
35
|
end
|
|
38
36
|
end
|
|
@@ -8,12 +8,14 @@ module Gemsmith
|
|
|
8
8
|
module Actions
|
|
9
9
|
# Handles the install action.
|
|
10
10
|
class Install
|
|
11
|
+
include Gemsmith::Import[:logger]
|
|
11
12
|
include Dry::Monads[:result]
|
|
12
13
|
|
|
13
|
-
def initialize installer: Tools::Installer.new, loader: Spek::Loader,
|
|
14
|
+
def initialize installer: Tools::Installer.new, loader: Spek::Loader, **dependencies
|
|
15
|
+
super(**dependencies)
|
|
16
|
+
|
|
14
17
|
@installer = installer
|
|
15
18
|
@loader = loader
|
|
16
|
-
@container = container
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def call configuration
|
|
@@ -26,11 +28,9 @@ module Gemsmith
|
|
|
26
28
|
|
|
27
29
|
private
|
|
28
30
|
|
|
29
|
-
attr_reader :installer, :loader
|
|
31
|
+
attr_reader :installer, :loader
|
|
30
32
|
|
|
31
33
|
def error(&) = logger.error(&)
|
|
32
|
-
|
|
33
|
-
def logger = container[__method__]
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
end
|
|
@@ -8,12 +8,14 @@ module Gemsmith
|
|
|
8
8
|
module Actions
|
|
9
9
|
# Handles the publish action.
|
|
10
10
|
class Publish
|
|
11
|
+
include Gemsmith::Import[:logger]
|
|
11
12
|
include Dry::Monads[:result]
|
|
12
13
|
|
|
13
|
-
def initialize publisher: Tools::Publisher.new, loader: Spek::Loader,
|
|
14
|
+
def initialize publisher: Tools::Publisher.new, loader: Spek::Loader, **dependencies
|
|
15
|
+
super(**dependencies)
|
|
16
|
+
|
|
14
17
|
@publisher = publisher
|
|
15
18
|
@loader = loader
|
|
16
|
-
@container = container
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def call configuration
|
|
@@ -26,11 +28,9 @@ module Gemsmith
|
|
|
26
28
|
|
|
27
29
|
private
|
|
28
30
|
|
|
29
|
-
attr_reader :publisher, :loader
|
|
31
|
+
attr_reader :publisher, :loader
|
|
30
32
|
|
|
31
33
|
def error(&) = logger.error(&)
|
|
32
|
-
|
|
33
|
-
def logger = container[__method__]
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
end
|
|
@@ -8,12 +8,14 @@ module Gemsmith
|
|
|
8
8
|
module Actions
|
|
9
9
|
# Handles the view action for viewing an installed gem in default browser.
|
|
10
10
|
class View
|
|
11
|
+
include Gemsmith::Import[:kernel, :logger]
|
|
11
12
|
include Dry::Monads[:result]
|
|
12
13
|
|
|
13
|
-
def initialize picker: Spek::Picker, viewer: Tools::Viewer.new,
|
|
14
|
+
def initialize picker: Spek::Picker, viewer: Tools::Viewer.new, **dependencies
|
|
15
|
+
super(**dependencies)
|
|
16
|
+
|
|
14
17
|
@picker = picker
|
|
15
18
|
@viewer = viewer
|
|
16
|
-
@container = container
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def call gem_name
|
|
@@ -26,13 +28,9 @@ module Gemsmith
|
|
|
26
28
|
|
|
27
29
|
private
|
|
28
30
|
|
|
29
|
-
attr_reader :picker, :viewer
|
|
31
|
+
attr_reader :picker, :viewer
|
|
30
32
|
|
|
31
33
|
def error(&) = logger.error(&)
|
|
32
|
-
|
|
33
|
-
def kernel = container[__method__]
|
|
34
|
-
|
|
35
|
-
def logger = container[__method__]
|
|
36
34
|
end
|
|
37
35
|
end
|
|
38
36
|
end
|
data/lib/gemsmith/cli/parser.rb
CHANGED
|
@@ -6,28 +6,32 @@ module Gemsmith
|
|
|
6
6
|
module CLI
|
|
7
7
|
# Assembles and parses all Command Line Interface (CLI) options.
|
|
8
8
|
class Parser
|
|
9
|
+
include Import[:configuration]
|
|
10
|
+
|
|
9
11
|
CLIENT = OptionParser.new nil, 40, " "
|
|
10
12
|
|
|
11
13
|
# Order is important.
|
|
12
14
|
SECTIONS = [Parsers::Core, Rubysmith::CLI::Parsers::Build, Parsers::Build].freeze
|
|
13
15
|
|
|
14
|
-
def initialize sections: SECTIONS, client: CLIENT,
|
|
16
|
+
def initialize sections: SECTIONS, client: CLIENT, **dependencies
|
|
17
|
+
super(**dependencies)
|
|
18
|
+
|
|
15
19
|
@sections = sections
|
|
16
20
|
@client = client
|
|
17
|
-
@
|
|
21
|
+
@configuration_duplicate = configuration.dup
|
|
18
22
|
end
|
|
19
23
|
|
|
20
24
|
def call arguments = []
|
|
21
|
-
sections.each { |section| section.call
|
|
25
|
+
sections.each { |section| section.call configuration_duplicate, client: }
|
|
22
26
|
client.parse arguments
|
|
23
|
-
|
|
27
|
+
configuration_duplicate.freeze
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
def to_s = client.to_s
|
|
27
31
|
|
|
28
32
|
private
|
|
29
33
|
|
|
30
|
-
attr_reader :sections, :client, :
|
|
34
|
+
attr_reader :sections, :client, :configuration_duplicate
|
|
31
35
|
end
|
|
32
36
|
end
|
|
33
37
|
end
|
|
@@ -7,16 +7,20 @@ module Gemsmith
|
|
|
7
7
|
module Parsers
|
|
8
8
|
# Handles parsing of Command Line Interface (CLI) build options.
|
|
9
9
|
class Build
|
|
10
|
+
include Import[:colorizer]
|
|
11
|
+
|
|
10
12
|
using Refinements::Structs
|
|
11
13
|
|
|
12
14
|
def self.call(...) = new(...).call
|
|
13
15
|
|
|
14
16
|
def initialize configuration = Container[:configuration],
|
|
15
17
|
client: Parser::CLIENT,
|
|
16
|
-
|
|
18
|
+
**dependencies
|
|
19
|
+
|
|
20
|
+
super(**dependencies)
|
|
21
|
+
|
|
17
22
|
@configuration = configuration
|
|
18
23
|
@client = client
|
|
19
|
-
@container = container
|
|
20
24
|
end
|
|
21
25
|
|
|
22
26
|
def call arguments = []
|
|
@@ -27,7 +31,7 @@ module Gemsmith
|
|
|
27
31
|
|
|
28
32
|
private
|
|
29
33
|
|
|
30
|
-
attr_reader :configuration, :client
|
|
34
|
+
attr_reader :configuration, :client
|
|
31
35
|
|
|
32
36
|
def add_cli
|
|
33
37
|
client.on(
|
|
@@ -46,8 +50,6 @@ module Gemsmith
|
|
|
46
50
|
.then { |boolean| boolean ? colorizer.green(boolean) : colorizer.red(boolean) }
|
|
47
51
|
.then { |colored_boolean| "Default: #{colored_boolean}" }
|
|
48
52
|
end
|
|
49
|
-
|
|
50
|
-
def colorizer = container[__method__]
|
|
51
53
|
end
|
|
52
54
|
end
|
|
53
55
|
end
|
|
@@ -8,16 +8,19 @@ module Gemsmith
|
|
|
8
8
|
module Parsers
|
|
9
9
|
# Handles parsing of Command Line Interface (CLI) core options.
|
|
10
10
|
class Core
|
|
11
|
+
include Import[:specification]
|
|
12
|
+
|
|
11
13
|
using Refinements::Structs
|
|
12
14
|
|
|
13
15
|
def self.call(...) = new(...).call
|
|
14
16
|
|
|
15
17
|
def initialize configuration = Container[:configuration],
|
|
16
18
|
client: Parser::CLIENT,
|
|
17
|
-
|
|
19
|
+
**dependencies
|
|
20
|
+
super(**dependencies)
|
|
21
|
+
|
|
18
22
|
@configuration = configuration
|
|
19
23
|
@client = client
|
|
20
|
-
@container = container
|
|
21
24
|
end
|
|
22
25
|
|
|
23
26
|
def call arguments = []
|
|
@@ -30,7 +33,7 @@ module Gemsmith
|
|
|
30
33
|
|
|
31
34
|
private
|
|
32
35
|
|
|
33
|
-
attr_reader :configuration, :client
|
|
36
|
+
attr_reader :configuration, :client
|
|
34
37
|
|
|
35
38
|
def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
|
|
36
39
|
|
|
@@ -86,8 +89,6 @@ module Gemsmith
|
|
|
86
89
|
configuration.merge! action_help: true
|
|
87
90
|
end
|
|
88
91
|
end
|
|
89
|
-
|
|
90
|
-
def specification = container[__method__]
|
|
91
92
|
end
|
|
92
93
|
end
|
|
93
94
|
end
|