Module: ODDB::Export::Server
- Defined in:
- lib/oddb/export/server.rb
Class Method Summary collapse
- .on_monthday(day, today = Date.today, &block) ⇒ Object
- .remote_export_chde ⇒ Object
- .remote_export_yaml ⇒ Object
- .run(today = Date.today) ⇒ Object
- .safe_export(exporter, &block) ⇒ Object
Class Method Details
.on_monthday(day, today = Date.today, &block) ⇒ Object
39 40 41 42 43 |
# File 'lib/oddb/export/server.rb', line 39 def Server.on_monthday(day, today = Date.today, &block) if(today.day == day) block.call end end |
.remote_export_chde ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/oddb/export/server.rb', line 14 def Server.remote_export_chde if(uri = ODDB.config.remote_databases.first) remote = DRb::DRbObject.new(nil, uri) safe_export(Export::Xls::ComparisonDeCh) { |exporter| remote.remote_export("chde.xls") { |path| File.open(path, 'w+') { |io| exporter.export(uri, io) } } } end end |
.remote_export_yaml ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/oddb/export/server.rb', line 24 def Server.remote_export_yaml if(uri = ODDB.config.remote_databases.first) remote = DRb::DRbObject.new(nil, uri) safe_export(Export::Yaml::Drugs) { |exporter| remote.remote_export("de.oddb.yaml") { |path| File.open(path, 'w') { |io| exporter.export(io) } } } end end |
.run(today = Date.today) ⇒ Object
34 35 36 37 38 |
# File 'lib/oddb/export/server.rb', line 34 def Server.run(today = Date.today) on_monthday(1, today) { remote_export_chde } end |
.safe_export(exporter, &block) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/oddb/export/server.rb', line 44 def Server.safe_export(exporter, &block) block.call(exporter.new) rescue StandardError => err subject = sprintf("%s: %s", Time.now.strftime('%c'), exporter) lines = [ sprintf("%s: %s#export", Time.now.strftime('%c'), exporter) ] lines.push(err.class, err., *err.backtrace) Util::Mail.notify_admins(subject, lines) end |