Class: Checkm::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/checkm/entry.rb

Constant Summary collapse

BASE_FIELDS =
['sourcefileorurl', 'alg', 'digest', 'length', 'modtime', 'targetfileorurl']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line, manifest = nil) ⇒ Entry

Returns a new instance of Entry.



15
16
17
18
19
20
21
22
# File 'lib/checkm/entry.rb', line 15

def initialize line, manifest = nil
  @line = line.strip
  @include = false
  @fields = BASE_FIELDS
  @fields = manifest.fields if manifest and manifest.fields
  @values = line.split('|').map { |s| s.strip }
  @manifest = manifest
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



24
25
26
# File 'lib/checkm/entry.rb', line 24

def method_missing(sym, *args, &block)
  @values[@fields.index(sym.to_s.downcase) || BASE_FIELDS.index(sym.to_s.downcase)] rescue nil
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



5
6
7
# File 'lib/checkm/entry.rb', line 5

def values
  @values
end

Class Method Details

.create(path, args = {}) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/checkm/entry.rb', line 7

def self.create path, args = {}
  base = args[:base] || Dir.pwd
  alg = args[:alg] || 'md5'
  file = File.new File.join(base, path)
  
  "%s | %s | %s | %s | %s | %s" % [path, alg, Checkm.checksum(file, alg), File.size(file.path), file.mtime.utc.xmlschema, nil]
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/checkm/entry.rb', line 29

def valid?
  return source_exists? && valid_checksum? && valid_multilevel? # xxx && valid_length? && valid_modtime?
end