Class: Storey::BuildsLoadCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/storey/builds_load_command.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BuildsLoadCommand

Returns a new instance of BuildsLoadCommand.



6
7
8
# File 'lib/storey/builds_load_command.rb', line 6

def initialize(options={})
  @options = options
end

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/storey/builds_load_command.rb', line 10

def execute
  switches = {}
  if @options[:file].present?
    switches[:file] = Shellwords.escape(@options[:file])
  end
  switches[:dbname] = @options[:database]
  switches[:username] = @options[:username] if @options[:username].present?
  switches[:host] = @options[:host] if @options[:host].present?
  switches[:port] = @options[:port] if @options[:port].present?
  if @options[:password].present?
    switches[:password] = @options[:password]
  else
    switches['no-password'] = nil
  end
  switches[:command] = %Q("#{@options[:command]}") if @options[:command].present?
  command_parts = ['psql',
                   Utils.command_line_switches_from(switches)]
  command_parts.join(' ')
end