Module: DerivativeRodeo::Services::UrlService
- Defined in:
- lib/derivative_rodeo/services/url_service.rb
Overview
Note:
It is a good design idea to wrap a library (in this case HTTParty). The goal is to expose the smallest interface and make it something that would be easy to swap out.
A utility class for handling general URLs. Provided as a means of easing the implementation logic of those that use this class.
Class Method Summary collapse
Class Method Details
.exists?(url) ⇒ URI, FalseClass
34 35 36 37 38 39 |
# File 'lib/derivative_rodeo/services/url_service.rb', line 34 def self.exists?(url) HTTParty.head(url, logger: DerivativeRodeo.config.logger) rescue StandardError => e DerivativeRodeo.config.logger.error(%(#{e.}\n#{e.backtrace.join("\n")})) false end |
.read(url) ⇒ String
21 22 23 24 25 26 |
# File 'lib/derivative_rodeo/services/url_service.rb', line 21 def self.read(url) HTTParty.get(url, logger: DerivativeRodeo.config.logger).body rescue StandardError => e DerivativeRodeo.config.logger.error(%(#{e.}\n#{e.backtrace.join("\n")})) raise e end |