penchant/README.md

66 lines
2.3 KiB
Markdown
Raw Normal View History

2011-07-14 20:51:54 +00:00
# I have a penchant for setting up all my projects so they work the same.
I like to do these things in all my projects:
* Have all my tests run before committing. I don't like buying ice cream for the team on test failures.
* If I'm developing gems alongside this project, I use a `Gemfile.erb` to get around the "one gem, one source" issue in
current versions of Bundler.
* If I'm moving to different machines or (heaven forbid!) having other developers work on the project, I want to make
getting all those local gems as easy as possible.
This gem makes that easier!
## What's it do?
Installs a bunch of scripts into the `scripts` directory of your project:
* `gemfile` which switches between `Gemfile.erb` environments
* `install-git-hooks` which will do just what it says
* `hooks/pre-commit`, one of the hooks the prior script installs
2011-07-14 21:16:11 +00:00
* `initialize-environment`, which bootstraps your local environment so you can get up and running
## initialize-environment
It will also try to run `rake bootstrap`, so add a `:bootstrap` task for things that should happen when you start going
2011-08-18 21:37:54 +00:00
(make databases, other stuff, etc, whatever). This won't run if the `:bootstrap` task is not there.
2011-07-14 20:51:54 +00:00
## Gemfile.erb?!
Yeah, it's a `Gemfile` with ERB in it:
2011-07-14 20:55:01 +00:00
``` erb
2011-08-18 21:37:54 +00:00
<% env :local do %>
2011-07-14 20:51:54 +00:00
gem 'guard', :path => '../guard'
2011-08-18 21:37:54 +00:00
<% end %>
<% env :remote do %>
2011-07-14 20:51:54 +00:00
gem 'guard', :git => 'git://github.com/johnbintz/guard.git'
<% end %>
2011-07-14 20:54:38 +00:00
```
2011-07-14 20:51:54 +00:00
2011-08-18 21:39:59 +00:00
Use `script/gemfile local` to get at the local ones, and `script/gemfile remote` to get at the remote ones.
2011-07-14 20:51:54 +00:00
It then runs `bundle install`.
2011-08-18 21:37:54 +00:00
You can also run `penchant gemfile ENV`.
### What environment are you currently using in that Gemfile?
`head -n 1` that puppy, or `penchant gemfile-env`.
2011-07-14 20:51:54 +00:00
## git hook?!
2011-08-18 21:37:54 +00:00
It runs `penchant gemfile remote` then runs `bundle exec rake`. Make sure your default Rake task for the project runs your
tests and performs any other magic necessary before each commit. Your re-environmented Gemfile and Gemfile.lock will be added
to your commit if they've changed.
2011-07-14 20:51:54 +00:00
## How?!
* `gem install penchant`
* `cd` to your project directory
2011-08-18 21:37:54 +00:00
And then one of the following:
* `penchant install` for a new project (`--dir=WHEREVER` will install the scripts to a directory other than `$PWD/scripts`)
* `penchant convert` for an existing project (`--dir=WHEVEVER` works here, too)
2011-07-14 20:51:54 +00:00