Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

Commit

Permalink
add lwrp for brew tap
Browse files Browse the repository at this point in the history
  • Loading branch information
bleything committed Mar 27, 2012
1 parent 48e29a7 commit cb6c2a6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
27 changes: 27 additions & 0 deletions providers/tap.rb
@@ -0,0 +1,27 @@
def load_current_resource
@tap = Chef::Resource::HomebrewTap.new(new_resource.name)
tap_dir = @tap.name.gsub('/', '-')

Chef::Log.debug("Checking whether we've already tapped #{new_resource.name}")
if ::File.directory?("/usr/local/Library/Taps/#{tap_dir}")
@tap.tapped true
else
@tap.tapped false
end
end

action :tap do
unless @tap.tapped
execute "tapping #{new_resource.name}" do
command "/usr/local/bin/brew tap #{new_resource.name}"
end
end
end

action :untap do
if @tap.tapped
execute "untapping #{new_resource.name}" do
command "/usr/local/bin/brew untap #{new_resource.name}"
end
end
end
14 changes: 14 additions & 0 deletions resources/tap.rb
@@ -0,0 +1,14 @@
actions :tap, :untap
attribute :name,
:name_attribute => true,
:kind_of => String,
:regex => /\w+(?:\/\w+)+/

attribute :tapped,
:kind_of => [TrueClass, FalseClass]

### hax for default action
def initialize( *args )
super
@action = :tap
end

0 comments on commit cb6c2a6

Please sign in to comment.