Sha256: 71a5e5ca494d9d91b53ae71047e1715d772cfd632844daea9bc42f1ab0fb1b40

Contents?: true

Size: 740 Bytes

Versions: 4

Compression:

Stored size: 740 Bytes

Contents

module SiteChecker
  module IO
    class ContentFromWeb

    	def initialize(visit_references, root)
    		@visit_references = visit_references
    		@root = root
    	end

    	def get(link)
        begin
          uri = create_absolute_reference(link.url)
          if link.local_page?
            content = open(uri)
          elsif link.local_image?
            open(uri)
          elsif @visit_references
            open(uri)
          end
        rescue => e
          raise "(#{e.message.strip})"
        end
        content
      end

      private
      def create_absolute_reference(link)
        if link.start_with?(@root)
          URI(link)
        else
          URI(@root).merge(link)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
site_checker-0.3.0 lib/site_checker/io/content_from_web.rb
site_checker-0.2.1 lib/site_checker/io/content_from_web.rb
site_checker-0.2.0 lib/site_checker/io/content_from_web.rb
site_checker-0.2.0.pre lib/site_checker/io/content_from_web.rb