Class: PgExport::Dump

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_export/dump.rb

Constant Summary collapse

TIMESTAMP_REGEX =
'[0-9]{8}_[0-9]{6}'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(a_database, a_dir) ⇒ Dump

Returns a new instance of Dump.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/pg_export/dump.rb', line 7

def initialize(a_database, a_dir)
  @database = a_database
  @dir = a_dir
  @dirname = absolute_path(dir)
  @basename = append_to_database(Time.now.strftime('%Y%m%d_%H%M%S'))
  @basename_gz = basename + '.gz'
  @regexp = Regexp.new(append_to_database(TIMESTAMP_REGEX))
  @ftp_regexp = append_to_database('*')
  @pathname = [dirname, basename].join('/')
  @pathname_gz = pathname + '.gz'
  create_dir_if_necessary
end

Instance Attribute Details

#basenameObject (readonly)

Returns the value of attribute basename.



5
6
7
# File 'lib/pg_export/dump.rb', line 5

def basename
  @basename
end

#basename_gzObject (readonly)

Returns the value of attribute basename_gz.



5
6
7
# File 'lib/pg_export/dump.rb', line 5

def basename_gz
  @basename_gz
end

#databaseObject (readonly)

Returns the value of attribute database.



5
6
7
# File 'lib/pg_export/dump.rb', line 5

def database
  @database
end

#dirObject (readonly)

Returns the value of attribute dir.



5
6
7
# File 'lib/pg_export/dump.rb', line 5

def dir
  @dir
end

#dirnameObject (readonly)

Returns the value of attribute dirname.



5
6
7
# File 'lib/pg_export/dump.rb', line 5

def dirname
  @dirname
end

#ftp_regexpObject (readonly)

Returns the value of attribute ftp_regexp.



5
6
7
# File 'lib/pg_export/dump.rb', line 5

def ftp_regexp
  @ftp_regexp
end

#pathnameObject (readonly)

Returns the value of attribute pathname.



5
6
7
# File 'lib/pg_export/dump.rb', line 5

def pathname
  @pathname
end

#pathname_gzObject (readonly)

Returns the value of attribute pathname_gz.



5
6
7
# File 'lib/pg_export/dump.rb', line 5

def pathname_gz
  @pathname_gz
end

#regexpObject (readonly)

Returns the value of attribute regexp.



5
6
7
# File 'lib/pg_export/dump.rb', line 5

def regexp
  @regexp
end

Instance Method Details

#sizeObject



20
21
22
# File 'lib/pg_export/dump.rb', line 20

def size
  file_size(pathname)
end

#size_gzObject



24
25
26
# File 'lib/pg_export/dump.rb', line 24

def size_gz
  file_size(pathname_gz)
end