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



9
10
11
12
# File 'bin/astrails-safe', line 9

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

#mainObject



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

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



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

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



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

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