Class: API::Launchpad
Instance Method Summary
collapse
#download_source_code, #fetch_license_info_from_local_source
Constructor Details
#initialize(distribution, distro_series, binary_package_name, binary_package_version, architecture = 'amd64', root_license_only = true) ⇒ Launchpad
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
# File 'lib/api/remote_source_package.rb', line 198
def initialize(distribution, distro_series, binary_package_name, binary_package_version, architecture='amd64',
root_license_only=true)
@site_url = 'https://launchpad.net'
@distribution = distribution
@distro_series = distro_series
@architecture = architecture
@binary_package_name = binary_package_name
@binary_package_version = binary_package_version
@download_dir = @download_dir
@source_url = nil
@source_path = nil
@root_license_only = root_license_only
end
|
Instance Method Details
#_find_source_code_download_url(source_package_homepage) ⇒ Object
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
# File 'lib/api/remote_source_package.rb', line 248
def _find_source_code_download_url(source_package_homepage)
source_code_download_url = nil
opts = {:discard_page_bodies => true, :depth_limit => 0}
Anemone.crawl(source_package_homepage, opts) do |anemone|
anemone.on_every_page do |page|
xpath = "//div[@id='source-files']/table/tbody/tr/td/a[contains(@href, '.orig.')]"
target_links = page.doc.xpath(xpath)
if target_links.size == 0
xpath = "//div[@id='source-files']/table/tbody/tr/td/a[not(contains(@href, '.dsc'))]"
target_links = page.doc.xpath(xpath)
end
target_links.each {|text|
full_href = text.attr('href')
if full_href
source_code_download_url = full_href
break
end
}
end
end
return source_code_download_url
end
|
#_find_source_package_homepage ⇒ Object
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
# File 'lib/api/remote_source_package.rb', line 227
def _find_source_package_homepage()
source_package_homepage = nil
opts = {:discard_page_bodies => true, :depth_limit => 0}
$plog.debug("binary_package_link: #{binary_package_link}")
Anemone.crawl(binary_package_link, opts) do |anemone|
anemone.on_every_page do |page|
xpath = "//dd[@id='source']/a[1]"
page.doc.xpath(xpath).each {|text|
abs_href = text.css('/@href')
if abs_href
source_package_homepage = "#{@site_url}#{abs_href}"
break
end
}
end
end
return source_package_homepage
end
|
#binary_package_link ⇒ Object
213
214
215
|
# File 'lib/api/remote_source_package.rb', line 213
def binary_package_link()
binary_package_url = "#{@site_url}/#{@distribution}/#{@distro_series}/#{@architecture}/#{@binary_package_name}/#{@binary_package_version}"
end
|
#find_source_package_homepage_and_download_url ⇒ Object
218
219
220
221
222
223
224
225
|
# File 'lib/api/remote_source_package.rb', line 218
def find_source_package_homepage_and_download_url()
homepage = _find_source_package_homepage
download_url = nil
if homepage
download_url = _find_source_code_download_url(homepage)
end
return homepage, download_url
end
|