Fix coding standards
This commit is contained in:
parent
658e333420
commit
c8b685b8a3
@ -38,7 +38,8 @@ module Producer
|
|||||||
|
|
||||||
attr_reader :arguments, :stdin, :stdout, :stderr, :env
|
attr_reader :arguments, :stdin, :stdout, :stderr, :env
|
||||||
|
|
||||||
def initialize(args, environment, stdin: $stdin, stdout: $stdout, stderr: $stderr)
|
def initialize(args, environment, stdin: $stdin, stdout: $stdout,
|
||||||
|
stderr: $stderr)
|
||||||
@arguments = args
|
@arguments = args
|
||||||
@stdin = stdin
|
@stdin = stdin
|
||||||
@stdout = stdout
|
@stdout = stdout
|
||||||
@ -82,7 +83,7 @@ module Producer
|
|||||||
def split_arguments_lists(arguments)
|
def split_arguments_lists(arguments)
|
||||||
arguments
|
arguments
|
||||||
.chunk { |e| e == ARGUMENTS_SEPARATOR }
|
.chunk { |e| e == ARGUMENTS_SEPARATOR }
|
||||||
.reject { |b, a| b }
|
.reject { |a, _| a }
|
||||||
.map &:last
|
.map &:last
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ module Producer
|
|||||||
attr_reader :input, :output, :error_output, :registry, :logger
|
attr_reader :input, :output, :error_output, :registry, :logger
|
||||||
attr_accessor :target, :verbose, :debug, :dry_run, :recipe_argv
|
attr_accessor :target, :verbose, :debug, :dry_run, :recipe_argv
|
||||||
|
|
||||||
def initialize(input: $stdin, output: $stdout, error_output: $stderr, remote: nil, registry: {})
|
def initialize(input: $stdin, output: $stdout, error_output: $stderr,
|
||||||
|
remote: nil, registry: {})
|
||||||
@verbose = @debug = @dry_run = false
|
@verbose = @debug = @dry_run = false
|
||||||
@input = input
|
@input = input
|
||||||
@output = output
|
@output = output
|
||||||
|
@ -56,7 +56,7 @@ module Producer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def indent_backtrace(backtrace)
|
def indent_backtrace(backtrace)
|
||||||
backtrace.map { |e| ' %s' % e }
|
backtrace.map { |e| ' ' + e }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
module Producer
|
module Producer
|
||||||
module Core
|
module Core
|
||||||
class LoggerFormatter < Logger::Formatter
|
class LoggerFormatter < Logger::Formatter
|
||||||
def call(severity, datetime, progname, message)
|
def call(severity, _datetime, _progname, message)
|
||||||
prefix(severity) + message + "\n"
|
prefix(severity) + message + "\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ module Producer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def compose_macro(name, macro, *base_args)
|
def compose_macro(name, macro, *base_args)
|
||||||
self.class.class_eval { compose_macro name, macro, *base_args}
|
self.class.class_eval { compose_macro name, macro, *base_args }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_macro(name, &block)
|
def test_macro(name, &block)
|
||||||
|
@ -26,16 +26,16 @@ module Producer
|
|||||||
|
|
||||||
def execute(command, output = '', error_output = '')
|
def execute(command, output = '', error_output = '')
|
||||||
session.open_channel do |channel|
|
session.open_channel do |channel|
|
||||||
channel.exec command do |ch, success|
|
channel.exec command do |ch, _success|
|
||||||
ch.on_data do |c, data|
|
ch.on_data do |_c, data|
|
||||||
output << data
|
output << data
|
||||||
end
|
end
|
||||||
|
|
||||||
ch.on_extended_data do |c, type, data|
|
ch.on_extended_data do |_c, _type, data|
|
||||||
error_output << data
|
error_output << data
|
||||||
end
|
end
|
||||||
|
|
||||||
ch.on_request 'exit-status' do |c, data|
|
ch.on_request 'exit-status' do |_c, data|
|
||||||
exit_status = data.read_long
|
exit_status = data.read_long
|
||||||
fail RemoteCommandExecutionError, command if exit_status != 0
|
fail RemoteCommandExecutionError, command if exit_status != 0
|
||||||
end
|
end
|
||||||
|
@ -29,11 +29,11 @@ module Producer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def mkdir(path, attributes = {})
|
def mkdir(path, attributes = {})
|
||||||
ret = sftp.mkdir! path, attributes
|
sftp.mkdir! path, attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_read(path)
|
def file_read(path)
|
||||||
sftp.file.open(path) { |f| content = f.read }
|
sftp.file.open(path) { |f| f.read }
|
||||||
rescue Net::SFTP::StatusException
|
rescue Net::SFTP::StatusException
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
@ -52,13 +52,20 @@ module Producer
|
|||||||
@actions << self.class.evaluate(@env, name, *args, &block)
|
@actions << self.class.evaluate(@env, name, *args, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ask(question, choices, prompter: Prompter.new(@env.input, @env.output))
|
def ask(question, choices, prompter: build_prompter)
|
||||||
prompter.prompt(question, choices)
|
prompter.prompt(question, choices)
|
||||||
end
|
end
|
||||||
|
|
||||||
def template(path, variables = {})
|
def template(path, variables = {})
|
||||||
Template.new(path).render variables
|
Template.new(path).render variables
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def build_prompter
|
||||||
|
Prompter.new(@env.input, @env.output)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user