Sha256: 4d68b079f4c4c6affa142a9a7699562b68eee49fd17bd32a6448b6806ba705f5
Contents?: true
Size: 873 Bytes
Versions: 1
Compression:
Stored size: 873 Bytes
Contents
require 'open-uri' class Page attr_reader :url, :source, :name def initialize(url) @name = Time.new.to_i.to_s + '_' + rand(9999).to_s @url = URI.parse(url) @source = open(url).readlines end def to_s <<-EOS.gsub(/^\s+\|\s/, '') | http.page_start("#{name}") | http.request_batch({ | {"GET", "#{url}", auto_decompress=true} | }) | | http.request_batch({ | #{asset_include.join("\n")} | }) | | http.page_end("#{name}") | | EOS end def assets @source.map do |l| l =~ /(?:\s|data-)?src="(.*?)"/ $1 if $1 end.compact.select do |l| l.include?(url.host) end end def asset_include assets.map do |url| ' {"GET", "' + url + '", auto_decompress=true},' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
load_impact-0.0.3 | lib/load_impact/page.rb |