Class: Dustcart::Resource::Input::Postgres

Inherits:
Base
  • Object
show all
Defined in:
lib/dustcart/input/postgres.rb

Overview

input: postgresql

Constant Summary collapse

COMMAND =
'pg_dump'.freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes, #dump_dir

Instance Method Summary collapse

Methods inherited from Base

define_attribute, inherited, #method_missing, #respond_to_missing?

Constructor Details

#initialize(to_dir, database_name, &block) ⇒ Postgres

Returns a new instance of Postgres.



17
18
19
20
21
22
23
24
# File 'lib/dustcart/input/postgres.rb', line 17

def initialize(to_dir, database_name, &block)
  super(to_dir, &block)
  @database_name = database_name

  host  '127.0.0.1'     unless host
  port  '5432'          unless port
  label 'database.dump' unless label
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Dustcart::Resource::Base

Instance Attribute Details

#database_nameObject (readonly)

Returns the value of attribute database_name.



13
14
15
# File 'lib/dustcart/input/postgres.rb', line 13

def database_name
  @database_name
end

Instance Method Details

#precheckObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dustcart/input/postgres.rb', line 26

def precheck
  super

  requirements

  raise <<-EOS.unindent unless SystemCommand.exists?(COMMAND)
    #{COMMAND} command is not installed
  EOS

  raise <<-EOS.unindent unless database_name
    'database_name' is required
  EOS
end

#runObject



40
41
42
43
44
# File 'lib/dustcart/input/postgres.rb', line 40

def run
  super

  create_dump
end