Module: Contestify::Util

Included in:
Contest
Defined in:
lib/contestify/util.rb

Instance Method Summary collapse

Instance Method Details

#check_dependenciesObject



13
14
15
16
17
18
# File 'lib/contestify/util.rb', line 13

def check_dependencies
  system?(:zip)       and
  system?(:curl)      and
  system?(:unzip)     and
  system?(:dos2unix)
end

#clean_dir!(directory) ⇒ Object



8
9
10
11
# File 'lib/contestify/util.rb', line 8

def clean_dir!(directory)
  puts red "Deleting created files & folders (#{directory})"
  FileUtils.rm_rf directory
end

#system?(command) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (Exception)


3
4
5
6
# File 'lib/contestify/util.rb', line 3

def system?(command)
  `which #{command.to_s}`
  raise Exception.new(red "`#{command}` is not installed. Please install it first") unless $?.success?
end