Class: CFBackup

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

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CFBackup

Implementation of initialize

Prepares CFBackup object by calling options processor, loading configuration files, and preparing the connection to Mosso Cloud Files.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/cfbackup.rb', line 30

def initialize(args)
  @opts = OptCFBackup.new(args)

  # Special case if the version is requested
  if @opts.options.show_ver
    version_file = File.join(File.dirname(__FILE__), '..', 'VERSION.yml')
    if File.exist?(version_file)
      config = YAML.load(File.read(version_file))
      version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
    else
      version = "unkown version"
    end
    show_error("CFBackup #{version}")
  end
  
  # Locate and load config file
  @opts.options.config.each do |path|
    if (File.exist?(path))
      @conf = YAML::load(File.open(path))
      break
    end
  end
  show_error('Error: Unable to locate config file.') unless (@conf != nil)
  
  prep_connection
  prep_error_log_file unless !@opts.options.error_log
  
end

Instance Method Details

#runObject

Run CFBackup.

This method will call the appropriate method based on the action given when CFBackup was called.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/cfbackup.rb', line 63

def run
  
  show_error() unless (@opts.options.container != "")
  
  # Run appropriate action
  case @opts.options.action
  when 'push'
    if @opts.options.pipe_data
      push_piped_data
    else
      push_files
    end
  when 'pull'
    pull_files()
  when 'delete'
    delete_files
  else
    show_error()
  end
  
end