From 6acad213322069b11de527c00433ca1ae2657ce4 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Thu, 7 Feb 2013 16:36:42 -0500 Subject: [PATCH 1/2] Use :install as the default action --- README.md | 9 ++------- resources/pip.rb | 7 +++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fe07d04..caad30f 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Install packages using the new hotness in Python package management...[`pip`](ht # Actions -- :install: Install a pip package - if version is provided, install that specific version +- :install: Install a pip package - if version is provided, install that specific version (default) - :upgrade: Upgrade a pip package - if version is provided, upgrade to that specific version - :remove: Remove a pip package - :user: User to run pip as, for using with virtualenv @@ -65,26 +65,21 @@ Install packages using the new hotness in Python package management...[`pip`](ht # Example # install latest gunicorn into system path - python_pip "gunicorn" do - action :install - end + python_pip "gunicorn" # target a virtualenv python_pip "gunicorn" do virtualenv "/home/ubunut/my_ve" - action :install end # install Django 1.1.4 python_pip "django" do version "1.1.4" - action :install end # use this provider with the core package resource package "django" do provider Chef::Provider::PythonPip - action :install end `python_virtualenv` diff --git a/resources/pip.rb b/resources/pip.rb index 3276000..2e661c7 100644 --- a/resources/pip.rb +++ b/resources/pip.rb @@ -19,6 +19,13 @@ # actions :install, :upgrade, :remove, :purge +default_action :install + +# Covers 0.10.8 and earlier :default_action +def initialize(*args) + super + @action = :install +end attribute :package_name, :kind_of => String, :name_attribute => true attribute :version, :default => nil From 9f11ea64191aeda8b9a230577be97ddaadb773d2 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Thu, 7 Feb 2013 20:58:01 -0500 Subject: [PATCH 2/2] Truly support backwards compatability --- resources/pip.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/pip.rb b/resources/pip.rb index 2e661c7..cccb224 100644 --- a/resources/pip.rb +++ b/resources/pip.rb @@ -19,9 +19,9 @@ # actions :install, :upgrade, :remove, :purge -default_action :install +default_action :install if defined?(default_action) # Chef > 10.8 -# Covers 0.10.8 and earlier :default_action +# Default action for Chef <= 10.8 def initialize(*args) super @action = :install