Fix coding standards

This commit is contained in:
Thibault Jouan 2015-05-12 15:02:44 +00:00
parent 658e333420
commit c8b685b8a3
8 changed files with 22 additions and 13 deletions

View File

@ -38,7 +38,8 @@ module Producer
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
@stdin = stdin
@stdout = stdout
@ -82,7 +83,7 @@ module Producer
def split_arguments_lists(arguments)
arguments
.chunk { |e| e == ARGUMENTS_SEPARATOR }
.reject { |b, a| b }
.reject { |a, _| a }
.map &:last
end

View File

@ -7,7 +7,8 @@ module Producer
attr_reader :input, :output, :error_output, :registry, :logger
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
@input = input
@output = output

View File

@ -56,7 +56,7 @@ module Producer
end
def indent_backtrace(backtrace)
backtrace.map { |e| ' %s' % e }
backtrace.map { |e| ' ' + e }
end
end
end

View File

@ -1,7 +1,7 @@
module Producer
module Core
class LoggerFormatter < Logger::Formatter
def call(severity, datetime, progname, message)
def call(severity, _datetime, _progname, message)
prefix(severity) + message + "\n"
end

View File

@ -46,7 +46,7 @@ module Producer
end
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
def test_macro(name, &block)

View File

@ -26,16 +26,16 @@ module Producer
def execute(command, output = '', error_output = '')
session.open_channel do |channel|
channel.exec command do |ch, success|
ch.on_data do |c, data|
channel.exec command do |ch, _success|
ch.on_data do |_c, data|
output << data
end
ch.on_extended_data do |c, type, data|
ch.on_extended_data do |_c, _type, data|
error_output << data
end
ch.on_request 'exit-status' do |c, data|
ch.on_request 'exit-status' do |_c, data|
exit_status = data.read_long
fail RemoteCommandExecutionError, command if exit_status != 0
end

View File

@ -29,11 +29,11 @@ module Producer
end
def mkdir(path, attributes = {})
ret = sftp.mkdir! path, attributes
sftp.mkdir! path, attributes
end
def file_read(path)
sftp.file.open(path) { |f| content = f.read }
sftp.file.open(path) { |f| f.read }
rescue Net::SFTP::StatusException
nil
end

View File

@ -52,13 +52,20 @@ module Producer
@actions << self.class.evaluate(@env, name, *args, &block)
end
def ask(question, choices, prompter: Prompter.new(@env.input, @env.output))
def ask(question, choices, prompter: build_prompter)
prompter.prompt(question, choices)
end
def template(path, variables = {})
Template.new(path).render variables
end
private
def build_prompter
Prompter.new(@env.input, @env.output)
end
end
end
end