Sha256: 671b0c4493d9045566cd897d351587443249c8d92e1f7dd2b0d2a9f72fe7ad55
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
require "thor" module Carrasco class Thor < ::Thor CommandFailed = Class.new(StandardError) no_commands do def execute_command(command) command_executer.execute!(command) end def command_executer=(command_executer) @@command_executer = command_executer end def command_executer @@command_executer ||= CommandExecuter.new end def execute_commands(commands, break_on_failure) if break_on_failure return execute_with_break_on_failure(commands) end errors = [] commands.each do |command| begin send(command) rescue StandardError => e errors << e.message end end unless errors.empty? messages = errors.map {|e| "'#{e}'"} raise CommandFailed, "Failed with messages: #{messages.join(', ')}" end end private def execute_with_break_on_failure(commands) commands.each do |command| send(command) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
carrasco-0.1.6 | lib/carrasco/thor.rb |