Class: RR::UninstallRunner
- Inherits:
-
Object
- Object
- RR::UninstallRunner
- Defined in:
- lib/rubyrep/uninstall_runner.rb
Overview
This class implements the functionality of the ‘uninstall’ command.
Instance Attribute Summary collapse
-
#options ⇒ Object
Provided options.
Class Method Summary collapse
-
.run(args) ⇒ Object
Entry points for executing a processing run.
Instance Method Summary collapse
-
#execute ⇒ Object
Removes all rubyrep created database objects.
-
#process_options(args) ⇒ Object
Parses the given command line parameter array.
-
#session ⇒ Object
Returns the active
Session
.
Instance Attribute Details
#options ⇒ Object
Provided options. Possible values:
-
:config_file
: path to config file
16 17 18 |
# File 'lib/rubyrep/uninstall_runner.rb', line 16 def @options end |
Class Method Details
.run(args) ⇒ Object
Entry points for executing a processing run. args: the array of command line options that were provided by the user.
80 81 82 83 84 85 86 87 88 |
# File 'lib/rubyrep/uninstall_runner.rb', line 80 def self.run(args) runner = new status = runner.(args) if runner. runner.execute end status end |
Instance Method Details
#execute ⇒ Object
Removes all rubyrep created database objects.
71 72 73 74 75 76 |
# File 'lib/rubyrep/uninstall_runner.rb', line 71 def execute initializer = ReplicationInitializer.new session initializer.restore_unconfigured_tables([]) initializer.drop_infrastructure puts "Uninstall completed: rubyrep tables and triggers removed!" end |
#process_options(args) ⇒ Object
Parses the given command line parameter array. Returns the status (as per UNIX conventions: 1 if parameters were invalid, 0 otherwise)
21 22 23 24 25 26 27 28 29 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 58 |
# File 'lib/rubyrep/uninstall_runner.rb', line 21 def (args) status = 0 self. = {} parser = OptionParser.new do |opts| opts. = <<EOS Usage: #{$0} uninstall [options] Removes all rubyrep tables, triggers, etc. from "left" and "right" database. EOS opts.separator "" opts.separator " Specific options:" opts.on("-c", "--config", "=CONFIG_FILE", "Mandatory. Path to configuration file.") do |arg| [:config_file] = arg end opts.on_tail("--help", "Show this message") do $stderr.puts opts self. = nil end end begin parser.parse!(args) if # this will be +nil+ if the --help option is specified raise("Please specify configuration file") unless .include?(:config_file) end rescue Exception => e $stderr.puts "Command line parsing failed: #{e}" $stderr.puts parser.help self. = nil status = 1 end return status end |
#session ⇒ Object
Returns the active Session
. Loads config file and creates session if necessary.
62 63 64 65 66 67 68 |
# File 'lib/rubyrep/uninstall_runner.rb', line 62 def session unless @session load [:config_file] @session = Session.new Initializer.configuration end @session end |