update things and docs and stuff

This commit is contained in:
John Bintz 2011-10-13 10:01:18 -04:00
parent 5fe4778e6b
commit bf69d6ee6d
8 changed files with 41 additions and 14 deletions

View File

@ -31,6 +31,10 @@ Yeah, it's a `Gemfile` with ERB in it:
<% env :remote do %> <% env :remote do %>
gem 'guard', :git => 'git://github.com/johnbintz/guard.git' gem 'guard', :git => 'git://github.com/johnbintz/guard.git'
<% end %> <% end %>
<% no_deployment do %>
gem 'os-specific-things'
<% end %>
``` ```
Use `script/gemfile local` to get at the local ones, and `script/gemfile remote` to get at the remote ones. Use `script/gemfile local` to get at the local ones, and `script/gemfile remote` to get at the remote ones.
@ -38,6 +42,29 @@ It then runs `bundle install`.
You can also run `penchant gemfile ENV`. You can also run `penchant gemfile ENV`.
### Deployment mode
Use `no_deployment` blocks to indicate gems that shouldn't even appear in `Gemfiles` destined for
remote servers. *Very* helpful when you have OS-specific gems and are developing on one platform
and deploying on another:
``` erb
<% no_deployment do %>
require 'rbconfig'
case RbConfig::CONFIG['host_os']
when /darwin/
gem 'growl_notify'
gem 'growl'
gem 'rb-fsevent'
when /linux/
gem 'libnotify', :require => nil
end
<% end %>
```
Run `penchant gemfile ENV --deployment` to get this behavior. This is run by default when the
pre-commit git hook runs.
## initialize-environment ## initialize-environment
Get new developers up to speed fast! `script/initialize-environment` does the following when run: Get new developers up to speed fast! `script/initialize-environment` does the following when run:

View File

@ -24,11 +24,12 @@ class PenchantCLI < Thor
gemfile(:remote) gemfile(:remote)
end end
method_options :deployment => false
desc "gemfile ENV", "Switch the gemfile environment, or rebuild the current environment if not given" desc "gemfile ENV", "Switch the gemfile environment, or rebuild the current environment if not given"
def gemfile(env = get_current_env) def gemfile(env = get_current_env)
if env if env
puts "[penchant] Rebunding for #{env} environment..." puts "[penchant] Rebunding for #{env} environment#{options[:deployment] ? ", deployment mode" : ''}..."
Penchant::Gemfile.do_full_env_switch!(env) Penchant::Gemfile.do_full_env_switch!(env, options[:deployment])
end end
gemfile = Penchant::Gemfile.new gemfile = Penchant::Gemfile.new

View File

@ -1,14 +1,14 @@
module Penchant module Penchant
class DotPenchant class DotPenchant
class << self class << self
def run(env = nil) def run(env = nil, deployment = false)
dot_penchant = new dot_penchant = new
dot_penchant.run(env) dot_penchant.run(env)
dot_penchant dot_penchant
end end
end end
def run(env = nil) def run(env = nil, deployment = false)
instance_eval(File.read('.penchant')) instance_eval(File.read('.penchant'))
end end
@ -22,7 +22,6 @@ module Penchant
def gemfile? def gemfile?
File.file?('Gemfile') File.file?('Gemfile')
end end
end end
end end

View File

@ -7,13 +7,13 @@ module Penchant
class << self class << self
def do_full_env_switch!(env, deployment = false) def do_full_env_switch!(env, deployment = false)
gemfile = Penchant::Gemfile.new gemfile = Penchant::Gemfile.new
gemfile.run_dot_penchant!(env) gemfile.run_dot_penchant!(env, deployment)
if !gemfile.has_gemfile_erb? if !gemfile.has_gemfile_erb?
return false return false
end end
gemfile.switch_to!(env) gemfile.switch_to!(env, deployment)
end end
end end
@ -56,8 +56,8 @@ module Penchant
end end
end end
def run_dot_penchant!(env) def run_dot_penchant!(env, deployment)
DotPenchant.run(env || environment) if has_dot_penchant? DotPenchant.run(env || environment, deployment) if has_dot_penchant?
end end
private private

View File

@ -1,3 +1,3 @@
module Penchant module Penchant
VERSION = "0.0.4" VERSION = "0.0.5"
end end

View File

@ -3,9 +3,9 @@
require 'rubygems' require 'rubygems'
require 'penchant' require 'penchant'
if Penchant::Gemfile.do_full_env_switch!(ARGV[0], true) if Penchant::Gemfile.do_full_env_switch!(ARGV[0])
system %{bundle} system %{bundle}
puts "Gemfile switched to #{ARGV[0]} in deployment mode" puts "Gemfile switched to #{ARGV[0]}"
else else
exit 0 exit 0
end end

View File

@ -4,7 +4,7 @@ OLD_GIT_DIR=$GIT_DIR
if [ "$(penchant gemfile-env)" != "remote" ]; then if [ "$(penchant gemfile-env)" != "remote" ]; then
unset GIT_DIR unset GIT_DIR
penchant gemfile remote penchant gemfile remote --deployment
GIT_DIR=$OLD_GIT_DIR GIT_DIR=$OLD_GIT_DIR
git add Gemfile* git add Gemfile*
fi fi

View File

@ -4,7 +4,7 @@ OLD_GIT_DIR=$GIT_DIR
if [ "$(penchant gemfile-env)" != "remote" ]; then if [ "$(penchant gemfile-env)" != "remote" ]; then
unset GIT_DIR unset GIT_DIR
penchant gemfile remote penchant gemfile remote --deployment
GIT_DIR=$OLD_GIT_DIR GIT_DIR=$OLD_GIT_DIR
git add Gemfile* git add Gemfile*
fi fi