Class: Zypper::Onlinesearch::Data::Page::Packman

Inherits:
PageData
  • Object
show all
Defined in:
lib/zypper/onlinesearch/data.rb

Overview

Scraping class for Packman page.

Constant Summary collapse

URL =
"http://packman.links2linux.org"
XPATH_NAME =
'//td[@id="package-details-header-name"]'
XPATH_DESC =
'//div[@id="package-description"]'
XPATH_PACKAGES =
'//td[@id="package-details-left"]//tbody/tr'
XPATH_VERSION =
".//td[1]"
XPATH_DISTRO =
".//td[2]"
XPATH_ARCH =
".//td[3]"
".//a/@href"

Constants inherited from PageData

PageData::ARCHS, PageData::FORMATS

Instance Method Summary collapse

Methods inherited from PageData

#expand_link, #initialize

Constructor Details

This class inherits a constructor from Zypper::Onlinesearch::PageData

Instance Method Details

#dataObject



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/zypper/onlinesearch/data.rb', line 243

def data
  res = {}
  res[:name] = @page.xpath(XPATH_NAME).text
  res[:short_description] = ""
  res[:description] = @page.xpath(XPATH_DESC).text
  res[:versions] = []

  @page.xpath(XPATH_PACKAGES).each do |pack|
    version = pack.xpath(XPATH_VERSION).text.split("-")[0].to_s
    distro = pack.xpath(XPATH_DISTRO).text.gsub(/_/, " ")
    arch = pack.xpath(XPATH_ARCH).text.strip.to_sym
    link = pack.xpath(XPATH_LINK).text

    res[:versions] << { format: :extra, arch: arch, version: version, distro: distro,
                        type: :supported, link: "http://packman.links2linux.org#{link}",
                        repo: "Packman" }
  end

  res
end