class Sprinkle::Installers::Pecl

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

Attributes

package_name[RW]
package_version[RW]

Public Instance Methods

has_pecl(package_name, options = {}) click to toggle source
# File lib/sprinkle/installers/pecl.rb, line 45
def has_pecl(package_name, options = {})
  @commands = "TERM= pecl list | grep '^#{package_name}\\\\s*" + (options[:version] ? options[:version].to_s : "") + "'"
end
pecl(package_name, options = {}, &block) click to toggle source
# File lib/sprinkle/installers/pecl.rb, line 39
def pecl(package_name, options = {}, &block)
  install Pecl.new(self, package_name, options, &block)
end
setup_ini() click to toggle source
# 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) click to toggle source
# 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