class Text::Checkm::Entry
Constants
- BASE_FIELDS
Attributes
values[R]
Public Class Methods
create(path, args = {})
click to toggle source
# File lib/text/checkm/entry.rb, line 12 def self.create(path, args = {}) # TODO: why is this in this class? base = args[:base] || Dir.pwd alg = args[:alg] || 'md5' file = File.new File.join(base, path) format('%s | %s | %s | %s | %s | %s', path, alg, Checkm.checksum(file, alg), File.size(file.path), file.mtime.utc.xmlschema, nil) end
new(line, manifest = nil)
click to toggle source
# File lib/text/checkm/entry.rb, line 20 def initialize(line, manifest = nil) @line = line.strip @include = false @fields = BASE_FIELDS @fields = manifest.fields if manifest && manifest.fields @values = line.split('|').map(&:strip) @manifest = manifest end
Public Instance Methods
method_missing(sym, *_args)
click to toggle source
# File lib/text/checkm/entry.rb, line 29 def method_missing(sym, *_args) # TODO: something less extreme @values[@fields.index(sym.to_s.downcase) || BASE_FIELDS.index(sym.to_s.downcase)] end
respond_to_missing?(sym, *)
click to toggle source
# File lib/text/checkm/entry.rb, line 34 def respond_to_missing?(sym, *) @fields.include?(sym.to_s.downcase) || BASE_FIELDS.include?(sym.to_s.downcase) end
valid?()
click to toggle source
# File lib/text/checkm/entry.rb, line 38 def valid? source_exists? && valid_checksum? && valid_multilevel? # xxx && valid_length? && valid_modtime? end
Private Instance Methods
source()
click to toggle source
# File lib/text/checkm/entry.rb, line 44 def source file = sourcefileorurl file = file[1..] if file =~ /^@/ File.join(@manifest.path, file) end
source_exists?()
click to toggle source
# File lib/text/checkm/entry.rb, line 50 def source_exists? File.exist? source end
valid_checksum?()
click to toggle source
# File lib/text/checkm/entry.rb, line 54 def valid_checksum? file = File.new source checksum = Checkm.checksum(file, alg) [true, digest].include?(checksum) # TODO: something less counterintuitive end
valid_multilevel?()
click to toggle source
def valid_length?
throw NotImplementedError
end
def valid_modtime?
throw NotImplementedError
end
# File lib/text/checkm/entry.rb, line 68 def valid_multilevel? return true unless sourcefileorurl =~ /^@/ Manifest.parse(File.read(source), path: File.dirname(source)) end