module Ore::Checks

A mixin for {Project} which provides methods for checking files.

Protected Instance Methods

check_directory(path) { |dir| ... } click to toggle source

Checks if the path is a readable directory.

@yield [path]

The block will be passed the path, if it is a readable directory.
Otherwise a warning will be printed.

@yieldparam [String] path

The directory path.
# File lib/ore/checks.rb, line 36
def check_directory(path)
  check_readable(path) do |dir|
    if File.directory?(dir)
      yield dir
    else
      warn "#{dir} is not a directory!"
    end
  end
end
check_executable(path) { |file| ... } click to toggle source

Checks if the path is an executable file.

@yield [path]

The block will be passed the path, if it is an executable file.
Otherwise a warning will be printed.

@yieldparam [String] path

An path to an executable file.
# File lib/ore/checks.rb, line 78
def check_executable(path)
  check_file(path) do |file|
    if File.executable?(file)
      yield file
    else
      warn "#{file} is not executable!"
    end
  end
end
check_file(path) { |file| ... } click to toggle source

Checks if the path is a readable file.

@yield [path]

The block will be passed the path, if it is a readable file.
Otherwise a warning will be printed.

@yieldparam [String] path

A file path.
# File lib/ore/checks.rb, line 56
def check_file(path)
  if @project_files.include?(path)
    check_readable(path) do |file|
      if File.file?(file)
        yield file
      else
        warn "#{file} is not a file!"
      end
    end
  end
end
check_readable(path) { |path| ... } click to toggle source

Checks if the path is readable.

@yield [path]

The block will be passed the path, if it is readable.
Otherwise a warning will be printed.

@yieldparam [String] path

A readable path.
# File lib/ore/checks.rb, line 18
def check_readable(path)
  if File.readable?(path)
    yield path
  else
    warn "#{path} is not readable!"
  end
end