Module: FailFast::Base

Defined in:
lib/fail_fast/base/base.rb

Constant Summary collapse

ERB_TEMPLATE =
File.dirname(__FILE__) + '/../report.txt.erb'

Instance Method Summary collapse

Instance Method Details

#but_fail_later(&block) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/fail_fast/base/base.rb', line 23

def but_fail_later(&block)
  return if @config_file_not_found
  check_all_rules(&block) if block_given?
  unless errors.empty?
    print_errors
  end
end

#check(&block) ⇒ Object Also known as: check_now



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fail_fast/base/base.rb', line 5

def check(&block)
  fail_now_mode   = block_given? # false in the case of  *.check_now.but_fail_now do .. end

  @config_file_not_found = @config_file_path && !File.exist?(@config_file_path)
  if @config_file_not_found
    add_error ErrorDetails.new(nil, :config_file_not_found, @config_file_path)
  else
    check_all_rules(&block) if block_given?
  end
  unless errors.empty?
    print_errors
    exit(1) if fail_now_mode
  end
  self
end