Class: Checkm::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/checkm.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.



129
130
131
132
133
134
135
136
# File 'lib/checkm.rb', line 129

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



138
139
140
# File 'lib/checkm.rb', line 138

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.



119
120
121
# File 'lib/checkm.rb', line 119

def values
  @values
end

Class Method Details

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



121
122
123
124
125
126
127
# File 'lib/checkm.rb', line 121

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)


143
144
145
# File 'lib/checkm.rb', line 143

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