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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/libis/metadata/cli/cli_downloader.rb', line 18
def self.included(klass)
klass.class_exec do
desc 'download [options] [TERM[:PID] ...]', 'Download metadata from Alma or Scope'
long_desc <<-DESC
'download [TERM ...]' will download metadata from Alma or Scope and convert it to Dublin Core.
The output format can either be Dublin Core or a Rosetta MD Update file. If you supply a Rosetta IE PID the
tool will generate a Rosetta MD Update file, a Dublin Core XML file if you don't. Note that there is no
check if the IE PID is a valid one.
Any TERM argument that starts with a '@' will be interpreted as an input file name. The input file name can
be:
* a simple text file. File extension should be '.txt' and each non-empty line is interpreted as if it was
supplied as a TERM argument on the command line.
* a comma-delimited file (CSV). File extension should be '.csv'.
* a tab-deliimited file (TSV). File extension should be '.tsv'.
* a spreadsheet. Excel files (.xls or xlsx) and OpenOffice/LibreOffice Calc files (.ods) are supported.
'@<sheet_name>' must be appended to the file name to select the proper sheet tab.
For the CSV, TSV and spreadsheets: if there is no header row, the first column should contain the search
terms. If present, the second column should contain PID info and the third column FILE info. Other columns
are ignored. If there is a header row, it should contain at least a cell with the text 'Term'. That column
is expexted to contain the search terms. If a column header with the text 'Pid' is found, the column data
will be expected to contain pids for the IE's to modify. If a column header with the text 'File' is found,
the column data will be expected to contain file names to save to.
In any case, if the output file info is missing, the name defaults to the PID (if present) or the search
term. If the FILE info does not have a file extension, '.xml' will be added.
The list of TERM arguments will be processed automatically. If there are no terms supplied on the command
line, the program will ask for them until you supply an empty value. A TERM argument can contain PID and
FILE info separated by a ':' or whatever you supply for the separator option. TERM arguments supplied via
a simple text file are interpreted the same way.
Examples:
* abc => searches for 'abc' and save DC metadata in abc.xml
* abc:123 => searches for 'abc' and generates MD Update in 123.xml
* abc:123:xyz.data => searches for 'abc' and generates MD Update in xyz.data
* abc::xyz => searches for 'abc' and save DC metadata in xyz.xml
For any option that is not supplied on the command line and doesn't have a default value, the tool will
always ask you to supply a value, even if the '-q' option is given.
DESC
method_option :quiet, aliases: '-q', desc: 'Do not ask for options that have a default value',
type: :boolean, default: false
method_option :metadata, aliases: '-m', banner: 'source', desc: 'Metadata source system',
default: VALID_SOURCES.keys.first, enum: VALID_SOURCES.keys
method_option :field, aliases: '-f', banner: 'field_name', desc: 'Search field in the Metadata system;' +
" default value depends on selected metadata source system: #{VALID_SOURCES}"
method_option :library, aliases: '-l', banner: 'library_code', desc: 'Library code for Alma',
default: '32KUL_KUL'
method_option :database, aliases: '-d', desc: 'Scope database to connect to'
method_option :user, aliases: '-u', desc: 'Database user name'
method_option :password, aliases: '-p', desc: 'Database password'
method_option :target_dir, aliases: '-t', desc: 'Directory where files will be created', default: '.'
method_option :separator, aliases: '-s', desc: 'Separator for the TERM arguments', default: ':'
end
end
|