Class: Mir::Application
- Inherits:
-
Object
- Object
- Mir::Application
- Defined in:
- lib/mir/application.rb
Constant Summary collapse
- DEFAULT_SETTINGS_FILE_NAME =
"mir_settings.yml"- DEFAULT_BATCH_SIZE =
20
Instance Attribute Summary collapse
-
#disk ⇒ Object
readonly
Returns the value of attribute disk.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.config ⇒ Mir::Config
Returns a global configuration instance.
-
.start ⇒ Object
Creates a new Mir instance.
Instance Method Summary collapse
-
#config ⇒ Object
Alias for +config.
-
#initialize ⇒ Application
constructor
A new instance of Application.
-
#start ⇒ Object
Begins the synchronization operation after initializing the file index and remote storage container.
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
19 20 21 22 23 24 25 26 27 |
# File 'lib/mir/application.rb', line 19 def initialize = Mir::Options.parse(ARGV) Mir.logger = Logger.new(.log_destination) Mir.logger.level = if .debug Logger::DEBUG else Logger::ERROR end end |
Instance Attribute Details
#disk ⇒ Object (readonly)
Returns the value of attribute disk.
17 18 19 |
# File 'lib/mir/application.rb', line 17 def disk @disk end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
17 18 19 |
# File 'lib/mir/application.rb', line 17 def index @index end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/mir/application.rb', line 17 def end |
Class Method Details
.config ⇒ Mir::Config
Returns a global configuration instance
57 58 59 |
# File 'lib/mir/application.rb', line 57 def self.config @@config end |
.start ⇒ Object
Creates a new Mir instance
13 14 15 |
# File 'lib/mir/application.rb', line 13 def self.start new.start end |
Instance Method Details
#config ⇒ Object
Alias for +config
63 64 65 |
# File 'lib/mir/application.rb', line 63 def config self.class.config end |
#start ⇒ Object
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 .copy && .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.(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 => .verbose, :force_flush => .flush) .copy ? pull(param_path) : push(param_path) end |