Sha256: 733444932e011bc805b3bbaeec2c327fdd2128d7480a037484871470ac7cbce6

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

module Sniffles
  module Sniffers
    class Vbulletin
      include HTML
      
      attr_accessor :doc
      attr_reader :output
      
      def initialize(response_body)
        @output = {}        
        parse(response_body) && process_document
      end
      
      def process_document
        if @output[:found] = found?
          parse_version
          parse_feed
        end
      end
      
      private
      def found?
        !!(js_initialization? || meta_generator_content =~ /vBulletin/)
      end
      
      def parse_feed
        @output[:feed] = text_at("//link[@type='application/rss+xml']/@href")
      end
      
      def parse_version
        if meta_generator_content
          @output[:version] = (meta_generator_content.match(/([\d]+\.[\d]+\.[\d]+)/) ? $1 : false)
        else
          @output[:version] = false
        end
      end
      
      def meta_generator_content
        text_at("//meta[@name='generator']/@content")
      end
      
      def js_initialization?
        @doc.xpath("//script[contains(text(),'vBulletin_init()')]").any?
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sniffles-0.1.5 lib/sniffles/sniffers/cms/vbulletin.rb
sniffles-0.1.4 lib/sniffles/sniffers/cms/vbulletin.rb
sniffles-0.1.3 lib/sniffles/sniffers/cms/vbulletin.rb