Class: Mir::Application

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

Constant Summary collapse

DEFAULT_SETTINGS_FILE_NAME =
"mir_settings.yml"
DEFAULT_BATCH_SIZE =
20

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplication

Returns a new instance of Application.



19
20
21
22
23
24
25
26
27
# File 'lib/mir/application.rb', line 19

def initialize
  @options = Mir::Options.parse(ARGV)
  Mir.logger = Logger.new(options.log_destination)
  Mir.logger.level = if options.debug
    Logger::DEBUG
  else
    Logger::ERROR
  end
end

Instance Attribute Details

#diskObject (readonly)

Returns the value of attribute disk.



17
18
19
# File 'lib/mir/application.rb', line 17

def disk
  @disk
end

#indexObject (readonly)

Returns the value of attribute index.



17
18
19
# File 'lib/mir/application.rb', line 17

def index
  @index
end

#optionsObject (readonly)

Returns the value of attribute options.



17
18
19
# File 'lib/mir/application.rb', line 17

def options
  @options
end

Class Method Details

.configMir::Config

Returns a global configuration instance

Returns:



57
58
59
# File 'lib/mir/application.rb', line 57

def self.config
  @@config
end

.startObject

Creates a new Mir instance



13
14
15
# File 'lib/mir/application.rb', line 13

def self.start
  new.start
end

Instance Method Details

#configObject

Alias for +config



63
64
65
# File 'lib/mir/application.rb', line 63

def config
  self.class.config
end

#startObject

Begins the synchronization operation after initializing the file index and remote storage container



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mir/application.rb', line 32

def start
  if options.copy && options.flush
    Mir.logger.error "Conflicting options: Cannot copy from remote source with an empty file index"
    exit
  end
  
  @@config = Config.new find_settings_file
  param_path = File.expand_path(ARGV[0])
  exit unless config.valid?
  
  # Initialize our remote disk
  @disk = Disk.fetch(config.cloud_provider)
  exit unless @disk.connected?
  
  # Initialize our local index
  @index = Index.new(param_path, config.database)
  @index.setup(:verbose => options.verbose, :force_flush => options.flush)
  
  options.copy ? pull(param_path) : push(param_path)
end