lib/scraper.rb in cyx-scraper-0.3.0 vs lib/scraper.rb in cyx-scraper-0.3.1
- old
+ new
@@ -5,17 +5,18 @@
autoload :Article, 'scraper/article'
autoload :Youtube, 'scraper/youtube'
autoload :Vimeo, 'scraper/vimeo'
autoload :Modules, 'scraper/modules'
- HANDLERS = [ :Youtube, :Article ]
+ HANDLERS = [ :Youtube, :Vimeo, :Article ]
end
def Scraper( args = {} )
- if handler = Scraper::HANDLERS.detect { |h| Scraper.const_get(h) =~ args }
- Scraper.const_get( handler ).new( args )
- else
- raise ArgumentError, "Scraper cannot handle content from #{args}"
+ Scraper::HANDLERS.each do |handler|
+ if object = (Scraper.const_get(handler) =~ args)
+ return object
+ end
end
+ raise ArgumentError, "Scraper cannot handle content from #{args}"
end
$LOAD_PATH.unshift( File.dirname(__FILE__) )
\ No newline at end of file