Class: Checkm::Manifest

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(checkm, args = {}) ⇒ Manifest

Returns a new instance of Manifest.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/checkm.rb', line 35

def initialize checkm, args = {}
  @args = args
  @version = nil
  @checkm = checkm
  @lines = checkm.split "\n"
  @entries = []
  @eof = false
  @fields= nil
  @path = args[:path]
  @path ||= Dir.pwd
  parse_lines 
  # xxx error on empty entries?
  @lines.unshift('#%checkm_0.7') and @version = '0.7' if @version.nil?

end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



31
32
33
# File 'lib/checkm.rb', line 31

def entries
  @entries
end

#fieldsObject (readonly)

Returns the value of attribute fields.



32
33
34
# File 'lib/checkm.rb', line 32

def fields
  @fields
end

#pathObject (readonly)

Returns the value of attribute path.



33
34
35
# File 'lib/checkm.rb', line 33

def path
  @path
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Class Method Details

.parse(str, args = {}) ⇒ Object



26
27
28
# File 'lib/checkm.rb', line 26

def self.parse str, args = {}
  Manifest.new str, args
end

Instance Method Details

#add(path, args = {}) ⇒ Object



56
57
58
59
60
# File 'lib/checkm.rb', line 56

def add path, args = {}
  line = Checkm::Entry.create path, args

  Checkm::Manifest.new [@lines, line].flatten.join("\n"), @args
end

#remove(path) ⇒ Object



62
63
64
# File 'lib/checkm.rb', line 62

def remove path
  Checkm::Manifest.new @lines.reject { |x| x =~ /^@?#{path}/ }.join("\n"), @args
end

#to_sObject



66
67
68
# File 'lib/checkm.rb', line 66

def to_s
  @lines.join("\n")
end

#valid?Boolean

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/checkm.rb', line 51

def valid?
  return true if @entries.empty?
  not @entries.map { |e| e.valid? }.any? { |b| b == false }
end