Module: SeisRuby::Database::GlobalCmtCatalogSearch::CmtsolutionFormat
- Defined in:
- lib/seis_ruby/database/global_cmt_catalog_search/cmtsolution_format.rb
Defined Under Namespace
Classes: CustomHtmlParser
Class Method Summary collapse
Class Method Details
.load_file(uri) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/seis_ruby/database/global_cmt_catalog_search/cmtsolution_format.rb', line 3 def load_file(uri) load_file_hook() agent = Mechanize.new{|a| a.pluggable_parser.html = ::SeisRuby::Database::GlobalCmtCatalogSearch::CmtsolutionFormat::CustomHtmlParser } agent.get(uri) events\ = agent.page.search('pre')\ .find{|e| e.text =~ /event name:/}\ .text.split("\n\n")\ .delete_if{|t| t.strip.empty?}\ .map{|text| ::SeisRuby::Data::Cmtsolution.load(text, {file: uri})} unless next_link = agent.page.links.find{|elem| elem.text == 'More solutions'} return events end events.concat(load_file(next_link.uri)) end |