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 []
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/libcfruby/packages.rb', line 118 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
111 112 113 |
# File 'lib/libcfruby/packages.rb', line 111 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.
53 54 |
# File 'lib/libcfruby/packages.rb', line 53 def install(packagename, force=false) end |
#installed?(package) ⇒ Boolean
Returns true if the named package is installed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/libcfruby/packages.rb', line 93 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
79 80 81 |
# File 'lib/libcfruby/packages.rb', line 79 def installed_packages() return(PackageList.new()) end |
#installed_version(packagename) ⇒ Object
Returns the installed version of the named package
63 64 65 |
# File 'lib/libcfruby/packages.rb', line 63 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
87 88 89 |
# File 'lib/libcfruby/packages.rb', line 87 def packages() return(PackageList.new()) end |
#uninstall(packagename) ⇒ Object
Uninstalls the named package
58 59 |
# File 'lib/libcfruby/packages.rb', line 58 def uninstall(packagename) end |
#version(packagename) ⇒ Object
Returns the latest stable version of the named package that is available (installed or not)
70 71 72 |
# File 'lib/libcfruby/packages.rb', line 70 def version(packagename) return(packages()[packagename].version) end |