Sha256: 71148d049713843e475403593a397169b36b0a4bfad2f814dc0a5e967d1b7ee4
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
require 'delegate' module GitHooker class Section < DelegateClass(Array) include TerminalColors attr_accessor :stop_on_error def initialize(name) @name = name.to_s.titleize @success = true @stop_on_error = false @actions = [] waiting! end def actions @actions.collect { |action| Repo.match_phase(action.phase) } end alias :__getobj__ :actions def stop_on_error?() @stop_on_error; end def success?() @success; end def finished?() @status == :finished; end def finished!() @status = :finished; end def running?() @status == :running; end def running!() @status = :running; end def waiting?() @status == :waiting; end def waiting!() @status = :waiting; end def completed? @actions.all? { |action| action.finished? } end def wait_count() @actions.select { |action| action.waiting? }.size end def name() "#{GitHooker::SCRIPT_NAME.camelize} :: #{@name}" end def colored_name() status_colorize name end def status_colorize(text) finished? && completed? ? (success? ? bright_green(text) : bright_red(text)) : dark_cyan(text) end def run() running! if stop_on_error? @actions.all? { |action| @success &= action.run } else @actions.collect { |action| @success &= action.run }.all? end.tap { finished! } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
githooker-0.2.10 | lib/githooker/section.rb |