Class: Oddb2xml::Downloader
- Inherits:
-
Object
- Object
- Oddb2xml::Downloader
- Defined in:
- lib/oddb2xml/downloader.rb
Direct Known Subclasses
BagXmlDownloader, EphaDownloader, LppvDownloader, MedregbmDownloader, MigelDownloader, RefdataDownloader, SwissmedicDownloader, SwissmedicInfoDownloader, ZurroseDownloader
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #init ⇒ Object
-
#initialize(options = {}, url = nil) ⇒ Downloader
constructor
A new instance of Downloader.
- #report_download(url, file) ⇒ Object
Constructor Details
#initialize(options = {}, url = nil) ⇒ Downloader
Returns a new instance of Downloader.
40 41 42 43 44 45 46 47 |
# File 'lib/oddb2xml/downloader.rb', line 40 def initialize(={}, url=nil) @options = @url = url @retry_times = 3 HTTPI.log = false # disable httpi warning Oddb2xml.log "Downloader from #{@url} for #{self.class}" init end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
39 40 41 |
# File 'lib/oddb2xml/downloader.rb', line 39 def agent @agent end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
39 40 41 |
# File 'lib/oddb2xml/downloader.rb', line 39 def type @type end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
39 40 41 |
# File 'lib/oddb2xml/downloader.rb', line 39 def url @url end |
Instance Method Details
#init ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/oddb2xml/downloader.rb', line 54 def init @agent = Mechanize.new @agent.user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0' @agent.redirect_ok = true @agent.redirection_limit = 5 @agent. = true if RUBY_PLATFORM =~ /mswin|mingw|bccwin|cygwin/i and ENV['SSL_CERT_FILE'].nil? cert_store = OpenSSL::X509::Store.new cert_store.add_file(File.('../../../tools/cacert.pem', __FILE__)) @agent.cert_store = cert_store end @agent.verify_mode = OpenSSL::SSL::VERIFY_NONE end |