Class: Sunshine::Apt

Inherits:
Dependency show all
Defined in:
lib/sunshine/package_managers/apt.rb

Overview

The Apt dependency class supports basic apt-get features:

dependency_lib.instance_eval do
  apt "ruby", :version => '1.9'
end

See the Dependency class for more info.

Instance Attribute Summary

Attributes inherited from Dependency

#children, #name, #parents, #pkg

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Dependency

#add_child, #check, #check_test, #child_dependencies, #install, #install!, #install_parents!, #installed?, #missing_parents?, #parent_dependencies, #requires, sudo, sudo=, #to_s, #uninstall, #uninstall!, #uninstall_children!

Constructor Details

#initialize(name, options = {}, &block) ⇒ Apt

Returns a new instance of Apt.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sunshine/package_managers/apt.rb', line 16

def initialize(name, options={}, &block)
  super(name, options) do
    pkg_name = build_pkg_name @pkg.dup, options

    install    "apt-get install -y #{pkg_name}"
    uninstall  "apt-get remove -y #{pkg_name}"

    @pkg = "#{@pkg}-#{options[:version]}" if options[:version]
    check_test "apt-cache search ^#{@pkg} | grep -c ^#{@pkg}", '-ge 1'

    instance_eval(&block) if block_given?
  end
end

Class Method Details

.system_manager?(shell = nil) ⇒ Boolean

Checks if dependency type is valid for a given shell.

Returns:

  • (Boolean)


34
35
36
# File 'lib/sunshine/package_managers/apt.rb', line 34

def self.system_manager? shell=nil
  (shell || Sunshine.shell).system "apt-get --version"
end