Module: Flick::Checker

Defined in:
lib/flick/checker.rb

Class Method Summary collapse

Class Method Details

.action(action) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/flick/checker.rb', line 30

def self.action action
  actions = ["start","stop"]
  unless actions.include? action
    puts "\nPlease specify a valid action #{actions}. e.g. flick <job> -a #{actions.sample} -p ios\n".red
    abort
  end
end

.file_exists?(file) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
# File 'lib/flick/checker.rb', line 46

def self.file_exists? file
  unless File.exists? file
    puts "\n#{file} does not exist! Please specify a valid file path.".red
    abort
  end
end

.format(format) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/flick/checker.rb', line 53

def self.format format
  formats = ["mp4","gif"]
  unless formats.include? format
    puts "\nPlease specify a valid format #{formats}. e.g. flick <job> -a stop -p ios -f #{formats.sample}\n".red
    abort
  end
end

.manager(option) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/flick/checker.rb', line 38

def self.manager option
  options = ["install","uninstall"]
  unless options.include? option
    puts "\nPlease specify a valid option #{options}. e.g. flick <job> -a #{options.sample} -p ios\n".red
    abort
  end
end

.platform(platform) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/flick/checker.rb', line 22

def self.platform platform
  platforms = ["android","ios"]
  unless platforms.include? platform
    puts "\nPlease specify a valid platform #{platforms}. e.g. flick <job> -a start -p #{platforms.sample}\n".red
    abort
  end
end

.system_dependency(dep) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/flick/checker.rb', line 14

def self.system_dependency dep
  program = self.which dep
  if program.nil? || program.empty? 
    puts "\n#{dep} was not found. Please ensure you have installed #{dep} and it's in your $PATH\n".red
    abort
  end
end

.which(cmd) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/flick/checker.rb', line 3

def self.which(cmd)
  exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
  ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
    exts.each { |ext|
      exe = File.join(path, "#{cmd}#{ext}")
      return exe if File.executable?(exe) && !File.directory?(exe)
    }
  end
  return nil
end