class Postmodern::WAL::Archive
Public Instance Methods
parser()
click to toggle source
# File lib/postmodern/wal/archive.rb, line 9 def parser @parser ||= OptionParser.new do |opts| opts.banner = "Usage: postmodern (archive|restore) <options>" opts.on('-f', '--filename FILE', 'File name of xlog') do |o| self.options[:filename] = o end opts.on('-p', '--path PATH', 'Path of xlog file') do |o| self.options[:path] = o end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("--version", "Show version") do require 'postmodern/version' puts Postmodern::VERSION exit end end end
run()
click to toggle source
# File lib/postmodern/wal/archive.rb, line 34 def run if local_script_exists? stdout, stderr, status = Open3.capture3(script_env, "#{local_script} #{path} #{filename}") $stdout.print stdout $stderr.print stderr exit status.exitstatus end end
Private Instance Methods
filename()
click to toggle source
# File lib/postmodern/wal/archive.rb, line 49 def filename @options[:filename] end
local_script()
click to toggle source
# File lib/postmodern/wal/archive.rb, line 57 def local_script 'postmodern_archive.local' end
local_script_exists?()
click to toggle source
# File lib/postmodern/wal/archive.rb, line 53 def local_script_exists? system({'PATH' => ENV['PATH']}, "which #{local_script} >/dev/null 2>/dev/null") end
path()
click to toggle source
# File lib/postmodern/wal/archive.rb, line 45 def path @options[:path] end
script_env()
click to toggle source
# File lib/postmodern/wal/archive.rb, line 61 def script_env { 'WAL_ARCHIVE_PATH' => path, 'WAL_ARCHIVE_FILE' => filename, 'PATH' => ENV['PATH'] } end