Sha256: 1facb5a761895f220a9508c9ead2cfa2fdb01b67c766a9f5b5c16daac69ba784
Contents?: true
Size: 1.45 KB
Versions: 4
Compression:
Stored size: 1.45 KB
Contents
module Sniffles module Sniffers class Wordpress include HTML attr_accessor :doc attr_reader :name, :group, :output, :response def initialize(response_body) @output = {} parse(response_body) && process_document end def process_document if @output[:found] = found? parse_version parse_feed parse_theme parse_pingback end end private def found? @doc.xpath('//link[contains(@href,"wp-content")]').any? end def parse_feed @output[:feed] = text_at("//link[@rel='alternate' and @type='application/rss+xml']/@href") end def parse_theme theme_uri = text_at("//link[@rel='stylesheet' and contains(@href,'wp-content/themes/')][1]/@href") @output[:theme] = (theme_uri ? clean_theme_uri(theme_uri)[1] : false) end def parse_version version_meta_tag = text_at("//meta[@name='generator']/@content") @output[:version] = (version_meta_tag ? extract_version(version_meta_tag)[1] : version_meta_tag) end def parse_pingback @output[:pingback] = text_at("//link[@rel='pingback']/@href") end def clean_theme_uri(uri) /wp-content\/themes\/([^\/]*)\//i.match uri end def extract_version(string) /([\d]+\.[\d]+[\.]?[\d]?)/.match string end end end end
Version data entries
4 entries across 4 versions & 1 rubygems