-
Notifications
You must be signed in to change notification settings - Fork 14
/
lookup.rb
56 lines (48 loc) · 1.47 KB
/
lookup.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
56
require "tmpdir"
require "fileutils"
require "itunes/store/transporter/errors"
require "itunes/store/transporter/command"
module ITunes
module Store
class Transporter
module Command
##
# Retrieve the metadata for a previously delivered package.
#
class Lookup < Mode
def initialize(*config)
super
# These 2 are mutually exclusive, and one is required.
# Optout has no way to denote this
options.on *VENDOR_ID
options.on *APPLE_ID
options.on *DESTINATION
end
def run(options = {})
options[:destination] = Dir.mktmpdir
super
ensure
FileUtils.rm_rf(options[:destination]) if options[:destination]
end
protected
def handle_success(stdout_lines, stderr_lines, options)
id = options[:apple_id] || options[:vendor_id]
path = File.join(options[:destination], "#{id}.itmsp", "metadata.xml")
if !File.exists?(path)
raise TransporterError, "No metadata file exists at #{path}"
end
begin
metadata = File.read(path)
rescue StandardError => e
raise TransporterError, "Failed to read metadata file #{path}: #{e}"
end
metadata
end
def mode
"lookupMetadata"
end
end
end
end
end
end