Class: IEDriverServer::Helper::GoogleCodeParser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(driver_name, url:, open_uri_provider: OpenURI) ⇒ GoogleCodeParser

Returns a new instance of GoogleCodeParser.



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

def initialize(driver_name, url: , open_uri_provider: OpenURI)
  @driver_name = driver_name
  @url = url
  @source = open_uri_provider.open_uri(url)
end

Instance Attribute Details

#driver_nameObject (readonly)

Returns the value of attribute driver_name.



8
9
10
# File 'lib/ie_driver_server/helper/google_code_parser.rb', line 8

def driver_name
  @driver_name
end

#sourceObject (readonly)

Returns the value of attribute source.



8
9
10
# File 'lib/ie_driver_server/helper/google_code_parser.rb', line 8

def source
  @source
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/ie_driver_server/helper/google_code_parser.rb', line 8

def url
  @url
end

Instance Method Details

#downloadsObject



16
17
18
19
20
21
# File 'lib/ie_driver_server/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| !(/#{driver_name}_/===k) }
  items.map {|k| "#{url}/#{k}"}
end

#newest_downloadObject



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

def newest_download
  (downloads.sort { |a, b| version_of(a) <=> version_of(b)}).last
end