Top Level Namespace

Includes:
Astrails::Safe

Defined Under Namespace

Modules: Astrails Classes: Dir

Constant Summary

Constants included from Astrails::Safe

Astrails::Safe::ROOT, Astrails::Safe::VERSION

Instance Method Summary collapse

Methods included from Astrails::Safe

safe

Instance Method Details

#die(msg) ⇒ Object



11
12
13
14
# File 'bin/astrails-safe', line 11

def die(msg)
  puts "ERROR: #{msg}"
  exit 1
end

#mainObject



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'bin/astrails-safe', line 39

def main
  process_options

  unless File.exists?($CONFIG_FILE_NAME)
    die "Missing configuration file. NOT CREATED! Rerun w/o the -n argument to create a template configuration file." if $DRY_RUN

    FileUtils.cp File.join(Astrails::Safe::ROOT, "templates", "script.rb"), $CONFIG_FILE_NAME

    die "Created default #{$CONFIG_FILE_NAME}. Please edit and run again."
  end

  load($CONFIG_FILE_NAME)
end

#process_optionsObject



30
31
32
33
34
35
36
37
# File 'bin/astrails-safe', line 30

def process_options
  usage if ARGV.delete("-h") || ARGV.delete("--help")
  $_VERBOSE = ARGV.delete("-v") || ARGV.delete("--verbose")
  $DRY_RUN = ARGV.delete("-n") || ARGV.delete("--dry-run")
  $LOCAL   = ARGV.delete("-L") || ARGV.delete("--local")
  usage unless ARGV.first
  $CONFIG_FILE_NAME = File.expand_path(ARGV.first)
end

#usageObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'bin/astrails-safe', line 16

def usage
  puts <<-END
Usage: astrails-safe [OPTIONS] CONFIG_FILE
Options:
  -h, --help           This help screen
  -v, --verbose        be verbose, duh!
  -n, --dry-run        just pretend, don't do anything.
  -L, --local          skip S3 and Cloud Files

Note: config file will be created from template if missing
END
  exit 1
end