Class: XABA::Manifest

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

Defined Under Namespace

Classes: AssemblyInfo

Constant Summary collapse

HEADER =
"Hash 32     Hash 64             Blob ID  Blob idx  Name"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(assemblies = nil) ⇒ Manifest

Returns a new instance of Manifest.



51
52
53
# File 'lib/xaba/manifest.rb', line 51

def initialize(assemblies = nil)
  @assemblies = assemblies
end

Instance Attribute Details

#assembliesObject

Returns the value of attribute assemblies.



5
6
7
# File 'lib/xaba/manifest.rb', line 5

def assemblies
  @assemblies
end

Class Method Details

.read(fname = "assemblies.manifest") ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/xaba/manifest.rb', line 31

def self.read(fname = "assemblies.manifest")
  lines = File.readlines(fname).map(&:chomp).map(&:split)
  header = lines.shift
  raise "invalid header: #{header.inspect}" if header != HEADER.split

  assemblies = lines.map do |line|
    AssemblyInfo.new(*line)
  end

  new assemblies
end

Instance Method Details

#each(&block) ⇒ Object



55
56
57
# File 'lib/xaba/manifest.rb', line 55

def each(&block)
  @assemblies.each(&block)
end

#write(f) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/xaba/manifest.rb', line 43

def write(f)
  data = [HEADER] + @assemblies.map do |a|
                      format("0x%08x  0x%016x  %03d      %04d      %s",
                             a.hash32, a.hash64, a.blob_id, a.blob_idx, a.name)
                    end
  f.write("#{data.join("\n")}\n")
end