Sha256: 70b3dbc9b5fc4c33b1764bb828d3bd2803c127a775187970a5c69ddd61f5e936
Contents?: true
Size: 844 Bytes
Versions: 12
Compression:
Stored size: 844 Bytes
Contents
require 'nokogiri' module Trackman module Assets class HtmlAsset < Asset include Components::CompositeAsset def document @doc ||= Nokogiri::HTML(data) end def img_paths @images_paths ||= refine_path(document.css('img'), 'src') end def js_paths @js_paths ||= refine_path(document.xpath('//script'), 'src') end def css_paths @css_paths ||= refine_path(document.xpath('//link[@type="text/css"]'), 'href') end def children_paths @children_paths ||= img_paths + js_paths + css_paths + inner_css_paths end def refine_path(paths, node) temp = paths.map{|n| n[node].to_s.gsub(/\?[^\?]*$/, '') } temp.select{|n| n && n =~ /\w/ && n.internal_path? && !n.embedded? } end end end end
Version data entries
12 entries across 12 versions & 1 rubygems