Sha256: b2d12e50092154538327503312b42cd101aa124370eddb8b35c360e66907f064

Contents?: true

Size: 683 Bytes

Versions: 9

Compression:

Stored size: 683 Bytes

Contents

Prospectus.extra_dep('url_xpath', 'nokogiri')

require 'open-uri'

module LogCabin
  module Modules
    ##
    # Pull state from a GitHub tag
    module UrlXpath
      include Prospectus.helpers.find(:regex)

      def load!
        fail('No url provided') unless @url
        fail('No xpath provided') unless @xpath
        text = parse_page
        @state.value = regex_helper(text)
      end

      private

      def parse_page
        page = Nokogiri::HTML(open(@url)) { |config| config.strict.nonet }
        page.xpath(@xpath).text.strip
      end

      def url(value)
        @url = value
      end

      def xpath(value)
        @xpath = value
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
prospectus-0.0.12 lib/prospectus/modules/url_xpath.rb
prospectus-0.0.11 lib/prospectus/modules/url_xpath.rb
prospectus-0.0.10 lib/prospectus/modules/url_xpath.rb
prospectus-0.0.9 lib/prospectus/modules/url_xpath.rb
prospectus-0.0.8 lib/prospectus/modules/url_xpath.rb
prospectus-0.0.6 lib/prospectus/modules/url_xpath.rb
prospectus-0.0.5 lib/prospectus/modules/url_xpath.rb
prospectus-0.0.4 lib/prospectus/modules/url_xpath.rb
prospectus-0.0.3 lib/prospectus/modules/url_xpath.rb