Class: Moab::FileManifestation

Inherits:
Serializable
  • Object
show all
Includes:
HappyMapper
Defined in:
lib/moab/file_manifestation.rb

Overview

Note:

Copyright © 2012 by The Board of Trustees of the Leland Stanford Junior University. All rights reserved. See LICENSE for details.

A container for a file signature and all the physical file instances that have that signature This element has one child FileSignature element, and one or more FileInstance elements Regarding the class name, see

Data Model

  • FileInventory = container for recording information about a collection of related files

    • FileGroup [1..*] = subset allow segregation of content and metadata files.

      • FileManifestation [1..*] = snapshot of a file’s filesystem characteristics

        • FileSignature [1] = file fixity information

        • FileInstance [1..*] = filepath and timestamp of any physical file having that signature

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ FileManifestation

Returns a new instance of FileManifestation.



27
28
29
30
# File 'lib/moab/file_manifestation.rb', line 27

def initialize(opts={})
  @instances = Array.new
  super(opts)
end

Instance Attribute Details

#instancesArray<FileInstance>

Returns The location(s) of the file manifestation’s file instances.

Returns:

  • (Array<FileInstance>)

    The location(s) of the file manifestation’s file instances



46
# File 'lib/moab/file_manifestation.rb', line 46

has_many :instances, FileInstance, :tag => 'fileInstance'

#signatureFileSignature

Returns The fixity data of the file instance.

Returns:



34
# File 'lib/moab/file_manifestation.rb', line 34

element :signature, FileSignature, :tag => 'fileSignature'

Instance Method Details

#==(other) ⇒ Boolean

Returns True if Moab::FileManifestation objects have same content.

Parameters:

Returns:



79
80
81
# File 'lib/moab/file_manifestation.rb', line 79

def ==(other)
  (self.signature == other.signature) && (self.instances == other.instances)
end

#block_countInteger

Returns The total disk usage (in 1 kB blocks) of all files that share this manifestation’s signature (estimating du -k result).

Returns:

  • (Integer)

    The total disk usage (in 1 kB blocks) of all files that share this manifestation’s signature (estimating du -k result)



70
71
72
73
74
# File 'lib/moab/file_manifestation.rb', line 70

def block_count
  block_size=1024
  instance_blocks = (signature.size.to_i + block_size - 1)/block_size
  file_count * instance_blocks
end

#byte_countInteger

Returns The total size (in bytes) of all files that share this manifestation’s signature.

Returns:

  • (Integer)

    The total size (in bytes) of all files that share this manifestation’s signature



63
64
65
# File 'lib/moab/file_manifestation.rb', line 63

def byte_count
  file_count.to_i * signature.size.to_i
end

#file_countInteger

Returns The total number of Moab::FileInstance objects in this manifestation. (Number of files that share this manifestation’s signature).

Returns:

  • (Integer)

    The total number of Moab::FileInstance objects in this manifestation. (Number of files that share this manifestation’s signature)



57
58
59
# File 'lib/moab/file_manifestation.rb', line 57

def file_count
  instances.size
end

#pathsArray<String>

Returns Create an array from all the file paths of the child Moab::FileInstance objects.

Returns:



50
51
52
# File 'lib/moab/file_manifestation.rb', line 50

def paths
  instances.collect { |i| i.path}
end