module RComp::Env

Public Instance Methods

command_exists?() click to toggle source

Checks for the existance of a command to test with

Returns a boolean

# File lib/rcomp/env.rb, line 41
def command_exists?
  @@conf.command
end
guard_initialized() click to toggle source

Emit error unless RComp is not fully initialized

Returns nothing

# File lib/rcomp/env.rb, line 21
def guard_initialized
  if initialized?
    puts "RComp already initialized"
    exit 1
  end
end
guard_uninitialized() click to toggle source

Emit error unless RComp is fully initialized

Returns nothing

# File lib/rcomp/env.rb, line 12
def guard_uninitialized
  guard_command_exists
  guard_root_dir_exists
  guard_root_subdirs_exist
end
initialize_directories() click to toggle source

Create RComp directories if they don’t already exist

Returns nothing

# File lib/rcomp/env.rb, line 31
def initialize_directories
  mkpath @@conf.root
  mkdir @@conf.test_root
  mkdir @@conf.expected_root
  mkdir @@conf.result_root
end

Private Instance Methods

guard_command_exists() click to toggle source

Require the command config option to be set Print error and exit otherwise

Returns nothing

# File lib/rcomp/env.rb, line 77
def guard_command_exists
  unless command_exists?
    puts "No command present"
    puts "Run rcomp init to setup"
    exit 1
  end
end
guard_root_dir_exists() click to toggle source

Require the existance of the root directory Print error and exit otherwise

Returns nothing

# File lib/rcomp/env.rb, line 89
def guard_root_dir_exists
  unless root_dir_exists?
    puts "No RComp directory"
    puts "Run rcomp init to create"
    exit 1
  end
end
guard_root_subdirs_exist() click to toggle source

Require all sudirectories of the root directory to exist Print error and exit otherwise

Returns nothing

# File lib/rcomp/env.rb, line 101
def guard_root_subdirs_exist
  unless root_subdirs_exist?
    puts "Missing RComp directories at #{@@conf.root}"
    puts "Run rcomp init to repair"
    exit 1
  end
end
initialized?() click to toggle source

Checks to see if RComp is fully initialized

Returns a boolean

# File lib/rcomp/env.rb, line 67
def initialized?
  command_exists? &&
    root_dir_exists? &&
    root_subdirs_exist?
end
root_dir_exists?() click to toggle source

Checks for the existance of RComp’s root directory

Returns a boolean

# File lib/rcomp/env.rb, line 50
def root_dir_exists?
  File.exists?(@@conf.root)
end
root_subdirs_exist?() click to toggle source

Checks for the existance of the required subdirectories inside of RComp’s root directory

Returns a boolean

# File lib/rcomp/env.rb, line 58
def root_subdirs_exist?
  File.exists?(@@conf.test_root) && 
  File.exists?(@@conf.result_root) && 
  File.exists?(@@conf.expected_root)
end