diff --git a/manifests/extension/mailparse.pp b/manifests/extension/mailparse.pp new file mode 100644 index 0000000..5435cdb --- /dev/null +++ b/manifests/extension/mailparse.pp @@ -0,0 +1,51 @@ +# Installs a php extension for a specific version of php. +# +# Usage: +# +# php::extension::mailparse { 'mailparse for 5.4.10': +# php => '5.4.10', +# version => '1.0.6' +# } +# +define php::extension::mailparse( + $php, + $version = '2.1.6' +) { + include boxen::config + + require php::config + + # Ensure that the specified version of PHP is installed. + php_require($php) + + + $extension = 'mailparse' + $package_name = "mailparse-${version}" + $url = "http://pecl.php.net/get/mailparse-${version}.tgz" + + # Final module install path + $module_path = "${php::config::root}/versions/${php}/modules/${extension}.so" + + # Additional options + $configure_params = '' + + php_extension { $name: + extension => $extension, + version => $version, + package_name => $package_name, + package_url => $url, + homebrew_path => $boxen::config::homebrewdir, + phpenv_root => $php::config::root, + php_version => $php, + cache_dir => $php::config::extensioncachedir, + configure_params => $configure_params, + } + + # Add config file once extension is installed + + file { "${php::config::configdir}/${php}/conf.d/${extension}.ini": + content => template('php/extensions/generic.ini.erb'), + require => Php_extension[$name], + } + +} diff --git a/spec/defines/extensions/php_extension_mailparse_spec.rb b/spec/defines/extensions/php_extension_mailparse_spec.rb new file mode 100644 index 0000000..6d11522 --- /dev/null +++ b/spec/defines/extensions/php_extension_mailparse_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe "php::extension::mailparse" do + let(:facts) { default_test_facts } + let(:title) { "mailparse for 5.4.17" } + let(:params) do + { + :php => "5.4.17", + :version => "2.1.6" + } + end + + it do + should contain_class("boxen::config") + should contain_class("php::config") + should contain_php__version("5.4.17") + + should contain_php_extension("mailparse for 5.4.17").with({ + :extension => "mailparse", + :version => "2.1.6", + :package_name => "mailparse-2.1.6", + :package_url => "http://pecl.php.net/get/mailparse-2.1.6.tgz", + :homebrew_path => "/test/boxen/homebrew", + :phpenv_root => "/test/boxen/phpenv", + :php_version => "5.4.17", + :cache_dir => "/test/boxen/data/php/cache/extensions", + :configure_params => '', + }) + + should contain_file("/test/boxen/config/php/5.4.17/conf.d/mailparse.ini").with({ + :content => File.read("spec/fixtures/mailparse.ini"), + :require => "Php_extension[mailparse for 5.4.17]" + }) + end +end diff --git a/spec/fixtures/mailparse.ini b/spec/fixtures/mailparse.ini new file mode 100644 index 0000000..98b983e --- /dev/null +++ b/spec/fixtures/mailparse.ini @@ -0,0 +1 @@ +extension=/test/boxen/phpenv/versions/5.4.17/modules/mailparse.so