Class: ProxyFetcher::Document::Adapters
- Inherits:
-
Object
- Object
- ProxyFetcher::Document::Adapters
- Defined in:
- lib/proxy_fetcher/document/adapters.rb
Overview
ProxyFetcher HTML parser adapters.
ProxyFetcher default supported adapters are:
-
Nokogiri
-
Oga
Any custom adapter can be used and must be inherited from ProxyFetcher::Document::AbstractAdapter
.
Class Method Summary collapse
-
.lookup(name_or_class) ⇒ Object
Returns HTML parser adapter by it’s name or class.
Class Method Details
.lookup(name_or_class) ⇒ Object
Returns HTML parser adapter by it’s name or class. If name is provided, then it looks for predefined classes in ProxyFetcher::Document
namespace. Otherwise it just returns the passed class.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/proxy_fetcher/document/adapters.rb', line 28 def lookup(name_or_class) raise Exceptions::BlankAdapter if name_or_class.nil? || name_or_class.to_s.empty? case name_or_class when Symbol, String adapter_name = "#{name_or_class.to_s.capitalize}#{ADAPTER}" ProxyFetcher::Document.const_get(adapter_name) else name_or_class end rescue NameError raise Exceptions::UnknownAdapter, name_or_class end |