Class: Chitin::Manifest

Inherits:
Object show all
Defined in:
lib/chitin/manifests/manifest.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeManifest

Returns a new instance of Manifest.



32
33
# File 'lib/chitin/manifests/manifest.rb', line 32

def initialize
end

Class Method Details

.find(name) ⇒ Object

retrieve the manifest entry for the name



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/chitin/manifests/manifest.rb', line 11

def self.find(name)
  manifest_path = File.expand_path '.chitin_manifest'
  manifest      = File.read manifest_path
  manifest_hmac = manifest_data[0..511]
  manifest_data = manifest_data[512..-1]

  # verify the authenticity of the file
  computed_hmac = OpenSSL::HMAC.hexdigest('sha256',
                                          @@password_hash,
                                          manifest_data)

  unless computed_hmac == manifest_hmac
    puts "MANIFEST FILE HAS BEEN TAMPERED WITH"
    return {}
  end

  @@data ||= {}
  @@data[manifest_path] ||= YAML.load manifest_data
  @@data[manifest_path][name]
end

.register(hash) ⇒ Object



6
7
8
# File 'lib/chitin/manifests/manifest.rb', line 6

def self.register(hash)
  @@password_hash = hash
end