Class: Omniscient::Command::Clone
- Defined in:
- lib/omniscient/command/clone.rb
Instance Attribute Summary collapse
-
#alias_name ⇒ Object
Returns the value of attribute alias_name.
-
#mysql ⇒ Object
Returns the value of attribute mysql.
-
#scp ⇒ Object
Returns the value of attribute scp.
-
#ssh ⇒ Object
Returns the value of attribute ssh.
Attributes inherited from Run
Instance Method Summary collapse
- #configurations_exist?(alias_name) ⇒ Boolean
- #help ⇒ Object
- #instantiate_adapters ⇒ Object
- #load_configurations(alias_name = false) ⇒ Object
- #run ⇒ Object
- #set_custom_variables(argv = false) ⇒ Object
Methods inherited from Run
#initialize, #request_configuration, #version
Constructor Details
This class inherits a constructor from Omniscient::Command::Run
Instance Attribute Details
#alias_name ⇒ Object
Returns the value of attribute alias_name.
10 11 12 |
# File 'lib/omniscient/command/clone.rb', line 10 def alias_name @alias_name end |
#mysql ⇒ Object
Returns the value of attribute mysql.
10 11 12 |
# File 'lib/omniscient/command/clone.rb', line 10 def mysql @mysql end |
#scp ⇒ Object
Returns the value of attribute scp.
10 11 12 |
# File 'lib/omniscient/command/clone.rb', line 10 def scp @scp end |
#ssh ⇒ Object
Returns the value of attribute ssh.
10 11 12 |
# File 'lib/omniscient/command/clone.rb', line 10 def ssh @ssh end |
Instance Method Details
#configurations_exist?(alias_name) ⇒ Boolean
38 39 40 |
# File 'lib/omniscient/command/clone.rb', line 38 def configurations_exist? alias_name Omniscient::Configuration::load alias_name end |
#help ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/omniscient/command/clone.rb', line 60 def help print "Usage:\n" print "\s\somniscient clone ALIAS_NAME [options]" print "\n\n" print "Options:" print "\n" print "\s\s-d\t\tSelect a different database\n" print "\s\s--host\tSelect a different SSH address, e.g. [email protected]\n" end |
#instantiate_adapters ⇒ Object
50 51 52 53 54 |
# File 'lib/omniscient/command/clone.rb', line 50 def instantiate_adapters @ssh = Omniscient::Ssh.new @configurations['ssh'] @scp = Omniscient::Scp.new @configurations['ssh'] @mysql = Omniscient::Adapter::MySQL.new @configurations['mysql'] end |
#load_configurations(alias_name = false) ⇒ Object
56 57 58 |
# File 'lib/omniscient/command/clone.rb', line 56 def load_configurations alias_name = false @configurations = Omniscient::Configuration.load(alias_name || @alias_name) end |
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/omniscient/command/clone.rb', line 12 def run @alias_name = Shell::Parser.get_arguments(@argv).first || "" (help; exit) if @alias_name.empty? request_configuration unless configurations_exist? @alias_name load_configurations set_custom_variables instantiate_adapters # Dumps remotely command_to_issue = "#{@ssh.connect} '#{@mysql.dump}'" puts "Running => #{command_to_issue}" exit unless system command_to_issue # Copies dumped data command_to_issue = "#{@scp.connect}:"+Omniscient::DUMP_REMOTE_PATH+" "+Omniscient::DUMP_LOCAL_PATH puts "Running => #{command_to_issue}" exit unless system command_to_issue # Imports data command_to_issue = "#{@mysql.import}" puts "Running => #{command_to_issue}" exit unless system command_to_issue end |
#set_custom_variables(argv = false) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/omniscient/command/clone.rb', line 42 def set_custom_variables argv = false database = Shell::Parser.get_option_value('d', (argv || @argv)) || nil @configurations['mysql']['database'] = database unless database.empty? address = Shell::Parser.get_option_value('host', (argv || @argv)) || nil @configurations['ssh']['address'] = address unless address.empty? end |