-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathid2noid
64 lines (54 loc) · 1.68 KB
/
id2noid
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
56
57
58
59
60
61
62
63
64
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'optparse'
require 'ostruct'
# Process the script parameters.
options = OpenStruct.new
option_parser = OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename(__FILE__)} [-f production|preview|staging] monograph_id [monograph_id...]"
opts.on('-f', '--fulcrum_host [production|preview|staging]', 'Fulcrum environment') do |fulcrum_host|
options.fulcrum_host = fulcrum_host
end
opts.on_tail('-h', '--help', 'Print this help message') do
puts opts
exit 0
end
end
option_parser.parse!(ARGV)
if ARGV.count < 1
puts option_parser.help
exit 0
end
monograph_id_list = ARGV
# Determine the root directory of the code base.
script_dir = File.expand_path(File.dirname(__FILE__))
root_dir = File.dirname(script_dir)
require 'date'
require 'fileutils'
require_relative File.join(root_dir, 'lib', 'services')
# Create the serivce for retrieving the NOID manifest.
service = UMPTG::Services::Heliotrope.new(
:fulcrum_host => options.fulcrum_host
)
monograph_noids = service.monograph_noid(identifier_list: monograph_id_list)
monograph_noids.each do |id,noid_list|
puts "#{id}:#{noid_list.count},#{noid_list.join(',')}"
end
=begin
noid_list = []
id_noid_list = []
monograph_id_list.each do |monograph_id|
#puts "*" * 10 + " #{monograph_id} " + "*" * 10
#STDOUT.flush
monograph_noid = service.monograph_noid(identifier: monograph_id)
noid_list << monograph_noid[monograph_id]
id_noid_list << "#{monograph_noid[monograph_id].first},#{monograph_id}"
end
#puts noid_list.join(' ')
#puts id_noid_list.join(' ')
puts "NOID,ISBN"
id_noid_list.each do |k|
#puts "#{k},#{v.first}"
puts k
end
=end