Class: Rumination::Pg::Restore

Inherits:
Object
  • Object
show all
Defined in:
lib/rumination/pg/restore.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Restore

Returns a new instance of Restore.



6
7
8
9
# File 'lib/rumination/pg/restore.rb', line 6

def initialize *args
  require "open3"
  @args = args.dup.freeze
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



4
5
6
# File 'lib/rumination/pg/restore.rb', line 4

def args
  @args
end

Class Method Details

.call(*args) ⇒ Object



11
12
13
# File 'lib/rumination/pg/restore.rb', line 11

def self.call *args
  new(*args).call
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rumination/pg/restore.rb', line 15

def call
  command = "pg_restore #{args.join(" ")}"
  puts command
  Open3.popen3 ENV, command do |stdin, stdout, stderr, thread|
    out_lines = stdout.readlines
    err_lines = stderr.readlines
    save_stream :stdout, out_lines
    save_stream :stderr, err_lines
    puts_log out_lines + err_lines, indent: 2
    analyse_stderr! err_lines
  end
end