Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add travis CI config and foodcritic tests and fixes

  • Loading branch information...
commit 3c0c57132cd500650670a9e506ea2d7f8b494446 1 parent 3b465f9
@alistairstead alistairstead authored
View
1  .gitignore
@@ -0,0 +1 @@
+tmp/*
View
7 .travis.yml
@@ -0,0 +1,7 @@
+language: ruby
+gemfile:
+ - test/support/Gemfile.ci
+rvm:
+ - 1.9.2
+ - 1.9.3
+script: BUNDLE_GEMFILE=test/support/Gemfile.ci bundle exec rake foodcritic
View
24 README.md
@@ -21,17 +21,17 @@ The following Opscode cookbooks are dependencies:
# Attributes
-* `[:xdebug][:cli_color]` = Enable cli colour output, defaults to `1`.
-* `[:xdebug][:scream]` = Enable removal for of `@` error suppression functionality, defaults to `0`.
-* `[:xdebug][:remote_enable]` = Defaults to `On`.
-* `[:xdebug][:remote_autostart]` = Defaults to `0`.
-* `[:xdebug][:remote_mode]` = Defaults to `req`.
-* `[:xdebug][:remote_connect_back]` = Defaults to `1`.
-* `[:xdebug][:idekey]` = Defaults to `macgdbp`.
-* `[:xdebug][:file_link_format]` = Defaults to `txmt://open?url=file://%f&line=%1`.
-* `[:xdebug][:profiler_enable_trigger]` = Defaults to `0`.
-* `[:xdebug][:profiler_enable]` = Defaults to `0`.
-* `[:xdebug][:profiler_output_dir]` = Defaults to `/tmp/cachegrind`.
+* `['xdebug']['cli_color']` = Enable cli colour output, defaults to `1`.
+* `['xdebug']['scream']` = Enable removal for of `@` error suppression functionality, defaults to `0`.
+* `['xdebug']['remote_enable']` = Defaults to `On`.
+* `['xdebug']['remote_autostart']` = Defaults to `0`.
+* `['xdebug']['remote_mode']` = Defaults to `req`.
+* `['xdebug']['remote_connect_back']` = Defaults to `1`.
+* `['xdebug']['idekey']` = Defaults to `macgdbp`.
+* `['xdebug']['file_link_format']` = Defaults to `txmt://open?url=file://%f&line=%1`.
+* `['xdebug']['profiler_enable_trigger']` = Defaults to `0`.
+* `['xdebug']['profiler_enable']` = Defaults to `0`.
+* `['xdebug']['profiler_output_dir']` = Defaults to `/tmp/cachegrind`.
# Providers
@@ -140,7 +140,7 @@ If you are setting up a development environment you can use the single recipe th
# License and Author
-Author:: Alistair Stead (alistair@inviqa.com)
+Author:: Alistair Stead (alistair@inviqa.com) Author:: Marcello Duarte (marcello@inviqa.com)
Copyright 2012, Inviqa
View
25 Rakefile
@@ -0,0 +1,25 @@
+desc "Runs foodcritic"
+task :foodcritic do
+ if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup)
+ sandbox = File.join(File.dirname(__FILE__), %w{tmp foodcritic cookbook})
+ prepare_foodcritic_sandbox(sandbox)
+
+ sh "foodcritic --epic-fail any #{File.dirname(sandbox)}"
+ else
+ STDERR.puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2."
+ end
+end
+
+task :default => "foodcritic"
+
+private
+
+def prepare_foodcritic_sandbox(sandbox)
+ files = %w{*.md *.rb attributes definitions files providers
+recipes resources templates}
+
+ rm_rf sandbox
+ mkdir_p sandbox
+ cp_r Dir.glob("{#{files.join(',')}}"), sandbox
+ puts "\n\n"
+end
View
22 attributes/default.rb
@@ -1,11 +1,11 @@
-default[:xdebug][:cli_color] = 1
-default[:xdebug][:scream] = 0
-default[:xdebug][:remote_enable] = "On"
-default[:xdebug][:remote_autostart] = 0
-default[:xdebug][:remote_mode] = "req"
-default[:xdebug][:remote_connect_back] = 1
-default[:xdebug][:idekey] = "macgdbp"
-default[:xdebug][:file_link_format] = "txmt://open?url=file://%f&line=%1"
-default[:xdebug][:profiler_enable_trigger] = 0
-default[:xdebug][:profiler_enable] = 0
-default[:xdebug][:profiler_output_dir] = "/tmp/cachegrind"
+default['xdebug']['cli_color'] = 1
+default['xdebug']['scream'] = 0
+default['xdebug']['remote_enable'] = "On"
+default['xdebug']['remote_autostart'] = 0
+default['xdebug']['remote_mode'] = "req"
+default['xdebug']['remote_connect_back'] = 1
+default['xdebug']['idekey'] = "macgdbp"
+default['xdebug']['file_link_format'] = "txmt://open?url=file://%f&line=%1"
+default['xdebug']['profiler_enable_trigger'] = 0
+default['xdebug']['profiler_enable'] = 0
+default['xdebug']['profiler_output_dir'] = "/tmp/cachegrind"
View
2  metadata.rb
@@ -5,7 +5,9 @@
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.0.2"
+depends "yum"
depends "php"
+depends "chef-php-extra"
%w{ ubuntu, debian, centos, redhat, fedora }.each do |os|
supports os
View
22 providers/composer.rb
@@ -21,20 +21,20 @@
raise "#{new_resource.project_path} is not a directory"
end
- if !::File.exists?("#{new_resource.project_path}/composer.phar")
- remote_file "#{new_resource.project_path}/composer.phar" do
- source "http://getcomposer.org/composer.phar"
- mode "0774"
- end
+ remote_file "#{new_resource.project_path}/composer.phar" do
+ source "http://getcomposer.org/composer.phar"
+ mode "0774"
+ not_if !::File.exists?("#{new_resource.project_path}/composer.phar")
end
+ new_resource.updated_by_last_action(true)
end
action :install_packages do
- if ::File.exists?("#{new_resource.project_path}/composer.json")
- execute "install dependencies with composer" do
- cwd new_resource.project_path
- user "root"
- command "php composer.phar install"
- end
+ execute "install dependencies with composer #{new_resource.name}" do
+ cwd new_resource.project_path
+ user "root"
+ command "php composer.phar install"
+ only_if ::File.exists?("#{new_resource.project_path}/composer.json")
end
+ new_resource.updated_by_last_action(true)
end
View
4 providers/pear.rb
@@ -39,7 +39,7 @@
Chef::Log.info("Installing #{@new_resource} version #{install_version}")
status = install_package(@new_resource.package_name, install_version)
if status
- @new_resource.updated_by_last_action(true)
+ new_resource.updated_by_last_action(true)
end
end
end
@@ -50,7 +50,7 @@
Chef::Log.info("Upgrading #{@new_resource} version from #{orig_version} to #{candidate_version}")
status = upgrade_package(@new_resource.package_name, candidate_version)
if status
- @new_resource.updated_by_last_action(true)
+ new_resource.updated_by_last_action(true)
end
end
end
View
2  recipes/default.rb
@@ -18,7 +18,7 @@
#
case node['platform']
-when "redhat", "centos", "fedora"
+when "redhat", "centos", "fedora", "amazon", "scientific"
include_recipe "chef-php-extra::package"
when "ubuntu", "debian"
include_recipe "php"
View
2  recipes/module_dev.rb
@@ -19,7 +19,7 @@
include_recipe "chef-php-extra"
-if node.platform_version.to_f < 6.0
+if node['platform_version'].to_f < 6.0
if File.exists?("/etc/yum.repos.d/ius.repo")
packages = %w{ php53u-devel }
else
View
2  recipes/module_gd.rb
@@ -19,7 +19,7 @@
include_recipe "chef-php-extra"
-if node.platform_version.to_f < 6.0
+if node['platform_version'].to_f < 6.0
if File.exists?("/etc/yum.repos.d/ius.repo")
packages = %w{ php53u-gd }
else
View
2  recipes/module_imagick.rb
@@ -19,7 +19,7 @@
include_recipe "chef-php-extra"
-if node.platform_version.to_f < 6.0
+if node['platform_version'].to_f < 6.0
if File.exists?("/etc/yum.repos.d/ius.repo")
packages = %w{ php53u-imagick }
else
View
6 recipes/module_mcrypt.rb
@@ -19,11 +19,11 @@
include_recipe "chef-php-extra"
-if platform?("redhat", "centos", "fedora")
+if platform?("redhat", "centos", "fedora", "amazon", "scientific")
include_recipe "yum::ius"
end
-if node.platform_version.to_f < 6.0
+if node['platform_version'].to_f < 6.0
if File.exists?("/etc/yum.repos.d/ius.repo")
packages = %w{ php53u-mcrypt }
else
@@ -34,7 +34,7 @@
end
pkgs = value_for_platform(
- [ "centos", "redhat", "fedora" ] => {
+ [ "centos", "redhat", "fedora", "amazon", "scientific" ] => {
"default" => packages
},
[ "debian", "ubuntu" ] => {
View
2  recipes/module_mysql.rb
@@ -19,7 +19,7 @@
include_recipe "chef-php-extra"
-if node.platform_version.to_f < 6.0
+if node['platform_version'].to_f < 6.0
if File.exists?("/etc/yum.repos.d/ius.repo")
packages = %w{ php53u-mysql }
else
View
2  recipes/module_soap.rb
@@ -19,7 +19,7 @@
include_recipe "chef-php-extra"
-if node.platform_version.to_f < 6.0
+if node['platform_version'].to_f < 6.0
if File.exists?("/etc/yum.repos.d/ius.repo")
packages = %w{ php53u-soap }
else
View
2  recipes/module_xml.rb
@@ -19,7 +19,7 @@
include_recipe "chef-php-extra"
-if node.platform_version.to_f < 6.0
+if node['platform_version'].to_f < 6.0
if File.exists?("/etc/yum.repos.d/ius.repo")
packages = %w{ php53u-xml }
else
View
2  recipes/package.rb
@@ -1,4 +1,4 @@
-if node.platform_version.to_f < 6.0
+if node['platform_version'].to_f < 6.0
centos_packages = %w{ php53 php53-devel php53-cli php-pear }
else
centos_packages = %w{ php php-devel php-cli php-pear }
View
2  recipes/xdebug.rb
@@ -26,7 +26,7 @@
if platform?(%w{debian ubuntu})
package "php5-xdebug"
-elsif platform?(%w{centos redhat fedora})
+elsif platform?(%w{centos redhat fedora amazon scientific})
php_pear "xdebug" do
action :install
end
View
10 resources/composer.rb
@@ -1,3 +1,13 @@
+# Chef 0.10.10 or greater
+default_action :install_composer
+
+# In earlier versions of Chef the LWRP DSL doesn't support specifying
+# a default action, so you need to drop into Ruby.
+def initialize(*args)
+ super
+ @action = :install_composer
+end
+
actions :install_composer, :install_packages
attribute :project_path, :kind_of => String, :name_attribute => true
View
11 resources/pear.rb
@@ -18,6 +18,17 @@
# limitations under the License.
#
+# Chef 0.10.10 or greater
+default_action :install
+
+# In earlier versions of Chef the LWRP DSL doesn't support specifying
+# a default action, so you need to drop into Ruby.
+def initialize(*args)
+ super
+ @action = :install
+end
+
+
actions :install, :upgrade, :remove, :purge
attribute :package_name, :kind_of => String, :name_attribute => true
View
11 resources/pear_channel.rb
@@ -18,6 +18,17 @@
# limitations under the License.
#
+# Chef 0.10.10 or greater
+default_action :discover
+
+# In earlier versions of Chef the LWRP DSL doesn't support specifying
+# a default action, so you need to drop into Ruby.
+def initialize(*args)
+ super
+ @action = :discover
+end
+
+
actions :discover, :add, :update, :remove
attribute :channel_name, :kind_of => String, :name_attribute => true
View
4 test/support/Gemfile.ci
@@ -0,0 +1,4 @@
+source :rubygems
+
+gem "rake"
+gem "foodcritic"
Please sign in to comment.
Something went wrong with that request. Please try again.