Class: Sprinkle::Installers::Pecl

Inherits:
Installer show all
Defined in:
lib/sprinkle/installers/pecl.rb

Overview

Pecl extension installed

Installs the specified pecl extension

Example Usage

package :php_stuff do
  pecl 'mongo'
  verify { has_pecl 'mongo' }
end

You can optionally pass a version number to both ‘pecl` and `has_pecl`:

package :php_stuff do
  pecl 'mongo', :version => "1.4.3"
  verify { has_pecl 'mongo', :version => "1.4.3" }
end

Some extensions need an ini file. You can have that generated, by passing the ‘:ini_file` option:

package :php_stuff do
  pecl 'mongo', :ini_file => true
end

If you need more fine grained control of the location or contents of the ini file, use:

package :php_stuff do
  pecl 'mongo', :ini_file => { :path => "/etc/php5/apache2/php.ini",
                               :content => "extension=mongo.so",
                               :sudo => true }
end

Instance Attribute Summary collapse

Attributes inherited from Installer

#delivery, #options, #package, #post, #pre

Instance Method Summary collapse

Methods inherited from Installer

#announce, api, #commands_from_block, #defer, #escape_shell_arg, inherited, #install_sequence, #method_missing, #per_host?, #post_process, #process, subclasses, verify_api

Methods included from Sudo

#sudo?, #sudo_cmd, #sudo_stack

Methods included from Attributes

#defaults, #set_defaults

Constructor Details

#initialize(parent, package_name, options = {}, &block) ⇒ Pecl

:nodoc:



50
51
52
53
54
55
56
# File 'lib/sprinkle/installers/pecl.rb', line 50

def initialize(parent, package_name, options = {}, &block) #:nodoc:
  super parent, &block
  @package_name = package_name
  @package_version = options[:version]
  @ini_file = options[:ini_file]
  setup_ini if @ini_file
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Sprinkle::Installers::Installer

Instance Attribute Details

#package_nameObject

Returns the value of attribute package_name.



36
37
38
# File 'lib/sprinkle/installers/pecl.rb', line 36

def package_name
  @package_name
end

#package_versionObject

Returns the value of attribute package_version.



36
37
38
# File 'lib/sprinkle/installers/pecl.rb', line 36

def package_version
  @package_version
end

Instance Method Details

#setup_iniObject



58
59
60
61
62
63
64
65
66
# File 'lib/sprinkle/installers/pecl.rb', line 58

def setup_ini
  @ini_file = to_ini_file_hash(@ini_file)
  text = @ini_file[:content] || "extension=#{@package_name}.so"
  path = @ini_file[:path] || "/etc/php5/conf.d/#{@package_name}.ini"
  use_sudo = @ini_file[:sudo]===false ? false : true
  post(:install) do
    file(path, :content => text, :sudo => use_sudo)
  end
end

#to_ini_file_hash(s) ⇒ Object



68
69
70
71
72
# File 'lib/sprinkle/installers/pecl.rb', line 68

def to_ini_file_hash(s)
  return {:content => s} if s.is_a? String
  return {} if s===true
  s
end