Class: AutomateIt::PackageManager::CPAN
- Inherits:
-
BaseDriver
- Object
- Common
- AutomateIt::Plugin::Base
- AutomateIt::Plugin::Driver
- BaseDriver
- AutomateIt::PackageManager::CPAN
- Defined in:
- lib/automateit/package_manager/cpan.rb
Overview
PackageManager::CPAN
A PackageManager driver for Perl CPAN (Comprehensive Perl Archive Network) software packages.
No automatic dependency installation
Unlike other AutomateIt PackageManager drivers, the CPAN driver will not install a package’s dependencies automatically. This protects you because many CPAN packages require a specific version of Perl, often one which you don’t have installed, and installing that dependency will destroy your Perl interpreter and everything that depends on it. Therefore, you must specify all package dependencies manually. If a package dependency isn’t found, the install will fail.
Specifying Perl interpreter
Use #setup to specify the Perl interpreter to use for all subsequent calls.
Example:
package_manager[:cpan].setup(:perl => "/usr/local/bin/perl")
package_manager.install %w(File::Next App::Ack), :with => :cpan
Constant Summary collapse
- CPAN_WRAPPER =
File.join(::AutomateIt::Constants::HELPERS_DIR, "cpan_wrapper.pl")
Constants inherited from AutomateIt::Plugin::Driver
AutomateIt::Plugin::Driver::BASE_DRIVER_NAME
Constants included from Constants
Constants::HELPERS_DIR, Constants::INSTALL_DIR, Constants::PERROR, Constants::PEXEC, Constants::PNOTE, Constants::WARNING_BOILERPLATE
Instance Attribute Summary collapse
-
#perl ⇒ Object
Path to Perl interpreter.
Attributes inherited from AutomateIt::Plugin::Driver
Attributes inherited from Common
Instance Method Summary collapse
-
#install(*packages) ⇒ Object
Options: * :perl – Command to use as the Perl interpreter, otherwise defaults to the one specified during #setup or to “perl”.
-
#installed?(*packages) ⇒ Boolean
Options: * :perl – Command to use as the Perl interpreter, otherwise defaults to the one specified during #setup or to “perl”.
-
#not_installed?(*packages) ⇒ Boolean
See AutomateIt::PackageManager#not_installed?.
-
#setup(*args) ⇒ Object
Setup the PackageManager::CPAN driver.
-
#suitability(method, *args) ⇒ Object
:nodoc:.
-
#uninstall(*packages) ⇒ Object
Options: * :perl – Command to use as the Perl interpreter, otherwise defaults to the one specified during #setup or to “perl”.
Methods inherited from AutomateIt::Plugin::Driver
abstract_driver, #available?, base_driver, base_driver?, depends_on, inherited, manager_token
Methods inherited from AutomateIt::Plugin::Base
Methods inherited from Common
#initialize, #log, #nitpick, #noop, #noop=, #noop?, #preview, #preview=, #preview?, #preview_for, #superuser?, #writing, #writing=, #writing?
Constructor Details
This class inherits a constructor from AutomateIt::Common
Instance Attribute Details
#perl ⇒ Object
Path to Perl interpreter
22 23 24 |
# File 'lib/automateit/package_manager/cpan.rb', line 22 def perl @perl end |
Instance Method Details
#install(*packages) ⇒ Object
Options:
-
:perl – Command to use as the Perl interpreter, otherwise defaults to the one specified during #setup or to “perl”
See AutomateIt::PackageManager#install
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/automateit/package_manager/cpan.rb', line 76 def install(*packages) return _install_helper(*packages) do |list, opts| perl = opts[:perl] || self.perl cmd = "#{perl} #{CPAN_WRAPPER} --install #{list.join(' ')}" cmd << " > /dev/null" if opts[:quiet] cmd << " 2>&1" interpreter.sh(cmd) end end |
#installed?(*packages) ⇒ Boolean
Options:
-
:perl – Command to use as the Perl interpreter, otherwise defaults to the one specified during #setup or to “perl”
See AutomateIt::PackageManager#installed?
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/automateit/package_manager/cpan.rb', line 51 def installed?(*packages) return _installed_helper?(*packages) do |list, opts| perl = opts[:perl] || self.perl cmd = "#{perl} #{CPAN_WRAPPER} --query #{list.join(' ')}" # FIXME if CPAN isn't configured, this will hang because Perl will demand input log.debug(PEXEC+cmd) output = `#{cmd}` output.sub!(/.*---(\s[^\n]+)?\n/m, '') struct = ::YAML.load(output) struct["available"] || [] end end |
#not_installed?(*packages) ⇒ Boolean
See AutomateIt::PackageManager#not_installed?
67 68 69 70 |
# File 'lib/automateit/package_manager/cpan.rb', line 67 def not_installed?(*packages) # TODO Move #not_installed? up to BaseDriver return _not_installed_helper?(*packages) end |
#setup(*args) ⇒ Object
Setup the PackageManager::CPAN driver.
Options:
-
:perl – The absolute, relative or unqualified path for the Perl interpreter to use. E.g., “perl” or “/usr/local/bin/perl”.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/automateit/package_manager/cpan.rb', line 31 def setup(*args) super(*args) args, opts = args_and_opts(*args) if opts[:perl] self.perl = opts[:perl] else self.perl ||= "perl" end end |
#suitability(method, *args) ⇒ Object
:nodoc:
42 43 44 45 |
# File 'lib/automateit/package_manager/cpan.rb', line 42 def suitability(method, *args) # :nodoc: # Never select as default driver return 0 end |
#uninstall(*packages) ⇒ Object
Options:
-
:perl – Command to use as the Perl interpreter, otherwise defaults to the one specified during #setup or to “perl”
See AutomateIt::PackageManager#uninstall
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/automateit/package_manager/cpan.rb', line 91 def uninstall(*packages) return _uninstall_helper(*packages) do |list, opts| perl = opts[:perl] || self.perl cmd = "#{perl} #{CPAN_WRAPPER} --uninstall #{list.join(' ')} < /dev/null" cmd << " > /dev/null" if opts[:quiet] cmd << " 2>&1" interpreter.sh(cmd) end end |