Sha256: f4a49d2d6330b6164ecb416a4edc47c392e3fface74b879382c7751b3a89a656
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
module Phare class Check attr_reader :status, :command, :tree def initialize(_directory, options = {}) @tree = Git.new(@extensions, options) end def run if should_run? print_banner Phare.system(command) @status = Phare.last_exit_status if @status == 0 print_success_message else print_error_message end Phare.puts '' else @status = 0 end end def should_run? should_run = binary_exists? [:configuration_exists?, :arguments_exists?].each do |condition| should_run &&= send(condition) if respond_to?(condition, true) end if @options[:diff] # NOTE: If the tree hasn't changed or if there is no files # to check (e.g. they are all in the exclude list), # we skip the check. should_run &&= @tree.changed? && files_to_check.any? end should_run end protected def excluded_files @excluded_files ||= [Dir.glob(excluded_list || [])].flatten end def excluded_list [] # Should be overriden by children end def files_to_check @files_to_check ||= @tree.changes - excluded_files end def print_success_message Phare.puts('Everything looks good from here!') end def print_error_message Phare.puts("Something went wrong. Program exited with #{@status}.") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
phare-1.0.1 | lib/phare/check.rb |