Sha256: 88e9a541e7715314fde080023d9aa15e8c2b2b7d6e886495be75b4b3cfae6f12

Contents?: true

Size: 940 Bytes

Versions: 5

Compression:

Stored size: 940 Bytes

Contents

module Storey
  class BuildsDumpCommand

    easy_class_to_instance

    def initialize(options={})
      @options = options
      if @options[:database].blank?
        raise ArgumentError, 'database must be supplied'
      end
    end

    def execute

      switches = {}
      switches['schema-only'] = nil if @options[:structure_only]
      switches['no-privileges'] = nil
      switches['no-owner'] = nil
      switches[:file] = Shellwords.escape(@options[:file])

      if @options[:schemas]
        schemas = @options[:schemas].split(',')
        schemas_switches = schemas.map do |part|
          Utils.command_line_switches_from({schema: Shellwords.escape(part) })
        end
      end

      command_parts = ['pg_dump',
                       Utils.command_line_switches_from(switches),
                       schemas_switches,
                       @options[:database]]
      command_parts.compact.join(' ')
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
storey-1.0.0 lib/storey/builds_dump_command.rb
storey-0.6.0 lib/storey/builds_dump_command.rb
storey-0.5.2 lib/storey/builds_dump_command.rb
storey-0.5.1 lib/storey/builds_dump_command.rb
storey-0.5.0 lib/storey/builds_dump_command.rb