Class: RuAUR
- Inherits:
-
Object
- Object
- RuAUR
- Defined in:
- lib/ruaur.rb
Defined Under Namespace
Classes: AUR, Error, Operation, Options, Package, Pacman
Class Method Summary collapse
Instance Method Summary collapse
- #clean(noconfirm) ⇒ Object
- #download(pkg_names, noconfirm = false) ⇒ Object
-
#initialize(hilight = false) ⇒ RuAUR
constructor
A new instance of RuAUR.
- #install(pkg_names, noconfirm = false) ⇒ Object
- #query(pkg_names, options = []) ⇒ Object
- #remove(pkg_names, options = []) ⇒ Object
- #search(string, names_only = false) ⇒ Object
- #sync(packages = [], options = []) ⇒ Object
- #upgrade(noconfirm = false) ⇒ Object
Constructor Details
#initialize(hilight = false) ⇒ RuAUR
Returns a new instance of RuAUR.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ruaur.rb', line 41 def initialize(hilight = false) [ "makepkg", "pacman", "su", "sudo" ].each do |dep| if (ScoobyDoo.where_are_you(dep).nil?) raise RuAUR::Error::MissingDependency.new(dep) end end @@hilight = hilight @pacman = RuAUR::Pacman.new @aur = RuAUR::AUR.new(@pacman, nil) @lock = Pathname.new("/tmp/ruaur.lock"). end |
Class Method Details
.hilight? ⇒ Boolean
36 37 38 39 |
# File 'lib/ruaur.rb', line 36 def self.hilight? @@hilight ||= false return @@hilight end |
.validate_options(options) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/ruaur.rb', line 156 def self.() valid = { RuAUR::Operation::Query => { "valid" => [ RuAUR::Options::Info, RuAUR::Options::Owns ] }, RuAUR::Operation::Remove => { "valid" => [ RuAUR::Options::NoSave ] }, RuAUR::Operation::Sync => { "valid" => [ RuAUR::Options::Clean, RuAUR::Options::Download, RuAUR::Options::NamesOnly, RuAUR::Options::NoConfirm, RuAUR::Options::Search, RuAUR::Options::Upgrade ], RuAUR::Options::Clean => [ RuAUR::Options::Clean, RuAUR::Options::NoConfirm ], RuAUR::Options::Download => [ RuAUR::Options::Download, RuAUR::Options::NoConfirm ], RuAUR::Options::Search => [ RuAUR::Options::NamesOnly, RuAUR::Options::NoConfirm, RuAUR::Options::Search ], RuAUR::Options::Upgrade => [ RuAUR::Options::NoConfirm, RuAUR::Options::Upgrade ] } } return false if (valid[["operation"]].nil?) valid[["operation"]].each do |k, v| if ((k == "valid") || ["options"].include?(k)) ["options"].each do |o| return false if (!v.include?(o)) end end end return true end |
Instance Method Details
#clean(noconfirm) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ruaur.rb', line 14 def clean(noconfirm) check_and_lock @pacman.clean(noconfirm) @aur.clean ensure unlock end |
#download(pkg_names, noconfirm = false) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ruaur.rb', line 22 def download(pkg_names, noconfirm = false) pkg_names.each do |pkg_name| if (@pacman.exist?(pkg_name)) @pacman.download(pkg_name, noconfirm) system( "cp /var/cache/pacman/pkg/#{pkg_name}-[0-9]*.xz ." ) else package = @aur.info(pkg_name) @aur.download(package) end end end |
#install(pkg_names, noconfirm = false) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ruaur.rb', line 59 def install(pkg_names, noconfirm = false) if (pkg_names.nil? || pkg_names.empty?) raise RuAUR::Error::PackageNotFound.new end check_and_lock pkg_names.each do |pkg_name| if (@pacman.exist?(pkg_name)) @pacman.install(pkg_name, noconfirm) else @aur.install(pkg_name, noconfirm) end end ensure unlock end |
#query(pkg_names, options = []) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ruaur.rb', line 77 def query(pkg_names, = []) info = .include?(RuAUR::Options::Info) owns = .include?(RuAUR::Options::Owns) if (owns) puts(@pacman.query_owns(pkg_names.join(" "))) else pkg_names.each do |pkg_name| results = @pacman.query(pkg_name, info) results.each do |name, details| print "#{name} " if (!info) puts(details) puts if (info) end results = @aur.query(pkg_name, info) results.each do |name, details| print "#{name} " if (!info) puts(details) puts if (info) end end end end |
#remove(pkg_names, options = []) ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/ruaur.rb', line 101 def remove(pkg_names, = []) check_and_lock nosave = .include?(RuAUR::Options::NoSave) @pacman.remove(pkg_names, nosave) ensure unlock end |
#search(string, names_only = false) ⇒ Object
109 110 111 112 113 114 115 116 117 |
# File 'lib/ruaur.rb', line 109 def search(string, names_only = false) found = @pacman.search(string).concat(@aur.search(string)) return found if (!names_only) names = Array.new found.each do |pkg| names.push(pkg.name) if (!names.include?(pkg.name)) end return names end |
#sync(packages = [], options = []) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/ruaur.rb', line 119 def sync(packages = [], = []) if (.include?(RuAUR::Options::Clean)) clean(.include?(RuAUR::Options::NoConfirm)) elsif (.include?(RuAUR::Options::Download)) download( packages, .include?(RuAUR::Options::NoConfirm) ) elsif (.include?(RuAUR::Options::Search)) return search( packages.join(" "), .include?(RuAUR::Options::NamesOnly) ) elsif (.include?(RuAUR::Options::Upgrade)) upgrade(.include?(RuAUR::Options::NoConfirm)) else install( packages, .include?(RuAUR::Options::NoConfirm) ) end return nil end |
#upgrade(noconfirm = false) ⇒ Object
148 149 150 151 152 153 154 |
# File 'lib/ruaur.rb', line 148 def upgrade(noconfirm = false) check_and_lock @pacman.upgrade(noconfirm) @aur.upgrade(noconfirm) ensure unlock end |