Class: Stanford::MoabStorageDirectory
- Inherits:
-
Object
- Object
- Stanford::MoabStorageDirectory
- Defined in:
- lib/stanford/moab_storage_directory.rb
Overview
methods for dealing with a directory which stores Moab objects
Constant Summary collapse
- DRUID_TREE_REGEXP =
'[[:lower:]]{2}/\\d{3}/[[:lower:]]{2}/\\d{4}'
- DRUID_REGEXP =
'[[:lower:]]{2}\\d{3}[[:lower:]]{2}\\d{4}'
Class Method Summary collapse
Class Method Details
.find_moab_paths(storage_dir) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/stanford/moab_storage_directory.rb', line 12 def self.find_moab_paths(storage_dir) Find.find(storage_dir) do |path| Find.prune unless File.directory?(path) # don't bother with a matching on files, we only care about directories path_match_data = storage_dir_regexp(storage_dir).match(path) if path_match_data yield path_match_data[1], path, path_match_data # yield the druid, the full path, and the MatchData object Find.prune # we don't care about what's in the moab dir, we just want the paths that look like moabs end end end |
.list_moab_druids(storage_dir) ⇒ Object
23 24 25 26 27 |
# File 'lib/stanford/moab_storage_directory.rb', line 23 def self.list_moab_druids(storage_dir) druids = [] find_moab_paths(storage_dir) { |druid, _path, _path_match_data| druids << druid } druids end |