Class: DoiExtractor::StatusCommand
- Inherits:
-
Command
- Object
- Command
- DoiExtractor::StatusCommand
show all
- Defined in:
- lib/doi_extractor/status_command.rb
Instance Attribute Summary
Attributes inherited from Command
#log, #options, #start_time, #std_out, #user_input_callback
Instance Method Summary
collapse
Methods inherited from Command
#execute, for, #initialize
Instance Method Details
#_execute ⇒ Object
4
5
6
7
8
9
10
|
# File 'lib/doi_extractor/status_command.rb', line 4
def _execute
if options.
report_group(options.)
else
report_recent
end
end
|
#report_group(id) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/doi_extractor/status_command.rb', line 12
def report_group(id)
= ipums_client.(id)
unless
fail("no extract for #{id} found")
end
location = DownloadLocation.new(options.download_base_path, )
say_doi_summary(, location)
say("Extract Requests:")
fmt = '%-10s%25s%20s%12s'
say(sprintf(fmt.sub('i', 's'), 'ID', 'Status', 'Sample', 'Downloaded'))
..each do |er|
say(sprintf(fmt, er.id, er.completion_status, er.samples.first.name, location.(er)))
end
end
|
#report_recent ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/doi_extractor/status_command.rb', line 33
def report_recent
recent = ipums_client.
if recent.nil? || recent.empty?
say("There are no DOI extracts")
else
recent.each do |doi|
location = DownloadLocation.new(options.download_base_path, doi)
say_doi_summary(doi, location)
say("\tExtracts: #{doi..count}")
end
end
end
|
#say_doi_summary(doi_extract, location) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/doi_extractor/status_command.rb', line 47
def say_doi_summary(, location)
count_hsh = Hash.new { |h, k| h[k] = 0 }
= ..reduce(count_hsh) { |h, e| h[e.completion_status] += 1; h }
say("DOI Extract (ID: #{.id})")
say("\tStatus: #{.status}")
say("\tCreated: #{.created_at}")
say("\tSubmitted: #{.submit_date}")
say("\tFinished: #{.finish_date}")
say("\tData Available: #{.all_data_available}")
say("\tPath: #{location.path}")
say("\tExtract Counts: #{.map { |k, v| "#{k}: #{v}" }.join(', ')}")
say("\tDownloaded: #{..any? && ..all? { |er| location.(er) }}")
end
|