Module: ODDB::Util::Updater

Defined in:
lib/oddb/util/updater.rb

Class Method Summary collapse

Class Method Details

._reported_import(importer, subject = nil, &block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/oddb/util/updater.rb', line 20

def Updater._reported_import(importer, subject=nil, &block)
  lines = [
    sprintf("%s: %s#import", Time.now.strftime('%c'), importer.class)
  ]
  lines.concat block.call
rescue StandardError => err
  lines.push(err.class.to_s, err.message, *err.backtrace)
  if importer.respond_to?(:report)
    lines.concat importer.report rescue [$!.message]
  end
  raise
ensure
  subject = sprintf("%s: %s", 
                    Time.now.strftime('%c'), subject || importer.class)
  Mail.notify_admins(subject, lines)
end

.import_whocc_guidelinesObject



13
14
15
16
# File 'lib/oddb/util/updater.rb', line 13

def Updater.import_whocc_guidelines
  reported_import(Import::Whocc::Guidelines.new, 
                  WWW::Mechanize.new)
end

.reported_import(importer, io, subject = nil) ⇒ Object



17
18
19
# File 'lib/oddb/util/updater.rb', line 17

def Updater.reported_import(importer, io, subject=nil)
  _reported_import(importer, subject) { importer.import io }
end

.run(today = Date.today) ⇒ Object



36
37
38
# File 'lib/oddb/util/updater.rb', line 36

def Updater.run(today = Date.today)
  ## disabled until 2.0
end