gemsmith 16.2.0 → 18.0.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 +134 -214
- data/README.adoc +63 -23
- data/gemsmith.gemspec +8 -7
- data/lib/gemsmith/builders/circle_ci.rb +35 -0
- data/lib/gemsmith/builders/cli.rb +15 -7
- data/lib/gemsmith/builders/git/commit.rb +6 -5
- data/lib/gemsmith/cli/actions/build.rb +2 -1
- 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 +5 -2
- data/lib/gemsmith/templates/%project_name%/exe/%project_name%.erb +1 -1
- 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 +4 -4
- data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/parser_spec.rb.erb +2 -2
- data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/parsers/core_spec.rb.erb +2 -2
- data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb +17 -14
- data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/configuration/content_spec.rb.erb +1 -1
- data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/configuration/loader_spec.rb.erb +3 -3
- data/lib/gemsmith/templates/%project_name%/spec/support/shared_contexts/application_dependencies.rb.erb +21 -0
- data/lib/gemsmith/templates/%project_name%/spec/support/shared_examples/a_parser.rb.erb +1 -1
- 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 +54 -37
- metadata.gz.sig +0 -0
- data/lib/gemsmith/gems/finder.rb +0 -23
- data/lib/gemsmith/gems/loader.rb +0 -23
- data/lib/gemsmith/gems/picker.rb +0 -45
- data/lib/gemsmith/gems/presenter.rb +0 -52
- data/lib/gemsmith/templates/%project_name%/spec/support/shared_contexts/application_container.rb.erb +0 -22
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "refinements/structs"
|
4
|
+
|
5
|
+
module Gemsmith
|
6
|
+
module Builders
|
7
|
+
# Builds project skeleton Circle CI configuration.
|
8
|
+
class CircleCI
|
9
|
+
using Refinements::Structs
|
10
|
+
|
11
|
+
def self.call(...) = new(...).call
|
12
|
+
|
13
|
+
def initialize configuration, builder: Rubysmith::Builder
|
14
|
+
@configuration = configuration
|
15
|
+
@builder = builder
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
19
|
+
return configuration unless configuration.build_circle_ci
|
20
|
+
|
21
|
+
builder.call(configuration.merge(template_path: "%project_name%/.circleci/config.yml.erb"))
|
22
|
+
.replace %({{checksum "Gemfile.lock"}}),
|
23
|
+
%({{checksum "Gemfile"}}-{{checksum "#{project_name}.gemspec"}})
|
24
|
+
|
25
|
+
configuration
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :configuration, :builder
|
31
|
+
|
32
|
+
def project_name = configuration.project_name
|
33
|
+
end
|
34
|
+
end
|
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
|
@@ -24,6 +24,7 @@ module Gemsmith
|
|
24
24
|
Rubysmith::Builders::Rake,
|
25
25
|
Rubysmith::Builders::Console,
|
26
26
|
Rubysmith::Builders::CircleCI,
|
27
|
+
Builders::CircleCI,
|
27
28
|
Rubysmith::Builders::Setup,
|
28
29
|
Rubysmith::Builders::GitHub,
|
29
30
|
Rubysmith::Builders::Guard,
|
@@ -31,7 +32,7 @@ module Gemsmith
|
|
31
32
|
Rubysmith::Builders::RSpec::Context,
|
32
33
|
Rubysmith::Builders::RSpec::Helper,
|
33
34
|
Builders::RSpec::Helper,
|
34
|
-
Rubysmith::Builders::
|
35
|
+
Rubysmith::Builders::Caliber,
|
35
36
|
Rubysmith::Extensions::Bundler,
|
36
37
|
Rubysmith::Extensions::Pragmater,
|
37
38
|
Rubysmith::Extensions::Tocer,
|
@@ -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
|
data/lib/gemsmith/cli/shell.rb
CHANGED
@@ -4,19 +4,20 @@ module Gemsmith
|
|
4
4
|
module CLI
|
5
5
|
# The main Command Line Interface (CLI) object.
|
6
6
|
class Shell
|
7
|
-
|
8
|
-
config
|
9
|
-
build
|
10
|
-
install
|
11
|
-
publish
|
12
|
-
edit
|
13
|
-
view
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
include Actions::Import[
|
8
|
+
:config,
|
9
|
+
:build,
|
10
|
+
:install,
|
11
|
+
:publish,
|
12
|
+
:edit,
|
13
|
+
:view,
|
14
|
+
:specification,
|
15
|
+
:logger
|
16
|
+
]
|
17
|
+
|
18
|
+
def initialize parser: Parser.new, **dependencies
|
19
|
+
super(**dependencies)
|
17
20
|
@parser = parser
|
18
|
-
@actions = actions
|
19
|
-
@container = container
|
20
21
|
end
|
21
22
|
|
22
23
|
def call arguments = []
|
@@ -27,40 +28,20 @@ module Gemsmith
|
|
27
28
|
|
28
29
|
private
|
29
30
|
|
30
|
-
attr_reader :parser
|
31
|
+
attr_reader :parser
|
31
32
|
|
32
33
|
def perform configuration
|
33
34
|
case configuration
|
34
|
-
in action_config: Symbol => action then config action
|
35
|
-
in action_build: true then build configuration
|
36
|
-
in action_install: true then install configuration
|
37
|
-
in action_publish: true then publish configuration
|
38
|
-
in action_edit: String => gem_name then edit gem_name
|
39
|
-
in action_view: String => gem_name then view gem_name
|
35
|
+
in action_config: Symbol => action then config.call action
|
36
|
+
in action_build: true then build.call configuration
|
37
|
+
in action_install: true then install.call configuration
|
38
|
+
in action_publish: true then publish.call configuration
|
39
|
+
in action_edit: String => gem_name then edit.call gem_name
|
40
|
+
in action_view: String => gem_name then view.call gem_name
|
40
41
|
in action_version: true then logger.info { specification.labeled_version }
|
41
|
-
else
|
42
|
+
else logger.any { parser.to_s }
|
42
43
|
end
|
43
44
|
end
|
44
|
-
|
45
|
-
def config(action) = actions.fetch(__method__).call(action)
|
46
|
-
|
47
|
-
def build(configuration) = actions.fetch(__method__).call(configuration)
|
48
|
-
|
49
|
-
def install(configuration) = actions.fetch(__method__).call(configuration)
|
50
|
-
|
51
|
-
def publish(configuration) = actions.fetch(__method__).call(configuration)
|
52
|
-
|
53
|
-
def edit(gem_name) = actions.fetch(__method__).call(gem_name)
|
54
|
-
|
55
|
-
def view(gem_name) = actions.fetch(__method__).call(gem_name)
|
56
|
-
|
57
|
-
def usage = logger.unknown { parser.to_s }
|
58
|
-
|
59
|
-
def logger = container[__method__]
|
60
|
-
|
61
|
-
def specification = container[__method__]
|
62
|
-
|
63
|
-
def process = container[__method__]
|
64
45
|
end
|
65
46
|
end
|
66
47
|
end
|
data/lib/gemsmith/container.rb
CHANGED
@@ -22,6 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
<% end %>
|
23
23
|
|
24
24
|
spec.required_ruby_version = "~> <%= RUBY_VERSION[/\d+\.\d+/] %>"
|
25
|
+
<% if configuration.build_cli %>
|
26
|
+
spec.add_dependency "auto_injector", "~> 0.4"
|
27
|
+
<% end %>
|
25
28
|
<% if configuration.build_cli %>
|
26
29
|
spec.add_dependency "dry-container", "~> 0.9"
|
27
30
|
<% end %>
|
@@ -29,13 +32,13 @@ Gem::Specification.new do |spec|
|
|
29
32
|
spec.add_dependency "pastel", "~> 0.8"
|
30
33
|
<% end %>
|
31
34
|
<% if configuration.build_refinements %>
|
32
|
-
spec.add_dependency "refinements", "~> 9.
|
35
|
+
spec.add_dependency "refinements", "~> 9.2"
|
33
36
|
<% end %>
|
34
37
|
<% if configuration.build_cli %>
|
35
38
|
spec.add_dependency "runcom", "~> 8.2"
|
36
39
|
<% end %>
|
37
40
|
<% if configuration.build_cli %>
|
38
|
-
spec.add_dependency "spek", "~> 0.
|
41
|
+
spec.add_dependency "spek", "~> 0.2"
|
39
42
|
<% end %>
|
40
43
|
<% if configuration.build_zeitwerk %>
|
41
44
|
spec.add_dependency "zeitwerk", "~> 2.5"
|
@@ -1,13 +1,14 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
<% namespace do %>
|
4
2
|
module CLI
|
5
3
|
module Actions
|
6
4
|
# Handles the config action.
|
7
5
|
class Config
|
8
|
-
|
6
|
+
include <%= configuration.project_class %>::Import[:kernel, :logger]
|
7
|
+
|
8
|
+
def initialize client: Configuration::Loader::CLIENT, **dependencies
|
9
|
+
super(**dependencies)
|
10
|
+
|
9
11
|
@client = client
|
10
|
-
@container = container
|
11
12
|
end
|
12
13
|
|
13
14
|
def call selection
|
@@ -20,15 +21,11 @@
|
|
20
21
|
|
21
22
|
private
|
22
23
|
|
23
|
-
attr_reader :client
|
24
|
+
attr_reader :client
|
24
25
|
|
25
26
|
def edit = kernel.system("$EDITOR #{client.current}")
|
26
27
|
|
27
28
|
def view = kernel.system("cat #{client.current}")
|
28
|
-
|
29
|
-
def kernel = container[__method__]
|
30
|
-
|
31
|
-
def logger = container[__method__]
|
32
29
|
end
|
33
30
|
end
|
34
31
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "dry/container"
|
2
|
+
|
3
|
+
<% namespace do %>
|
4
|
+
module CLI
|
5
|
+
module Actions
|
6
|
+
# Provides a single container of application and action specific dependencies.
|
7
|
+
module Container
|
8
|
+
extend Dry::Container::Mixin
|
9
|
+
|
10
|
+
config.registry = ->(container, key, value, _options) { container[key.to_s] = value }
|
11
|
+
|
12
|
+
merge <%= configuration.project_namespaced_class %>::Container
|
13
|
+
|
14
|
+
register(:config) { Config.new }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
<% end %>
|