Permalink
Browse files

added perlbrew_cpanm LWRP

  • Loading branch information...
1 parent c385d1c commit 983f236129a3cd61b3d3f406c6b726067a6a652f @xdg xdg committed Mar 15, 2012
Showing with 67 additions and 0 deletions.
  1. +37 −0 cookbooks/perlbrew/providers/cpanm.rb
  2. +30 −0 cookbooks/perlbrew/resources/cpanm.rb
@@ -0,0 +1,37 @@
+#
+# Author:: David A. Golden
+# Cookbook Name:: perlbrew
+# Provider:: perlbrew_cpanm
+#
+# Copyright:: 2012, David A. Golden <dagolden@cpan.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/mixin/shell_out'
+require 'chef/mixin/language'
+include Chef::Mixin::ShellOut
+
+action :install do
+ perlbrew_env = {
+ 'PERLBREW_ROOT' => node['perlbrew']['perlbrew_root'],
+ 'PERLBREW_HOME' => node['perlbrew']['perlbrew_root']
+ }
+ new_resource.modules([new_resource.name]) unless new_resource.modules.length > 0
+ p = perlbrew_run "cpanm #{new_resource.modules.join(' ')}" do
+ perlbrew new_resource.perlbrew
+ action :nothing
+ end
+ p.run_action(:run)
+ new_resource.updated_by_last_action(true)
+end
@@ -0,0 +1,30 @@
+#
+# Author:: David A. Golden
+# Cookbook Name:: perlbrew
+# Resource:: perlbrew_run
+#
+# Copyright:: 2012, David A. Golden <dagolden@cpan.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+actions :run
+
+attribute :command, :name_attribute => true, :kind_of => String
+attribute :perlbrew, :kind_of => String, :required => true
+attribute :modules, :kind_of => Array, :default => []
+
+def initialize(*args)
+ super
+ @action = :install
+end

0 comments on commit 983f236

Please sign in to comment.