Sha256: 6f79aad9f9fed3b47e84f697dd0d9528fcc07fdeff6de51a9ccde00387ef2617

Contents?: true

Size: 437 Bytes

Versions: 3

Compression:

Stored size: 437 Bytes

Contents

require 'net/http'

module Prawn::SVG::Loaders
  class Web
    def from_url(url)
      uri = build_uri(url)

      perform_request(uri) if uri && %w[http https].include?(uri.scheme)
    end

    private

    def build_uri(url)
      URI(url)
    rescue URI::InvalidURIError
    end

    def perform_request(uri)
      Net::HTTP.get(uri)
    rescue StandardError => e
      raise Prawn::SVG::UrlLoader::Error, e.message
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
prawn-svg-0.36.0 lib/prawn/svg/loaders/web.rb
prawn-svg-0.35.1 lib/prawn/svg/loaders/web.rb
prawn-svg-0.35.0 lib/prawn/svg/loaders/web.rb