Module: Aurb::Base
Overview
Main Aurb class, interacting with the AUR.
Defined Under Namespace
Classes: Version
Instance Method Summary collapse
-
#download(*packages) ⇒ Object
Download
packagesfrom the AUR. -
#info(package) ⇒ Object
Returns all available info for a given package name.
-
#search(*packages) ⇒ Object
Search the AUR for given
packages. -
#upgrade(*list) ⇒ Object
Returns a
listof names of packages that have an upgrade available to them, which could then in turn be passed on to thedownloadmethod.
Instance Method Details
#download(*packages) ⇒ Object
Download packages from the AUR. Returns an array of downloadable package urls.
download('aurb') # => ['http://.../aurb.tar.gz']
73 74 75 76 77 78 79 |
# File 'lib/aurb/base.rb', line 73 def download(*packages) packages.map { |package| Aurb::DownloadPath[URI.escape(package.to_s)] }.select { |package| !!(open package rescue false) }.compact end |
#info(package) ⇒ Object
Returns all available info for a given package name.
info('aurb') # => {:ID => ..., :Name => 'aurb', ...}
84 85 86 87 88 89 |
# File 'lib/aurb/base.rb', line 84 def info(package) parse_json Aurb::SearchPath[:info, URI.escape(package.to_s)] do |json| return if json.type =~ /error/ json.results end end |
#search(*packages) ⇒ Object
Search the AUR for given packages. Returns an array of results.
search('aurb') # => [{:ID => ..., :Name => 'aurb', ...}, {...}]
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/aurb/base.rb', line 56 def search(*packages) [].tap { |results| packages.map {|p| URI.escape(p.to_s)}.inject([]) { |ary, package| ary << Thread.new do parse_json Aurb::SearchPath[:search, package] do |json| next if json.type =~ /error/ results << json.results end end }.each &:join }.flatten.compact end |
#upgrade(*list) ⇒ Object
Returns a list of names of packages that have an upgrade available to them, which could then in turn be passed on to the download method.
# With Aurb on the AUR as version 1.1.2-1
upgrade('aurb 0.0.0-0', 'aurb 9.9.9-9') # => [:aurb]
97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/aurb/base.rb', line 97 def upgrade(*list) [].tap { |upgradables| list.inject([]) { |ary, line| ary << Thread.new do name, version = line.split next if Dir["/var/lib/pacman/sync/community/#{name}-#{version}"].any? upgradables << name.to_sym if upgradable?(name, version) end }.each &:join }.compact end |