Class: Astrails::Safe::Source

Inherits:
Stream
  • Object
show all
Defined in:
lib/astrails/safe/source.rb

Direct Known Subclasses

Archive, Mysqldump, Pgdump, Svndump

Instance Attribute Summary collapse

Attributes inherited from Stream

#config

Instance Method Summary collapse

Methods inherited from Stream

#expand

Constructor Details

#initialize(id, config) ⇒ Source

Returns a new instance of Source.



6
7
8
# File 'lib/astrails/safe/source.rb', line 6

def initialize(id, config)
  @id, @config = id.to_s, config
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/astrails/safe/source.rb', line 5

def id
  @id
end

Instance Method Details

#backupObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/astrails/safe/source.rb', line 22

def backup
  return @backup if @backup
  @backup = Backup.new(
    :id        => @id,
    :kind      => kind,
    :extension => extension,
    :command   => command,
    :timestamp => timestamp
  )
  # can't do this in the initializer hash above since
  # filename() calls expand() which requires @backup
  # FIXME: move expansion to the backup (last step in ctor) assign :tags here
  @backup.filename = filename
  @backup
end

#filenameObject



18
19
20
# File 'lib/astrails/safe/source.rb', line 18

def filename
  @filename ||= expand(":kind-:id.:timestamp")
end

#kindObject



14
15
16
# File 'lib/astrails/safe/source.rb', line 14

def kind
  self.class.human_name
end

#timestampObject



10
11
12
# File 'lib/astrails/safe/source.rb', line 10

def timestamp
  Time.now.strftime("%y%m%d-%H%M")
end