Class: ODDB::XlsExportPlugin

Inherits:
Plugin show all
Defined in:
src/plugin/xls_export.rb

Constant Summary

EXPORT_SERVER =
DRbObject.new(nil, EXPORT_URI)
EXPORT_DIR =
File.join(ARCHIVE_PATH, 'downloads')
RECIPIENTS =
[
  'Josef.Hunkeler@pue.admin.ch',
]

Constants inherited from Plugin

ARCHIVE_PATH, RECIPIENTS

Instance Method Summary (collapse)

Methods inherited from Plugin

#initialize, #l10n_sessions, #recipients, #resolve_link, #update_rss_feeds

Methods included from HttpFile

#http_body, #http_file

Constructor Details

This class inherits a constructor from ODDB::Plugin

Instance Method Details

- (Object) export_competition(company, db_path = nil)



13
14
15
16
17
18
19
# File 'src/plugin/xls_export.rb', line 13

def export_competition(company, db_path=nil)
  dir = File.join(ARCHIVE_PATH, "xls")
  file = "#{company.name}.Preisvergleich.xls".tr(' ', '_')
  @file_path = File.join(dir, file)
  @recipients = [company.competition_email]
  EXPORT_SERVER.export_competition_xls(company.odba_id, dir, file, db_path)
end

- (Object) export_generics



20
21
22
23
24
# File 'src/plugin/xls_export.rb', line 20

def export_generics
  name = 'generics.xls'
  @file_path = File.join(EXPORT_DIR, name)
  EXPORT_SERVER.export_generics_xls(EXPORT_DIR, name)
end

- (Object) export_patents(range = @@today...(@@today >> 24))



25
26
27
28
29
30
31
32
33
34
# File 'src/plugin/xls_export.rb', line 25

def export_patents(range = @@today...(@@today >> 24))
  cutoff = @@today >> 24
  regs = @app.sorted_patented_registrations.select { |reg|
    range.include? reg.patent.expiry_date
  }
  ids = regs.collect { |reg| reg.odba_id }
  name = 'patents.xls'
  @file_path = File.join(EXPORT_DIR, name)
  @nil_data = EXPORT_SERVER.export_patent_xls(ids, EXPORT_DIR, name)
end

- (Object) log_info



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'src/plugin/xls_export.rb', line 35

def log_info
  hash = super
  if @file_path
    hash.update({
      :files     => { @file_path => "application/vnd.ms-excel"},
      :recipients => recipients,
    })
  end
  if @nil_data
    hash[:report] += "\n\nThere is nil data in the patents.xls file. " +
                     "Most probably \"Bezeichnung\" is missing.\n" + 
                     @nil_data.join("\n")
  end
  hash
end

- (Object) report



50
51
52
# File 'src/plugin/xls_export.rb', line 50

def report
  @file_path.to_s
end