Class: Storey::BuildsDumpCommand
- Inherits:
-
Object
- Object
- Storey::BuildsDumpCommand
- Defined in:
- lib/storey/builds_dump_command.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(options = {}) ⇒ BuildsDumpCommand
constructor
A new instance of BuildsDumpCommand.
Constructor Details
#initialize(options = {}) ⇒ BuildsDumpCommand
Returns a new instance of BuildsDumpCommand.
6 7 8 9 10 11 |
# File 'lib/storey/builds_dump_command.rb', line 6 def initialize(={}) = if [:database].blank? raise ArgumentError, 'database must be supplied' end end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/storey/builds_dump_command.rb', line 13 def execute switches = {} switches['schema-only'] = nil if [:structure_only] switches['no-privileges'] = nil switches['no-owner'] = nil switches['host'] = [:host] if [:host].present? switches['username'] = [:username] if [:username].present? switches[:file] = Shellwords.escape([:file]) if [:schemas] schemas = [:schemas].split(',') schemas_switches = schemas.map do |part| Utils.command_line_switches_from({schema: Shellwords.escape(part) }) end end command_parts = [] if [:password].present? command_parts << "PGPASSWORD=#{@options[:password]}" end command_parts += ['pg_dump', Utils.command_line_switches_from(switches), schemas_switches, [:database]] command_parts.compact.join(' ') end |