Skip to content

Commit

Permalink
Add phar-archive installation method + tabs for spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
djoos committed Apr 25, 2013
1 parent 32eccaa commit 6f857bf
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 39 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Requirements
Attributes
==========

* `node['pdepend']['install_method']` - Installation method, "pear" or "composer", defaults to "pear"
* `node['pdepend']['install_method']` - Installation method, "pear", "composer" or "phar" defaults to "pear"
* `node['pdepend']['version']` - The pdepend version that will be installed, defaults to "latest"
* `node['pdepend']['prefix']` - The composer.json bin-dir, defaults to "/usr/bin" (composer install method only)

Expand All @@ -36,9 +36,9 @@ Usage

1) include `recipe[pdepend]` in a run list
2)
change the attributes
--- OR ---
override the attribute on a higher level (http://wiki.opscode.com/display/chef/Attributes#Attributes-AttributesPrecedence)
change the attributes
--- OR ---
override the attribute on a higher level (http://wiki.opscode.com/display/chef/Attributes#Attributes-AttributesPrecedence)

References
==========
Expand Down
8 changes: 8 additions & 0 deletions attributes/composer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Cookbook Name:: pdepend
# Attributes:: composer
#
# Copyright 2013, Escape Studios
#

default[:pdepend][:prefix] = "/usr/bin"
5 changes: 1 addition & 4 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@
#

default[:pdepend][:install_method] = "pear"
default[:pdepend][:version] = "latest"

#composer install only
default[:pdepend][:prefix] = "/usr/bin"
default[:pdepend][:version] = "latest"
9 changes: 9 additions & 0 deletions attributes/phar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Cookbook Name:: pdepend
# Attributes:: phar
#
# Copyright 2013, Escape Studios
#

default[:pdepend][:phar_url] = "http://static.pdepend.org/php/latest/pdepend.phar"
default[:pdepend][:install_dir] = ""
5 changes: 3 additions & 2 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license "MIT"
description "Installs/Configures pdepend"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.0.2"
version "0.0.3"

%w{ debian ubuntu redhat centos fedora scientific amazon }.each do |os|
supports os
Expand All @@ -15,4 +15,5 @@

recipe "pdepend", "Installs pdepend."
recipe "pdepend::composer", "Installs pdepend using composer."
recipe "pdepend::pear", "Installs pdepend using pear."
recipe "pdepend::pear", "Installs pdepend using pear."
recipe "pdepend::phar", "Installs pdepend using phar."
36 changes: 18 additions & 18 deletions recipes/composer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@
pdepend_dir = "#{Chef::Config[:file_cache_path]}/pdepend"

directory "#{pdepend_dir}" do
owner "root"
group "root"
mode "0755"
action :create
owner "root"
group "root"
mode "0755"
action :create
end

#figure out what version to install
if node[:pdepend][:version] != "latest"
version = node[:pdepend][:version]
version = node[:pdepend][:version]
else
version = "*.*.*"
version = "*.*.*"
end

#composer.json
template "#{pdepend_dir}/composer.json" do
source "composer.json.erb"
owner "root"
group "root"
mode 0600
variables(
:version => version,
:bindir => node[:pdepend][:prefix]
)
source "composer.json.erb"
owner "root"
group "root"
mode 0600
variables(
:version => version,
:bindir => node[:pdepend][:prefix]
)
end

#composer update
execute "pdepend-composer" do
user "root"
cwd pdepend_dir
command "composer update"
action :run
user "root"
cwd pdepend_dir
command "composer update"
action :run
end
10 changes: 6 additions & 4 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
#

case node[:pdepend][:install_method]
when "pear"
include_recipe "pdepend::pear"
when "composer"
include_recipe "pdepend::composer"
when "pear"
include_recipe "pdepend::pear"
when "composer"
include_recipe "pdepend::composer"
when "phar"
include_recipe "pdepend::phar"
end
14 changes: 7 additions & 7 deletions recipes/pear.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@

#upgrade PEAR
php_pear "PEAR" do
action :upgrade
action :upgrade
end

#pdepend PEAR channel
pearhub_chan = php_pear_channel "pear.pdepend.org" do
action :discover
action :discover
end

#upgrade pdepend
php_pear "PHP_Depend-beta" do
channel pearhub_chan.channel_name
if node[:pdepend][:version] != "latest"
version "#{node[:pdepend][:version]}"
end
action :upgrade
channel pearhub_chan.channel_name
if node[:pdepend][:version] != "latest"
version "#{node[:pdepend][:version]}"
end
action :upgrade
end
24 changes: 24 additions & 0 deletions recipes/phar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Cookbook Name:: pdepend
# Recipe:: phar
#
# Copyright 2013, Escape Studios
#

if node[:pdepend][:install_dir] != ""
pdepend_dir = node[:pdepend][:install_dir]
else
pdepend_dir = "#{Chef::Config[:file_cache_path]}/pdepend"
end

directory "#{pdepend_dir}" do
owner "root"
group "root"
mode "0755"
action :create
end

remote_file "#{pdepend_dir}/pdepend.phar" do
source node[:pdepend][:phar_url]
mode "0755"
end

0 comments on commit 6f857bf

Please sign in to comment.