Class: Chromedriver::Helper::GoogleCodeParser

Inherits:
Object
  • Object
show all
Defined in:
lib/chromedriver2/helper/google_code_parser.rb

Constant Summary collapse

BUCKET_URL =
'http://chromedriver.storage.googleapis.com'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(platform) ⇒ GoogleCodeParser

Returns a new instance of GoogleCodeParser.



11
12
13
14
# File 'lib/chromedriver2/helper/google_code_parser.rb', line 11

def initialize(platform)
  @platform = platform
  @source = open(BUCKET_URL)
end

Instance Attribute Details

#platformObject (readonly)

Returns the value of attribute platform.



9
10
11
# File 'lib/chromedriver2/helper/google_code_parser.rb', line 9

def platform
  @platform
end

#sourceObject (readonly)

Returns the value of attribute source.



9
10
11
# File 'lib/chromedriver2/helper/google_code_parser.rb', line 9

def source
  @source
end

Instance Method Details

#downloadsObject



16
17
18
19
20
21
# File 'lib/chromedriver2/helper/google_code_parser.rb', line 16

def downloads
  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

#newest_downloadObject



23
24
25
# File 'lib/chromedriver2/helper/google_code_parser.rb', line 23

def newest_download
  downloads.last
end