Class: Chromedriver::Helper::GoogleCodeParser
- Inherits:
-
Object
- Object
- Chromedriver::Helper::GoogleCodeParser
- Defined in:
- lib/chromedriver/helper/google_code_parser.rb
Constant Summary collapse
- BUCKET_URL =
'https://chromedriver.storage.googleapis.com'
Instance Attribute Summary collapse
-
#newest_download_version ⇒ Object
readonly
Returns the value of attribute newest_download_version.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #downloads ⇒ Object
-
#initialize(platform, open_uri_provider = OpenURI) ⇒ GoogleCodeParser
constructor
A new instance of GoogleCodeParser.
- #version_download_url(version) ⇒ Object
Constructor Details
#initialize(platform, open_uri_provider = OpenURI) ⇒ GoogleCodeParser
Returns a new instance of GoogleCodeParser.
12 13 14 15 16 |
# File 'lib/chromedriver/helper/google_code_parser.rb', line 12 def initialize(platform, open_uri_provider=OpenURI) @platform = platform @source = open_uri_provider.open_uri(BUCKET_URL) @newest_download_version = Gem::Version.new(open_uri_provider.open_uri(URI.join(BUCKET_URL, "LATEST_RELEASE")).read) end |
Instance Attribute Details
#newest_download_version ⇒ Object (readonly)
Returns the value of attribute newest_download_version.
10 11 12 |
# File 'lib/chromedriver/helper/google_code_parser.rb', line 10 def newest_download_version @newest_download_version end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
10 11 12 |
# File 'lib/chromedriver/helper/google_code_parser.rb', line 10 def platform @platform end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
10 11 12 |
# File 'lib/chromedriver/helper/google_code_parser.rb', line 10 def source @source end |
Instance Method Details
#downloads ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/chromedriver/helper/google_code_parser.rb', line 18 def downloads @downloads ||= begin doc = Nokogiri::XML.parse(source) items = doc.css("Contents Key").collect {|k| k.text } items.reject! {|k| !(/chromedriver_#{platform}/===k) } items.map {|k| "#{BUCKET_URL}/#{k}"} end end |
#version_download_url(version) ⇒ Object
27 28 29 30 |
# File 'lib/chromedriver/helper/google_code_parser.rb', line 27 def version_download_url(version) gem_version = Gem::Version.new(version) downloads.find { |download_url| version_of(download_url) == gem_version } end |