Class: RuPac::Pacman
- Inherits:
-
Object
- Object
- RuPac::Pacman
- Defined in:
- lib/rupac.rb
Overview
Base class from which any class that calls pacman directly decends from
Constant Summary collapse
- @@force =
"no"- @@nodeps =
"no"- @@verbose =
"no"- @@lock =
"no"- @@lockerror =
"There is already another instance of pacman running"
Instance Method Summary collapse
-
#exec(finalCommand) ⇒ Object
exec Method Runs the final pacman command assembled by the subclasses Returns True if it fired off successfully Raises an exception if the command needed root and the UID isn’t root’s Raises SystemCallError if the command won’t execute Raises an exception if the command didn’t exit cleanly.
-
#force! ⇒ Object
force! method Tacks on the -f option to the command.
-
#force? ⇒ Boolean
force? method Asks if the Force option is set.
-
#initialize(rootneeded) ⇒ Pacman
constructor
Constructor.
-
#to_s ⇒ Object
Override the to_s method.
-
#verbose! ⇒ Object
verbose! method Tacks on the -v option.
-
#verbose? ⇒ Boolean
verbose? method Asks if the Verbose option is set.
Constructor Details
#initialize(rootneeded) ⇒ Pacman
Constructor. Needs rootneeded passed (yes or no)
22 23 24 25 |
# File 'lib/rupac.rb', line 22 def initialize( rootneeded ) @rootneeded = rootneeded @command = "pacman -" end |
Instance Method Details
#exec(finalCommand) ⇒ Object
exec Method
Runs the final pacman command assembled by the subclasses
Returns True if it fired off successfully
Raises an exception if the command needed root and the UID
isn't root's
Raises SystemCallError if the command won't execute
Raises an exception if the command didn't exit cleanly
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/rupac.rb', line 81 def exec( finalCommand ) if @rootneeded == "yes" ## Check for root's UID if Process.uid == 0 @output = `#{finalCommand}` if $? == 0 return true else raise "#{finalCommand} failed with error code #{$?}" end else raise "Must be root!" end elsif @rootneeded == "no" @output = `#{finalCommand}` if $? == 0 return true else raise "#{finalCommand} failed with error code #{$?}" end end end |
#force! ⇒ Object
force! method
Tacks on the -f option to the command
51 52 53 54 55 56 |
# File 'lib/rupac.rb', line 51 def force! if @@force == "no" @@force = "yes" @command = "#{@command}f" end end |
#force? ⇒ Boolean
force? method
Asks if the Force option is set
29 30 31 32 33 34 35 |
# File 'lib/rupac.rb', line 29 def force? if @@force == "yes" return true else return false end end |
#to_s ⇒ Object
Override the to_s method
70 71 72 |
# File 'lib/rupac.rb', line 70 def to_s "Command: #@command, Lock: #@@lock, Verbose: #@@verbose, Nodeps #@@nodeps, RootNeeded #@rootneeded" end |
#verbose! ⇒ Object
verbose! method
Tacks on the -v option
62 63 64 65 66 67 |
# File 'lib/rupac.rb', line 62 def verbose! if @@verbose == "no" @command = "#{@command}v" @@verbose = "yes" end end |
#verbose? ⇒ Boolean
verbose? method
Asks if the Verbose option is set
40 41 42 43 44 45 46 |
# File 'lib/rupac.rb', line 40 def verbose? if @@verbose == "yes" return true else return false end end |