Class: Giddyup::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/giddyup/runner.rb

Class Method Summary collapse

Class Method Details

.parse_options(args) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/giddyup/runner.rb', line 11

def parse_options(args)
  value = args.shift
  error "WHERES MY FILE щ(ಠ益ಠщ)" if value.nil? || !valid_file(value)
  files = args.inject([value]) do |acc, arg|
    acc << arg if valid_file(arg)
    acc
  end
  files
end

.run!(*args) ⇒ Object



5
6
7
8
9
# File 'lib/giddyup/runner.rb', line 5

def run!(*args)
  files = parse_options(args)
  Giddyup::Util.post_files(files) if files
  return 0
end

.valid_file(path) ⇒ Object



21
22
23
24
# File 'lib/giddyup/runner.rb', line 21

def valid_file(path)
  cwd = `pwd`.strip
  File.exists?(File.join(cwd, path))
end