Class: Stanford::DorMetadata

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

Overview

Note:

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

Stanford-specific utility methods for interfacing with DOR metadata files

Data Model

  • DorMetadata = utility methods for interfacing with Stanford metadata files (esp contentMetadata)

    • ContentInventory [1..1] = utilities for transforming contentMetadata to versionInventory and doing comparsions

    • ActiveFedoraObject [1..*] = utility for extracting content or other information from a Fedora Instance

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(digital_object_id, version_id = nil) ⇒ Stanford::DorMetadata

Parameters:

  • digital_object_id (String)

    The digital object identifier

  • version_id (Integer) (defaults to: nil)

    The ordinal version number



25
26
27
28
# File 'lib/stanford/dor_metadata.rb', line 25

def initialize(digital_object_id, version_id=nil)
  @digital_object_id = digital_object_id
  @version_id = version_id
end

Instance Attribute Details

#digital_object_idString

Returns The digital object identifier (druid).

Returns:

  • (String)

    The digital object identifier (druid)



17
18
19
# File 'lib/stanford/dor_metadata.rb', line 17

def digital_object_id
  @digital_object_id
end

#version_idInteger

Returns @versionId = The ordinal version number.

Returns:

  • (Integer)

    @versionId = The ordinal version number



20
21
22
# File 'lib/stanford/dor_metadata.rb', line 20

def version_id
  @version_id
end

Instance Method Details

#inventory_from_directory(directory, version_id = nil) ⇒ FileInventory

Returns Inventory of the files under the specified directory.

Parameters:

  • directory (String)

    The location of the directory to be inventoried

  • version_id (Integer) (defaults to: nil)

    The ordinal version number

Returns:

  • (FileInventory)

    Inventory of the files under the specified directory



34
35
36
37
38
39
40
41
42
43
# File 'lib/stanford/dor_metadata.rb', line 34

def inventory_from_directory(directory, version_id=nil)
  version_id ||= @version_id
  version_inventory = FileInventory.new(:type=>'version',:digital_object_id=>@digital_object_id, :version_id=>version_id)
   = IO.read(File.join(directory,'contentMetadata.xml'))
  content_group = ContentInventory.new.group_from_cm(, 'preserve' )
  version_inventory.groups << content_group
   = FileGroup.new(:group_id=>'metadata').group_from_directory(directory)
  version_inventory.groups << 
  version_inventory
end