module Edfize

Loads EDFs, prints information, runs tests

Public Class Methods

check(argv) click to toggle source
# File lib/edfize.rb, line 35
def self.check(argv)
  test_start_time = Time.now
  edf_count = 0
  test_count = 0
  failure_count = 0
  total_edfs = edf_paths.count
  show_passing = argv.include?("--failing") ? false : true
  puts "Started\n"
  edfs.each do |edf|
    runner = Edfize::Tests::Runner.new(edf, argv)
    runner.run_tests
    test_count += runner.tests_run
    failure_count += runner.tests_failed
    edf_count += 1
    print "\rChecked EDF #{edf_count} of #{total_edfs}" unless show_passing || !runner.tests_failed.zero?
  end
  puts "\nFinished in #{Time.now - test_start_time}s"
  puts "#{edf_count} EDF#{"s" unless edf_count == 1}, #{test_count} test#{"s" unless test_count == 1}, " + "#{failure_count} failure#{"s" unless failure_count == 1}".send(failure_count == 0 ? :green : :red)
end
edf_paths(recursive: true) click to toggle source
# File lib/edfize.rb, line 82
def self.edf_paths(recursive: true)
  path = "#{"**/" if recursive}*.edf"
  Dir.glob(path, File::FNM_CASEFOLD)
end
edfs(recursive: true) { |edf| ... } click to toggle source

Returns an enumerator of EDFs.

# File lib/edfize.rb, line 75
def self.edfs(recursive: true)
  return enum_for(:edfs, recursive: recursive) unless block_given?
  edf_paths(recursive: recursive).each do |file_path|
    yield Edf.new(file_path)
  end
end
help() click to toggle source
# File lib/edfize.rb, line 55
  def self.help
    help_message = <<-EOT
Usage: edfize COMMAND [ARGS]

The most common edfize commands are:
  [t]est            Check EDFs in directory and subdirectories
    --failing       Only display failing tests
    --quiet         Suppress failing test descriptions
  [r]un             Print EDF header information
  [h]elp            Show edfize command documentation
  [v]ersion         Returns the version of Edfize

Commands can be referenced by the first letter:
  Ex: `edfize t`, for test

EOT
    puts help_message
  end
launch(argv) click to toggle source
# File lib/edfize.rb, line 10
def self.launch(argv)
  case argv.first.to_s.scan(/\w/).first
  when "v"
    version
  when "c", "t"
    check(argv[1..-1])
  when "r"
    print_headers
  else
    help
  end
end
print_headers() click to toggle source
version() click to toggle source
# File lib/edfize.rb, line 31
def self.version
  puts "Edfize #{Edfize::VERSION::STRING}"
end