Class: ODDB::Plugin

Inherits:
Object show all
Includes:
HttpFile
Defined in:
src/plugin/plugin.rb

Direct Known Subclasses

AnalysisPlugin, BsvXmlPlugin, CoMarketingPlugin, CsvExportPlugin, Doctors::DoctorPlugin, FiPDFExporter, HospitalPlugin, Interaction::FlockhartPlugin, Interaction::HayesPlugin, Interaction::InteractionPlugin, Invoicer, LppvPlugin, MedwinPlugin, MiGeLPlugin, MiniFiPlugin, NarcoticPlugin, OdbaExporter::OddbDatExport, OuwerkerkPlugin, RssPlugin, SwissmedicJournalPlugin, SwissmedicPlugin, SwissregPlugin, TextInfoPlugin, VaccinePlugin, WhoPlugin, XlsExportPlugin, YamlExporter, YdimPlugin

Defined Under Namespace

Classes: SessionStub

Constant Summary

ARCHIVE_PATH =
File.expand_path('../../data', File.dirname(__FILE__))
RECIPIENTS =

Recipients for Plugin-Specific Update-Logs can be added in ‘Plugin’s subclasses

[]

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from HttpFile

#http_body, #http_file

Constructor Details

- (Plugin) initialize(app)

A new instance of Plugin



37
38
39
40
# File 'src/plugin/plugin.rb', line 37

def initialize(app)
  @app = app
  @change_flags = {}
end

Instance Attribute Details

- (Object) change_flags (readonly)

Returns the value of attribute change_flags



36
37
38
# File 'src/plugin/plugin.rb', line 36

def change_flags
  @change_flags
end

- (Object) month (readonly)

Returns the value of attribute month



36
37
38
# File 'src/plugin/plugin.rb', line 36

def month
  @month
end

Instance Method Details

- (Object) l10n_sessions(&block)



41
42
43
44
45
46
47
48
# File 'src/plugin/plugin.rb', line 41

def l10n_sessions(&block)
  stub = SessionStub.new(@app)
  LookandfeelBase::DICTIONARIES.each_key { |lang|
    stub.language = lang
    stub.lookandfeel = LookandfeelBase.new(stub)
    block.call(stub)
  }
end

- (Object) log_info



49
50
51
52
53
54
# File 'src/plugin/plugin.rb', line 49

def log_info
  [:change_flags, :report, :recipients].inject({}) { |inj, key|
    inj.store(key, self.send(key))
    inj
  }
end

- (Object) recipients



55
56
57
# File 'src/plugin/plugin.rb', line 55

def recipients
  @recipients ||= self::class::RECIPIENTS.dup
end

- (Object) report



58
59
60
# File 'src/plugin/plugin.rb', line 58

def report
  ''
end


61
62
63
64
65
66
67
68
69
70
71
# File 'src/plugin/plugin.rb', line 61

def resolve_link(model)
  pointer = model.pointer
  str = if(model.respond_to?(:name_base)) 
    (model.name_base.to_s + ': ').ljust(50) 
  else
    ''
  end
  str << 'http://ch.oddb.org/de/gcc/resolve/pointer/' << CGI.escape(pointer.to_s) << ' '
rescue StandardError
  "Error creating Link for #{pointer.inspect}"
end

- (Object) update_rss_feeds(name, model, view_klass)



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'src/plugin/plugin.rb', line 72

def update_rss_feeds(name, model, view_klass)
  return if model.empty?
  l10n_sessions { |stub|
    view = view_klass.new(model, stub, nil)
    path = File.join(RSS_PATH, stub.language, name)
    tmp = File.join(RSS_PATH, stub.language, '.' << name)
    FileUtils.mkdir_p(File.dirname(path))
    File.open(tmp, 'w') { |fh|
      fh.puts view.to_html(CGI.new('html4'))
    }
    File.mv(tmp, path)
  }
  @app.rss_updates[name] = [@month || @@today, model.size]
  @app.odba_isolated_store
end