Sha256: e204355343522197fe44ae2caef27a056e5290edfc690d07aa0b01494189985b

Contents?: true

Size: 739 Bytes

Versions: 3

Compression:

Stored size: 739 Bytes

Contents

require 'open-uri'
require 'json'

module Geckodriver
  class Helper
    class GeckoReleasePageParser
      GIT_API_URL = 'https://api.github.com/repos/mozilla/geckodriver/releases'

      attr_reader :platform

      def initialize(platform)
        @platform = platform
      end

      def download_url(versions)
        download_url = nil
        assets = versions[0]['assets']
        assets.each do |asset|
          link = asset['browser_download_url']
          if link.include? platform
            download_url = link
            break
          end
        end
        download_url
      end

      def latest_release
        result = JSON.parse(open(GIT_API_URL).read)
        download_url(result)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
geckodriver-helper-0.0.5 lib/geckodriver/helper/gecko_release_page_parser.rb
geckodriver-helper-0.0.4 lib/geckodriver/helper/gecko_release_page_parser.rb
geckodriver-helper-0.0.3 lib/geckodriver/helper/gecko_release_page_parser.rb