Class: Cfruby::Packages::PackageManager
- Inherits:
-
Object
- Object
- Cfruby::Packages::PackageManager
- Defined in:
- lib/libcfruby/packages.rb
Overview
The PackageManager class serves mostly as an in-code description of the PackageManager interface. It implements a handful of useful of helper functions, but is generally unimplemented
Direct Known Subclasses
AptPackageManager, FinkPackageManager, FreeBSDPackageManager, OpenBSDPackageManager, PortagePackageManager, RPMPackageManager
Instance Method Summary collapse
-
#[](packagename) ⇒ Object
Returns the referenced PackageInfo object, or nil.
-
#install(packagename, force = false) ⇒ Object
Installs the latest version of the named package, will not install the package if it is already installed unless force=true.
-
#installed?(package) ⇒ Boolean
Returns true if the named package is installed.
-
#installed_packages ⇒ Object
Returns a PackageList object that contains key value pairs for every installed package where the key is the package name and the value is the currently installed version.
-
#installed_version(packagename) ⇒ Object
Returns the installed version of the named package.
-
#method_missing(symbol, *args) ⇒ Object
Calls installed? after converting the symbol to a string if symbol ends in ?, otherwise calls [].
-
#packages ⇒ Object
Returns a PackageList object that contains key value pairs for every package (installed or not) where the key is the package name and the value is a PackageInfo object.
-
#uninstall(packagename) ⇒ Object
Uninstalls the named package.
-
#version(packagename) ⇒ Object
Returns the latest stable version of the named package that is available (installed or not).
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
Calls installed? after converting the symbol to a string if symbol ends in ?, otherwise calls []
140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/libcfruby/packages.rb', line 140 def method_missing(symbol, *args) if(args == nil or args.length == 0) name = symbol.id2name if(name =~ /\?$/) return(installed?(name[/^(.*)\?$/, 1])) else return(packages()[name]) end end super.method(symbol).call(args) end |
Instance Method Details
#[](packagename) ⇒ Object
Returns the referenced PackageInfo object, or nil
133 134 135 |
# File 'lib/libcfruby/packages.rb', line 133 def [](packagename) return(packages()[packagename]) end |
#install(packagename, force = false) ⇒ Object
Installs the latest version of the named package, will not install the package if it is already installed unless force=true. Returns true is a package is actually installed, false otherwise.
75 76 |
# File 'lib/libcfruby/packages.rb', line 75 def install(packagename, force=false) end |
#installed?(package) ⇒ Boolean
Returns true if the named package is installed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/libcfruby/packages.rb', line 115 def installed?(package) if(!package.kind_of?(Regexp)) package = Regexp.new(Regexp.escape(package.to_s)) end Cfruby.controller.inform('debug', "Getting installed? status of \"#{package.source}\"") installed_packages.each_value() { |packageinfo| if(package.match(packageinfo.name)) return(true) end } return(false) end |
#installed_packages ⇒ Object
Returns a PackageList object that contains key value pairs for every installed package where the key is the package name and the value is the currently installed version. See PackageList for more information
101 102 103 |
# File 'lib/libcfruby/packages.rb', line 101 def installed_packages() return(PackageList.new()) end |
#installed_version(packagename) ⇒ Object
Returns the installed version of the named package
85 86 87 |
# File 'lib/libcfruby/packages.rb', line 85 def installed_version(packagename) return(installed_packages()[packagename].version) end |
#packages ⇒ Object
Returns a PackageList object that contains key value pairs for every package (installed or not) where the key is the package name and the value is a PackageInfo object
109 110 111 |
# File 'lib/libcfruby/packages.rb', line 109 def packages() return(PackageList.new()) end |
#uninstall(packagename) ⇒ Object
Uninstalls the named package
80 81 |
# File 'lib/libcfruby/packages.rb', line 80 def uninstall(packagename) end |
#version(packagename) ⇒ Object
Returns the latest stable version of the named package that is available (installed or not)
92 93 94 |
# File 'lib/libcfruby/packages.rb', line 92 def version(packagename) return(packages()[packagename].version) end |