Class: ODDB::Interaction::HayesPlugin

Inherits:
Plugin show all
Defined in:
src/plugin/hayes.rb,
test/test_plugin/hayes.rb

Constant Summary

HTTP_SERVER =
'www.edhayes.com'
HTML_PATH =
''
TARGET =
File.expand_path('../../test/data/html/interaction/hayes', File.dirname(__FILE__))
TABLES =
{
  :substrate    => "CYP450-1.html",
  :interaction  => "CYP450-2.html",
}
RETRIES =
3
RETRY_WAIT =
5

Constants inherited from Plugin

ARCHIVE_PATH, RECIPIENTS

Instance Method Summary (collapse)

Methods inherited from Plugin

#l10n_sessions, #log_info, #recipients, #report, #resolve_link, #update_rss_feeds

Methods included from HttpFile

#http_body, #http_file

Constructor Details

- (HayesPlugin) initialize(app)

A new instance of HayesPlugin



174
175
176
# File 'src/plugin/hayes.rb', line 174

def initialize(app)
  @app = app
end

Instance Method Details

- (Object) fetch_pages



177
178
179
180
181
182
183
# File 'src/plugin/hayes.rb', line 177

def fetch_pages
  TABLES.each { |key, value|
    path = [HTML_PATH, value].join("/")
    target = [TARGET, value].join("/")
    http_file(HTTP_SERVER, path, target)
  }
end

- (Object) parse_interaction_table



193
194
195
196
197
198
199
200
201
# File 'src/plugin/hayes.rb', line 193

def parse_interaction_table
  writer = HayesWriter.new
  formatter = HtmlFormatter.new(writer)
  parser = HtmlParser.new(formatter)
  file = [TARGET, TABLES[:interaction]].join("/")
  html = File.read(file)
  parser.feed(html)
  writer.extract_data
end

- (Object) parse_substrate_table



184
185
186
187
188
189
190
191
192
# File 'src/plugin/hayes.rb', line 184

def parse_substrate_table
  writer = HayesWriter.new
  formatter = HtmlFormatter.new(writer)
  parser = HtmlParser.new(formatter)
  file = [TARGET, TABLES[:substrate]].join("/")
  html = File.read(file)
  parser.feed(html)
  writer.extract_data
end