-
Notifications
You must be signed in to change notification settings - Fork 1
/
migration_report.rb
55 lines (53 loc) · 1.71 KB
/
migration_report.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require 'hunting'
require './lib/buffalo'
require './lib/buffalo/cdm'
require './lib/buffalo/crosswalk'
require './lib/buffalo/element'
require './lib/buffalo/map'
require './lib/buffalo/report'
require 'active_support'
require 'active_support/core_ext'
require 'builder'
require 'fileutils'
require 'json'
require 'open-uri'
require 'pathname'
require 'uri'
require 'yaml'
COLLECTION = ARGV[0]
CROSSWALK = ARGV[1]
NAME = ARGV[2]
if COLLECTION == nil or CROSSWALK == nil or NAME == nil
puts "\nPlease enter a CDM collection alias, crosswalk file name from the 'dmwg' directory, and your name."\
"\n\n=== Example ===\nruby migration_report.rb p15195coll38 p15195coll38_crosswalk andy\n"
exit
else
Hunting.configure_with("O:/Metadata and Digitization Services/Metadata/Migration/config/uhdl.yml")
Buffalo.configure_with("O:/Metadata and Digitization Services/Metadata/Migration/config/#{NAME}.yml")
DMWG = Buffalo.config[:dmwg]
MAP = Buffalo.config[:map]
ITEMS = Buffalo.config[:items]
ITEM_LEVEL = Buffalo.config[:item_level]
puts ''
puts 'Loading MAP...'
bcdams = Map.new(JSON.parse(open('https://vocab.lib.uh.edu/bcdams-map/api/elements.json').read))
puts 'Loading Crosswalk...'
elements = Crosswalk.elements("#{DMWG}/#{COLLECTION}/#{CROSSWALK}.yml", bcdams)
uhdl = Repository.scout([COLLECTION])
uhdl.collections.each do |c_alias, collection|
filename = Report.migration_report(
collection,
elements,
{ path: "#{MAP}/migration",
cdm_domain: "digital.lib.uh.edu",
items: ITEMS,
item_level: ITEM_LEVEL
}
)
Buffalo.append(
"#{MAP}/_data/migration.yml",
"\n- label: \'#{filename}\'\n file: \'#{filename}\'\n"
)
end
puts "DONE"
end