gemsmith 17.0.1 → 18.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.adoc +58 -28
  4. data/gemsmith.gemspec +5 -4
  5. data/lib/gemsmith/builders/circle_ci.rb +4 -1
  6. data/lib/gemsmith/builders/cli.rb +15 -7
  7. data/lib/gemsmith/builders/git/commit.rb +6 -5
  8. data/lib/gemsmith/cli/actions/config.rb +6 -7
  9. data/lib/gemsmith/cli/actions/container.rb +25 -0
  10. data/lib/gemsmith/cli/actions/edit.rb +5 -7
  11. data/lib/gemsmith/cli/actions/import.rb +11 -0
  12. data/lib/gemsmith/cli/actions/install.rb +5 -5
  13. data/lib/gemsmith/cli/actions/publish.rb +5 -5
  14. data/lib/gemsmith/cli/actions/view.rb +5 -7
  15. data/lib/gemsmith/cli/parser.rb +9 -5
  16. data/lib/gemsmith/cli/parsers/build.rb +7 -5
  17. data/lib/gemsmith/cli/parsers/core.rb +6 -5
  18. data/lib/gemsmith/cli/shell.rb +21 -40
  19. data/lib/gemsmith/container.rb +1 -1
  20. data/lib/gemsmith/import.rb +7 -0
  21. data/lib/gemsmith/templates/%project_name%/%project_name%.gemspec.erb +3 -0
  22. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/actions/config.rb.erb +6 -9
  23. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/actions/container.rb.erb +18 -0
  24. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/actions/import.rb.erb +9 -0
  25. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/parser.rb.erb +9 -5
  26. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/parsers/core.rb.erb +6 -5
  27. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/shell.rb.erb +6 -15
  28. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/container.rb.erb +3 -25
  29. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/import.rb.erb +5 -0
  30. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/actions/config_spec.rb.erb +3 -3
  31. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/parser_spec.rb.erb +1 -1
  32. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/parsers/core_spec.rb.erb +1 -1
  33. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb +16 -13
  34. data/lib/gemsmith/templates/%project_name%/spec/support/shared_contexts/application_dependencies.rb.erb +21 -0
  35. data/lib/gemsmith/tools/editor.rb +2 -9
  36. data/lib/gemsmith/tools/installer.rb +5 -5
  37. data/lib/gemsmith/tools/pusher.rb +23 -5
  38. data/lib/gemsmith/tools/validator.rb +1 -10
  39. data/lib/gemsmith/tools/versioner.rb +6 -6
  40. data/lib/gemsmith/tools/viewer.rb +1 -10
  41. data.tar.gz.sig +0 -0
  42. metadata +48 -28
  43. metadata.gz.sig +0 -0
  44. 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: 4f37d4347b54a5dd52f7aa24d649a94566f7eee546fe25eacd74084b0157029c
4
- data.tar.gz: a4f23dfa0c5c5d1588508a1e0f4aa7f81408102d9903b6abe0f6f1b60e2c8164
3
+ metadata.gz: 7078991f9fcbcb707c47a3bbc7fb390725c3048c26de414728624f01a5a42a9e
4
+ data.tar.gz: aefb802ad6d7e39a454c553b40921c596c5000adee42e14f5e195eafcda95e0b
5
5
  SHA512:
6
- metadata.gz: 7ef45d382883ca6064a343aae7a16932c529a6761a2d6ecb927d63c52df6c5dc28a026e85317b6fbb161572771f8e36a01860ae14320ecd460b042111eb1aa08
7
- data.tar.gz: a7ddacd605e91f3a5de61b83acc4aba91e09db226554c255ccf3d5014ffe47a7f029070b539bd5b0e38cb4a68d4daece6cc92f5955e4621fd77fa74acc2ca229
6
+ metadata.gz: 66f5dbee7fd91d463f89b8e95819eac28af1ee9af66bc1314d32103cd085a238c6dd8c8e7011e02ef588781f9397e3db3aacfb35b03a545f3e1fc67ea2591a6a
7
+ data.tar.gz: fd91bff49d27af059de47ace1aafacc50b0a4e7938e1b8627f5cb6b856498a64fab0bb4bcf4cbec47a339bf54f09d52e1d18788bc47bdaf849f615c5f83a6f0c
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 features provided by link:https://www.alchemists.io/projects/rubysmith[Rubysmith]
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 16.0.0 to 17.0.0, you'll need to make the following changes:
39
+ If upgrading from 17.0.0 to 18.0.0, you'll want to be aware of the following changes:
41
40
 
42
- * README badges are no longer injected so you can customize as desired.
43
- * The `:rubocop:` build configuration has been removed. Use `:caliber:` instead.
44
- * The `--rubocop` build option has been removed. Use `--caliber` instead.
45
- * You no longer have to Git ignore RuboCop cached configurations since this is handled by the
46
- link:https://www.alchemists.io/projects/caliber[Caliber] gem now.
41
+ * The `--dead_end` build option has been removed.
42
+ * The Milestoner configuraition 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, which is unique to Gemsmith, is the `--cli` option. This allows you to build a gem
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
@@ -301,7 +298,8 @@ link:https://guides.rubygems.org/security[Security].
301
298
 
302
299
  == Private Gem Servers
303
300
 
304
- By default, the following Rake task will publish your gem to link:https://rubygems.org[RubyGems]:
301
+ By default, the following command will publicly publish your gem to
302
+ link:https://rubygems.org[RubyGems]:
305
303
 
306
304
  [source,bash]
307
305
  ----
@@ -319,20 +317,19 @@ Add the following metadata to your gemspec:
319
317
  [source,ruby]
320
318
  ----
321
319
  Gem::Specification.new do |spec|
322
- spec.metadata = {
323
- "allowed_push_key" => "example_key",
324
- "allowed_push_host" => "https://gems.example.com"
325
- }
320
+ spec.metadata = {"allowed_push_host" => "https://private.example.com"}
326
321
  end
327
322
  ----
328
323
 
329
- The gemspec metadata keys and values _must_ be strings per the
330
- link:https://guides.rubygems.org/specification-reference/#metadata[RubyGems Specification]. Each key
331
- represents the following:
324
+ 💡 The gemspec metadata _must_ be strings per the
325
+ link:https://guides.rubygems.org/specification-reference/#metadata[RubyGems Specification].
332
326
 
333
- * `allowed_push_key`: Provides a reference (look up) to the key defined the RubyGems credentials
334
- file so that sensitive credentials are not used within your gemspec.
335
- * `allowed_push_host`: Provides the URL of the private gem server to push your gem to.
327
+ Use of the `allowed_push_host` key provides two important capabilities:
328
+
329
+ * Prevents you from accidentally publishing your private gem to the public RubyGems server (default
330
+ behavior).
331
+ * Defines the lookup key in your `$HOME/.gem/credentials` file which contains your private
332
+ credentials for authentication to your private server (more on this below).
336
333
 
337
334
  === Gem Credentials
338
335
 
@@ -340,18 +337,52 @@ With your gem specification metadata established, you are ready to publish your
340
337
  private server. If this is your first time publishing a gem and no gem credentials have been
341
338
  configured, you'll be prompted for them. Gem credentials are stored in the RubyGems
342
339
  `$HOME/.gem/credentials` file. From this point forward, future gem publishing will use your stored
343
- credentials instead. Multiple credentials can be stored in the `$HOME/.gem/credentials` file.
344
- Example:
340
+ credentials instead.
341
+
342
+ Multiple credentials can be stored in the `$HOME/.gem/credentials` file as well. Example:
345
343
 
346
344
  [source,yaml]
347
345
  ----
348
346
  :rubygems_api_key: 2a0b460650e67d9b85a60e183defa376
349
- :some_custom_key: "Basic dXNlcjpwYXNzd29yZA=="
347
+ https://private.example.com: Basic dXNlcjpwYXNzd29yZA==
348
+ ----
349
+
350
+ Notice how the first line contains credentials for the public RubyGems server while the second line
351
+ is for our private example server. You'll also notice that the key is not a symbol but a URL string
352
+ to our private server. This is important as this is how we link our gem specification metadata to
353
+ our private credentials. To illustrate further, here are both files truncated and shown together:
354
+
355
+ ....
356
+ # Gem specificaiton metadata which defines the private host to publish to.
357
+ spec.metadata = {"allowed_push_host" => "https://private.example.com"}
358
+
359
+ # Gem credentials where the URL value above becomes the key which enables authentication.
360
+ https://private.example.com: Basic dXNlcjpwYXNzd29yZA==
361
+ ....
362
+
363
+ When the above are linked together like this, you enable Gemsmith to publish your gem using only the
364
+ following command:
365
+
366
+ [source,bash]
350
367
  ----
368
+ gemsmith --publish
369
+ ----
370
+
371
+ This is especially powerful when publishing to
372
+ link:https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-rubygems-registry[GitHub's
373
+ Packages registory] which would look like this when properly configured (truncated for brevity):
374
+
375
+ ....
376
+ # Gem specification
377
+ spec.metadata = {"allowed_push_host" => "https://rubygems.pkg.github.com/alchemists"}
378
+
379
+ # Gem credentials
380
+ https://rubygems.pkg.github.com/alchemists: Bearer ghp_c5b8d394abefebbf45c7b27b379c74978923
381
+ ....
351
382
 
352
- Should you need to delete a credential (due to a bad login/password for example), you can open the
353
- `$HOME/.gem/credentials` in your default editor and remove the line(s) you don't need. Upon next
354
- publish of your gem, you'll be prompted for the missing credentials.
383
+ Lastly, should you need to delete a credential (due to a bad login/password for example), you can
384
+ open the `$HOME/.gem/credentials` in your default editor and remove the line(s) you don't need. Upon
385
+ next publish of your gem, you'll be prompted for the missing credentials.
355
386
 
356
387
  == Promotion
357
388
 
@@ -359,7 +390,6 @@ Once your gem is released, let the world know about your accomplishment by posti
359
390
  these sites:
360
391
 
361
392
  * link:https://rubyflow.com[RubyFlow]
362
- * link:https://rubyradar.dev[Ruby Radar]
363
393
  * link:https://ruby.libhunt.com[Ruby Library Hunt]
364
394
  * link:https://rubydaily.org[RubyDaily]
365
395
  * 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 = "17.0.1"
5
+ spec.version = "18.0.0"
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", "~> 13.3"
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", "~> 2.0"
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", "#{configuration.project_name}.gemspec")
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 render_library
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/application_container.rb.erb",
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, container: Container
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, :container
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
- def initialize client: Configuration::Loader::CLIENT, container: Container
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, :container
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, container: Container
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, :container
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
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "auto_injector"
4
+
5
+ module Gemsmith
6
+ module CLI
7
+ module Actions
8
+ Import = AutoInjector[Container]
9
+ end
10
+ end
11
+ 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, container: Container
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, :container
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, container: Container
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, :container
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, container: Container
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, :container
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
@@ -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, container: Container
16
+ def initialize sections: SECTIONS, client: CLIENT, **dependencies
17
+ super(**dependencies)
18
+
15
19
  @sections = sections
16
20
  @client = client
17
- @configuration = container[:configuration].dup
21
+ @configuration_duplicate = configuration.dup
18
22
  end
19
23
 
20
24
  def call arguments = []
21
- sections.each { |section| section.call configuration, client: }
25
+ sections.each { |section| section.call configuration_duplicate, client: }
22
26
  client.parse arguments
23
- configuration.freeze
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, :configuration
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
- container: Container
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, :container
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
- container: Container
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, :container
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