Class: WebTranslateIt::Safe::Source

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

Direct Known Subclasses

Archive, Mongodump, Mysqldump, Pgdump

Instance Attribute Summary collapse

Attributes inherited from Stream

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Stream

#expand

Constructor Details

#initialize(id, config) ⇒ Source

Returns a new instance of Source.



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

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

Instance Attribute Details

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/web_translate_it/safe/source.rb', line 7

def id
  @id
end

Class Method Details

.human_nameObject



43
44
45
# File 'lib/web_translate_it/safe/source.rb', line 43

def self.human_name
  name.split('::').last.downcase
end

Instance Method Details

#backupObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/web_translate_it/safe/source.rb', line 26

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



22
23
24
# File 'lib/web_translate_it/safe/source.rb', line 22

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

#kindObject



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

def kind
  self.class.human_name
end

#timestampObject



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

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