Sha256: becbd9e3dd47a94b1b5527cf65b4a6149b2ea099a0d2811a234be7dc47dc8e50
Contents?: true
Size: 788 Bytes
Versions: 38
Compression:
Stored size: 788 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) paths.collect{|n| n[node].to_s }.select{|n|n && n =~/\w/ && n.internal_path? } end end end end
Version data entries
38 entries across 38 versions & 1 rubygems