gemsmith 17.0.1 → 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/README.adoc +58 -28
- 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 +3 -0
- 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
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 %>
|
@@ -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 %>
|
@@ -4,28 +4,32 @@ require "optparse"
|
|
4
4
|
module CLI
|
5
5
|
# Assembles and parses all Command Line Interface (CLI) options.
|
6
6
|
class Parser
|
7
|
+
include Import[:configuration]
|
8
|
+
|
7
9
|
CLIENT = OptionParser.new nil, 40, " "
|
8
10
|
|
9
11
|
# Order is important.
|
10
12
|
SECTIONS = [Parsers::Core].freeze
|
11
13
|
|
12
|
-
def initialize sections: SECTIONS, client: CLIENT,
|
14
|
+
def initialize sections: SECTIONS, client: CLIENT, **dependencies
|
15
|
+
super(**dependencies)
|
16
|
+
|
13
17
|
@sections = sections
|
14
18
|
@client = client
|
15
|
-
@
|
19
|
+
@configuration_duplicate = configuration.dup
|
16
20
|
end
|
17
21
|
|
18
22
|
def call arguments = []
|
19
|
-
sections.each { |section| section.call
|
23
|
+
sections.each { |section| section.call configuration_duplicate, client: }
|
20
24
|
client.parse arguments
|
21
|
-
|
25
|
+
configuration_duplicate.freeze
|
22
26
|
end
|
23
27
|
|
24
28
|
def to_s = client.to_s
|
25
29
|
|
26
30
|
private
|
27
31
|
|
28
|
-
attr_reader :sections, :client, :
|
32
|
+
attr_reader :sections, :client, :configuration_duplicate
|
29
33
|
end
|
30
34
|
end
|
31
35
|
<% end %>
|
@@ -5,16 +5,19 @@ require "refinements/structs"
|
|
5
5
|
module Parsers
|
6
6
|
# Handles parsing of Command Line Interface (CLI) core options.
|
7
7
|
class Core
|
8
|
+
include Import[:specification]
|
9
|
+
|
8
10
|
using Refinements::Structs
|
9
11
|
|
10
12
|
def self.call(...) = new(...).call
|
11
13
|
|
12
14
|
def initialize configuration = Container[:configuration],
|
13
15
|
client: Parser::CLIENT,
|
14
|
-
|
16
|
+
**dependencies
|
17
|
+
|
18
|
+
super(**dependencies)
|
15
19
|
@configuration = configuration
|
16
20
|
@client = client
|
17
|
-
@container = container
|
18
21
|
end
|
19
22
|
|
20
23
|
def call arguments = []
|
@@ -27,7 +30,7 @@ require "refinements/structs"
|
|
27
30
|
|
28
31
|
private
|
29
32
|
|
30
|
-
attr_reader :configuration, :client
|
33
|
+
attr_reader :configuration, :client
|
31
34
|
|
32
35
|
def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
|
33
36
|
|
@@ -51,8 +54,6 @@ require "refinements/structs"
|
|
51
54
|
configuration.merge! action_help: true
|
52
55
|
end
|
53
56
|
end
|
54
|
-
|
55
|
-
def specification = container[__method__]
|
56
57
|
end
|
57
58
|
end
|
58
59
|
end
|
@@ -2,12 +2,11 @@
|
|
2
2
|
module CLI
|
3
3
|
# The main Command Line Interface (CLI) object.
|
4
4
|
class Shell
|
5
|
-
|
5
|
+
include Actions::Import[:config, :specification, :logger]
|
6
6
|
|
7
|
-
def initialize parser: Parser.new,
|
7
|
+
def initialize parser: Parser.new, **dependencies
|
8
|
+
super(**dependencies)
|
8
9
|
@parser = parser
|
9
|
-
@actions = actions
|
10
|
-
@container = container
|
11
10
|
end
|
12
11
|
|
13
12
|
def call arguments = []
|
@@ -18,23 +17,15 @@
|
|
18
17
|
|
19
18
|
private
|
20
19
|
|
21
|
-
attr_reader :parser
|
20
|
+
attr_reader :parser
|
22
21
|
|
23
22
|
def perform configuration
|
24
23
|
case configuration
|
25
|
-
in action_config: Symbol => action then config action
|
24
|
+
in action_config: Symbol => action then config.call action
|
26
25
|
in action_version: true then logger.info { specification.labeled_version }
|
27
|
-
else
|
26
|
+
else logger.any { parser.to_s }
|
28
27
|
end
|
29
28
|
end
|
30
|
-
|
31
|
-
def config(action) = actions.fetch(__method__).call(action)
|
32
|
-
|
33
|
-
def usage = logger.unknown { parser.to_s }
|
34
|
-
|
35
|
-
def specification = container[__method__]
|
36
|
-
|
37
|
-
def logger = container[__method__]
|
38
29
|
end
|
39
30
|
end
|
40
31
|
<% end %>
|
@@ -1,6 +1,5 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require "pastel"
|
1
|
+
require "cogger"
|
2
|
+
require "dry/container"
|
4
3
|
require "spek"
|
5
4
|
|
6
5
|
<% namespace do %>
|
@@ -10,28 +9,7 @@ require "spek"
|
|
10
9
|
|
11
10
|
register(:configuration) { Configuration::Loader.call }
|
12
11
|
register(:specification) { Spek::Loader.call "#{__dir__}/<%= Array.new(2 + configuration.project_levels, "../").join %><%= configuration.project_name %>.gemspec" }
|
13
|
-
register(:colorizer) { Pastel.new enabled: $stdout.tty? }
|
14
12
|
register(:kernel) { Kernel }
|
15
|
-
|
16
|
-
register :log_colors do
|
17
|
-
{
|
18
|
-
"DEBUG" => self[:colorizer].white.detach,
|
19
|
-
"INFO" => self[:colorizer].green.detach,
|
20
|
-
"WARN" => self[:colorizer].yellow.detach,
|
21
|
-
"ERROR" => self[:colorizer].red.detach,
|
22
|
-
"FATAL" => self[:colorizer].white.bold.on_red.detach,
|
23
|
-
"ANY" => self[:colorizer].white.bold.detach
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
register :logger do
|
28
|
-
Logger.new $stdout,
|
29
|
-
level: Logger.const_get(ENV.fetch("LOG_LEVEL", "INFO")),
|
30
|
-
formatter: (
|
31
|
-
lambda do |severity, _at, _name, message|
|
32
|
-
self[:log_colors][severity].call "#{message}\n"
|
33
|
-
end
|
34
|
-
)
|
35
|
-
end
|
13
|
+
register(:logger) { Cogger::Client.new }
|
36
14
|
end
|
37
15
|
<% end %>
|
data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/actions/config_spec.rb.erb
CHANGED
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
RSpec.describe <%= configuration.project_namespaced_class %>::CLI::Actions::Config do
|
4
4
|
subject(:action) { described_class.new }
|
5
5
|
|
6
|
-
include_context "with application
|
6
|
+
include_context "with application dependencies"
|
7
7
|
|
8
8
|
describe "#call" do
|
9
9
|
it "edits configuration" do
|
@@ -17,8 +17,8 @@ RSpec.describe <%= configuration.project_namespaced_class %>::CLI::Actions::Conf
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "logs invalid configuration" do
|
20
|
-
|
21
|
-
expect(
|
20
|
+
action.call :bogus
|
21
|
+
expect(logger.reread).to match(/Invalid configuration selection: bogus./)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
RSpec.describe <%= configuration.project_namespaced_class %>::CLI::Parser do
|
4
4
|
subject(:parser) { described_class.new }
|
5
5
|
|
6
|
-
include_context "with application
|
6
|
+
include_context "with application dependencies"
|
7
7
|
|
8
8
|
describe "#call" do
|
9
9
|
it "answers hash with valid option" do
|
data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/parsers/core_spec.rb.erb
CHANGED
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
RSpec.describe <%= configuration.project_namespaced_class %>::CLI::Parsers::Core do
|
4
4
|
subject(:parser) { described_class.new configuration.dup }
|
5
5
|
|
6
|
-
include_context "with application
|
6
|
+
include_context "with application dependencies"
|
7
7
|
|
8
8
|
it_behaves_like "a parser"
|
9
9
|
|
@@ -2,42 +2,45 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe <%= configuration.project_namespaced_class %>::CLI::Shell do
|
4
4
|
using Refinements::Pathnames
|
5
|
+
using AutoInjector::Stub
|
5
6
|
|
6
|
-
subject(:shell) { described_class.new
|
7
|
+
subject(:shell) { described_class.new }
|
7
8
|
|
8
|
-
include_context "with
|
9
|
+
include_context "with application dependencies"
|
9
10
|
|
10
|
-
|
11
|
+
before { <%= configuration.project_namespaced_class %>::CLI::Actions::Import.stub configuration:, kernel:, logger: }
|
12
|
+
|
13
|
+
after { <%= configuration.project_namespaced_class %>::CLI::Actions::Import.unstub :configuration, :kernel, :logger }
|
11
14
|
|
12
15
|
describe "#call" do
|
13
16
|
it "edits configuration" do
|
14
17
|
shell.call %w[--config edit]
|
15
|
-
expect(
|
18
|
+
expect(kernel).to have_received(:system).with("$EDITOR ")
|
16
19
|
end
|
17
20
|
|
18
21
|
it "views configuration" do
|
19
22
|
shell.call %w[--config view]
|
20
|
-
expect(
|
23
|
+
expect(kernel).to have_received(:system).with("cat ")
|
21
24
|
end
|
22
25
|
|
23
26
|
it "prints version" do
|
24
|
-
|
25
|
-
expect(
|
27
|
+
shell.call %w[--version]
|
28
|
+
expect(logger.reread).to match(/<%= configuration.project_label %>\s\d+\.\d+\.\d+/)
|
26
29
|
end
|
27
30
|
|
28
31
|
it "prints help (usage)" do
|
29
|
-
|
30
|
-
expect(
|
32
|
+
shell.call %w[--help]
|
33
|
+
expect(logger.reread).to match(/<%= configuration.project_label %>.+USAGE.+/m)
|
31
34
|
end
|
32
35
|
|
33
36
|
it "prints usage when no options are given" do
|
34
|
-
|
35
|
-
expect(
|
37
|
+
shell.call
|
38
|
+
expect(logger.reread).to match(/<%= configuration.project_label %>.+USAGE.+/m)
|
36
39
|
end
|
37
40
|
|
38
41
|
it "prints error with invalid option" do
|
39
|
-
|
40
|
-
expect(
|
42
|
+
shell.call %w[--bogus]
|
43
|
+
expect(logger.reread).to match(/invalid option.+bogus/)
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "dry/container/stub"
|
2
|
+
require "auto_injector/stub"
|
3
|
+
|
4
|
+
RSpec.shared_context "with application dependencies" do
|
5
|
+
using Refinements::Structs
|
6
|
+
using AutoInjector::Stub
|
7
|
+
|
8
|
+
include_context "with temporary directory"
|
9
|
+
|
10
|
+
let(:configuration) { <%= configuration.project_namespaced_class %>::Configuration::Loader.with_defaults.call }
|
11
|
+
let(:kernel) { class_spy Kernel }
|
12
|
+
|
13
|
+
let :logger do
|
14
|
+
Cogger::Client.new Logger.new(StringIO.new),
|
15
|
+
formatter: ->(_severity, _name, _at, message) { "#{message}\n" }
|
16
|
+
end
|
17
|
+
|
18
|
+
before { <%= configuration.project_namespaced_class %>::Import.stub configuration:, kernel:, logger: }
|
19
|
+
|
20
|
+
after { <%= configuration.project_namespaced_class %>::Import.unstub :configuration, :kernel, :logger }
|
21
|
+
end
|
@@ -6,12 +6,9 @@ module Gemsmith
|
|
6
6
|
module Tools
|
7
7
|
# Edits a gem within default editor.
|
8
8
|
class Editor
|
9
|
+
include Import[:executor, :environment]
|
9
10
|
include Dry::Monads[:result]
|
10
11
|
|
11
|
-
def initialize container: Container
|
12
|
-
@container = container
|
13
|
-
end
|
14
|
-
|
15
12
|
def call specification
|
16
13
|
executor.capture3(client, specification.source_path.to_s).then do |_stdout, stderr, status|
|
17
14
|
status.success? ? Success(specification) : Failure(stderr)
|
@@ -20,11 +17,7 @@ module Gemsmith
|
|
20
17
|
|
21
18
|
private
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
def executor = container[__method__]
|
26
|
-
|
27
|
-
def client = container[:environment].fetch("EDITOR")
|
20
|
+
def client = environment.fetch("EDITOR")
|
28
21
|
end
|
29
22
|
end
|
30
23
|
end
|
@@ -6,14 +6,16 @@ module Gemsmith
|
|
6
6
|
module Tools
|
7
7
|
# Installs a locally built gem.
|
8
8
|
class Installer
|
9
|
+
include Import[:executor]
|
9
10
|
include Dry::Monads[:result, :do]
|
10
11
|
|
11
12
|
# Order matters.
|
12
13
|
STEPS = [Tools::Cleaner.new, Tools::Packager.new].freeze
|
13
14
|
|
14
|
-
def initialize steps: STEPS,
|
15
|
+
def initialize steps: STEPS, **dependencies
|
16
|
+
super(**dependencies)
|
17
|
+
|
15
18
|
@steps = steps
|
16
|
-
@container = container
|
17
19
|
end
|
18
20
|
|
19
21
|
def call specification
|
@@ -23,7 +25,7 @@ module Gemsmith
|
|
23
25
|
|
24
26
|
private
|
25
27
|
|
26
|
-
attr_reader :steps
|
28
|
+
attr_reader :steps
|
27
29
|
|
28
30
|
def run specification
|
29
31
|
path = specification.package_path
|
@@ -32,8 +34,6 @@ module Gemsmith
|
|
32
34
|
status.success? ? Success(specification) : Failure("Unable to install: #{path}.")
|
33
35
|
end
|
34
36
|
end
|
35
|
-
|
36
|
-
def executor = container[__method__]
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -7,11 +7,13 @@ module Gemsmith
|
|
7
7
|
module Tools
|
8
8
|
# Pushes a gem package to remote gem server.
|
9
9
|
class Pusher
|
10
|
+
include Import[:executor, :logger]
|
10
11
|
include Dry::Monads[:result]
|
11
12
|
|
12
|
-
def initialize command: Gem::CommandManager.new,
|
13
|
+
def initialize command: Gem::CommandManager.new, **dependencies
|
14
|
+
super(**dependencies)
|
15
|
+
|
13
16
|
@command = command
|
14
|
-
@container = container
|
15
17
|
end
|
16
18
|
|
17
19
|
def call specification
|
@@ -23,14 +25,30 @@ module Gemsmith
|
|
23
25
|
|
24
26
|
private
|
25
27
|
|
26
|
-
attr_reader :command
|
28
|
+
attr_reader :command
|
27
29
|
|
30
|
+
# :reek:TooManyStatements
|
28
31
|
def one_time_password
|
29
|
-
|
32
|
+
return [] if check_yubikey.failure?
|
33
|
+
|
34
|
+
executor.capture3(check_yubikey.success, "oath", "accounts", "code", "--single", "RubyGems")
|
30
35
|
.then { |stdout, _stderr, status| status.success? ? ["--otp", stdout.chomp] : [] }
|
36
|
+
rescue Errno::ENOENT => error
|
37
|
+
logger.warn { "Unable to obtain YubiKey One-Time Password. #{error}." }
|
38
|
+
[]
|
31
39
|
end
|
32
40
|
|
33
|
-
def
|
41
|
+
def check_yubikey
|
42
|
+
executor.capture3("command", "-v", "ykman")
|
43
|
+
.then do |stdout, stderr, status|
|
44
|
+
if status.success?
|
45
|
+
Success stdout.chomp
|
46
|
+
else
|
47
|
+
logger.warn { "Unable to find YubiKey Manager. #{stderr}." }
|
48
|
+
Failure()
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
34
52
|
end
|
35
53
|
end
|
36
54
|
end
|
@@ -6,23 +6,14 @@ module Gemsmith
|
|
6
6
|
module Tools
|
7
7
|
# Validates whether a gem can be published or not.
|
8
8
|
class Validator
|
9
|
+
include Import[:executor]
|
9
10
|
include Dry::Monads[:result]
|
10
11
|
|
11
|
-
def initialize container: Container
|
12
|
-
@container = container
|
13
|
-
end
|
14
|
-
|
15
12
|
def call specification
|
16
13
|
executor.capture3("git", "status", "--porcelain").then do |_stdout, _stderr, status|
|
17
14
|
status.success? ? Success(specification) : Failure("Project has uncommitted changes.")
|
18
15
|
end
|
19
16
|
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
attr_reader :container
|
24
|
-
|
25
|
-
def executor = container[__method__]
|
26
17
|
end
|
27
18
|
end
|
28
19
|
end
|
@@ -7,14 +7,17 @@ module Gemsmith
|
|
7
7
|
module Tools
|
8
8
|
# Versions (tags) current project (local and remote).
|
9
9
|
class Versioner
|
10
|
+
include Import[:configuration]
|
10
11
|
include Dry::Monads[:result]
|
11
12
|
|
12
13
|
def initialize client: Milestoner::Tags::Publisher.new,
|
13
14
|
content: Milestoner::Configuration::Content,
|
14
|
-
|
15
|
+
**dependencies
|
16
|
+
|
17
|
+
super(**dependencies)
|
18
|
+
|
15
19
|
@client = client
|
16
20
|
@content = content
|
17
|
-
@container = container
|
18
21
|
end
|
19
22
|
|
20
23
|
def call specification
|
@@ -26,18 +29,15 @@ module Gemsmith
|
|
26
29
|
|
27
30
|
private
|
28
31
|
|
29
|
-
attr_reader :client, :content
|
32
|
+
attr_reader :client, :content
|
30
33
|
|
31
34
|
def settings specification
|
32
35
|
content[
|
33
36
|
documentation_format: configuration.extensions_milestoner_documentation_format,
|
34
37
|
prefixes: configuration.extensions_milestoner_prefixes,
|
35
|
-
sign: configuration.extensions_milestoner_sign,
|
36
38
|
version: specification.version
|
37
39
|
]
|
38
40
|
end
|
39
|
-
|
40
|
-
def configuration = container[__method__]
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -6,23 +6,14 @@ module Gemsmith
|
|
6
6
|
module Tools
|
7
7
|
# Views a gem within default browser.
|
8
8
|
class Viewer
|
9
|
+
include Import[:executor]
|
9
10
|
include Dry::Monads[:result]
|
10
11
|
|
11
|
-
def initialize container: Container
|
12
|
-
@container = container
|
13
|
-
end
|
14
|
-
|
15
12
|
def call specification
|
16
13
|
executor.capture3("open", specification.homepage_url).then do |_stdout, stderr, status|
|
17
14
|
status.success? ? Success(specification) : Failure(stderr)
|
18
15
|
end
|
19
16
|
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
attr_reader :container
|
24
|
-
|
25
|
-
def executor = container[__method__]
|
26
17
|
end
|
27
18
|
end
|
28
19
|
end
|