Class: Moab::FileManifestation

Inherits:
Serializer::Serializable 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

Methods inherited from Serializer::Serializable

#array_to_hash, deep_diff, #diff, #key, #key_name, #summary, #to_hash, #to_json, #to_yaml, #variable_names, #variables

Constructor Details

#initialize(opts = {}) ⇒ FileManifestation

Returns a new instance of FileManifestation.



24
25
26
27
# File 'lib/moab/file_manifestation.rb', line 24

def initialize(opts = {})
  @instances = []
  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



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

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

#signatureFileSignature

Returns The fixity data of the file instance.

Returns:



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

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

Instance Method Details

#==(other) ⇒ Boolean

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

Parameters:

Returns:



76
77
78
79
# File 'lib/moab/file_manifestation.rb', line 76

def ==(other)
  return false unless other.respond_to?(:signature) && other.respond_to?(:instances) # Cannot equal an incomparable type!
  (signature == other.signature) && (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)



67
68
69
70
71
# File 'lib/moab/file_manifestation.rb', line 67

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



60
61
62
# File 'lib/moab/file_manifestation.rb', line 60

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)



54
55
56
# File 'lib/moab/file_manifestation.rb', line 54

def file_count
  instances.size
end

#pathsArray<String>

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

Returns:

  • (Array<String>)

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



47
48
49
# File 'lib/moab/file_manifestation.rb', line 47

def paths
  instances.collect(&:path)
end