Class: Rubble::Resource::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rubble/resource/base.rb

Direct Known Subclasses

Database, Fileset, Webapp

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, *params) ⇒ Base

Returns a new instance of Base.



10
11
12
# File 'lib/rubble/resource/base.rb', line 10

def initialize(name, *params)
    @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/rubble/resource/base.rb', line 9

def name
  @name
end

Instance Method Details

#get_filesetsObject



28
29
30
# File 'lib/rubble/resource/base.rb', line 28

def get_filesets
    []
end

#get_version(filesets) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/rubble/resource/base.rb', line 18

def get_version(filesets)
    md = Digest::SHA1.new
    filesets.each do |fileset|
        fileset.paths.each do |path|
            md.file(path)
        end
    end
    md.hexdigest.force_encoding('UTF-8')
end

#snapshotObject



32
33
34
35
36
# File 'lib/rubble/resource/base.rb', line 32

def snapshot
    filesets = get_filesets
    version = get_version(filesets)
    Snapshot.new(version, *filesets)
end

#to_sObject



38
39
40
# File 'lib/rubble/resource/base.rb', line 38

def to_s
    to_yaml
end

#typeObject



14
15
16
# File 'lib/rubble/resource/base.rb', line 14

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