Class: Webhookdb::Postgres::Maintenance::Command

Inherits:
Base
  • Object
show all
Defined in:
lib/webhookdb/postgres/maintenance.rb

Direct Known Subclasses

Repack

Instance Attribute Summary

Attributes inherited from Base

#service_integration

Instance Method Summary collapse

Methods inherited from Base

#conn_params, #debug?, #initialize

Constructor Details

This class inherits a constructor from Webhookdb::Postgres::Maintenance::Base

Instance Method Details

#command_listObject

Raises:

  • (NotImplementedError)


72
# File 'lib/webhookdb/postgres/maintenance.rb', line 72

def command_list = raise NotImplementedError

#command_stringsObject



96
97
98
99
100
101
# File 'lib/webhookdb/postgres/maintenance.rb', line 96

def command_strings
  c = []
  c << self.shelex(self.create_extension_command_list) if self.extension
  c << self.shelex(self.command_list)
  return c
end

#create_extension_command_listObject



88
89
90
91
92
93
94
# File 'lib/webhookdb/postgres/maintenance.rb', line 88

def create_extension_command_list
  a = ["PGPASSWORD=#{self.conn_params[:password]}", "psql"]
  a += self.psql_conn_params
  a << "-c"
  a << "'CREATE EXTENSION IF NOT EXISTS #{self.extension}'"
  return a
end

#docker?Boolean

Returns:

  • (Boolean)


59
# File 'lib/webhookdb/postgres/maintenance.rb', line 59

def docker? = Webhookdb::Postgres::Maintenance.docker

#docker_imageObject

Raises:

  • (NotImplementedError)


73
# File 'lib/webhookdb/postgres/maintenance.rb', line 73

def docker_image = raise NotImplementedError

#docker_preambleObject



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/webhookdb/postgres/maintenance.rb', line 76

def docker_preamble
  return [
    "docker",
    "run",
    "-e",
    "PGPASSWORD=#{self.conn_params[:password]}",
    "-it",
    "--rm",
    self.docker_image,
  ]
end

#extensionObject



74
# File 'lib/webhookdb/postgres/maintenance.rb', line 74

def extension = nil

#psql_conn_paramsObject



61
62
63
64
65
66
67
68
69
70
# File 'lib/webhookdb/postgres/maintenance.rb', line 61

def psql_conn_params
  h = self.conn_params
  return [
    "--no-password",
    "-U", h[:user],
    "-h", h[:host],
    "-p", h[:port],
    "--dbname", h[:database],
  ]
end

#shelex(a) ⇒ Object



103
104
105
# File 'lib/webhookdb/postgres/maintenance.rb', line 103

def shelex(a)
  return a.join(" ")
end