diff --git a/Gemfile b/Gemfile index bfb18fd..f0fe365 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,8 @@ -source 'https://rubygems.org' - -# Specify your gem's dependencies in bullseye.gemspec +# generated by penchant, environment: remote +source "https://rubygems.org" gemspec +gem "rake" +gem "capybara" +gem "cucumber" +gem "rspec" +gem "cuke-pack", {:git=>"git://github.com/johnbintz/cuke-pack.git"} \ No newline at end of file diff --git a/Gemfile.penchant b/Gemfile.penchant new file mode 100644 index 0000000..ef0e9b5 --- /dev/null +++ b/Gemfile.penchant @@ -0,0 +1,25 @@ +# ensure git hooks are always installed +ensure_git_hooks! + +# everything in the :local env is assumed to be a sibling directory of this one +defaults_for env(:local), :path => '../%s' + +# reference a github repository with gem 'my-gem', :github => 'username' +property :github, :git => 'git://github.com/$1/%s.git' +source 'https://rubygems.org' + +# Specify your gem's dependencies in bullseye.gemspec +gemspec + +gem 'rake' + +gems 'capybara', 'cucumber', 'rspec' + +env :local do + gem 'cuke-pack' +end + +env :remote do + gem 'cuke-pack', :github => 'johnbintz' +end + diff --git a/README.md b/README.md index c42eb53..94857bc 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,9 @@ Want to target that page in your Sass? Use a little string interpolation and a f ``` Piece of cake. + +## Hacking + +_You'll need to install [Penchant](http://github.com/johnbintz/penchant) to mess with the Gemfile +during development._ + diff --git a/Rakefile b/Rakefile index f57ae68..ffb574f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,3 @@ #!/usr/bin/env rake require "bundler/gem_tasks" + diff --git a/script/gemfile b/script/gemfile new file mode 100755 index 0000000..eb78755 --- /dev/null +++ b/script/gemfile @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby + +require 'rubygems' +require 'penchant' + +if Penchant::Gemfile.do_full_env_switch!(ARGV[0]) + puts "Gemfile switched to #{ARGV[0]}" +else + exit 0 +end + diff --git a/script/hooks/commit-msg b/script/hooks/commit-msg new file mode 100755 index 0000000..880057a --- /dev/null +++ b/script/hooks/commit-msg @@ -0,0 +1,40 @@ +#!/bin/bash + +msg=$(cat $1) + +OLD_GIT_DIR=$GIT_DIR + +# lion appears to insert git paths before everything else. ensure rvm can +# bust through, at the very least. +if [ ! -z "$MY_RUBY_HOME" ]; then + PATH="$MY_RUBY_HOME/bin:$PATH" +fi + +if [ ! -z "$GEM_PATH" ]; then + oifs="$IFS" + while IFS=":" read -ra GEM_PATHS; do + FIXED_GEM_PATH="" + for i in "${GEM_PATHS[@]}"; do + FIXED_GEM_PATH="$FIXED_GEM_PATH:${i}/bin" + done + done <<< "$GEM_PATH" + IFS="$oifs" + PATH="$FIXED_GEM_PATH:$PATH" +fi + +if [[ "${msg}" != *"[ci skip]"* ]]; then + if [ "$(penchant gemfile-env)" != "remote" ]; then + unset GIT_DIR + penchant gemfile remote + GIT_DIR=$OLD_GIT_DIR + fi + + if [ $(bundle exec rake -P | grep default | wc -l) -ne 0 ]; then + bundle exec rake + R=$? + if [ $R -ne 0 ]; then exit $R; fi + else + echo "[penchant] No default Rake task found! Add one if you want to run tests before committing." + fi +fi + diff --git a/script/hooks/post-commit b/script/hooks/post-commit new file mode 100755 index 0000000..99e8287 --- /dev/null +++ b/script/hooks/post-commit @@ -0,0 +1,5 @@ +#!/bin/bash + +unset GIT_DIR +penchant gemfile remote --switch-back + diff --git a/script/hooks/pre-commit b/script/hooks/pre-commit new file mode 100755 index 0000000..dfc22bd --- /dev/null +++ b/script/hooks/pre-commit @@ -0,0 +1,14 @@ +#!/bin/bash + +if [ $(bundle exec rake -P | grep preflight_check | wc -l) -ne 0 ]; then + bundle exec rake preflight_check + R=$? + if [ $R -ne 0 ]; then exit $R; fi +fi + +unset GIT_DIR +penchant gemfile remote --deployment +GIT_DIR=$OLD_GIT_DIR +git add Gemfile* + +exit 0 diff --git a/script/initialize-environment b/script/initialize-environment new file mode 100755 index 0000000..dad92b2 --- /dev/null +++ b/script/initialize-environment @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby + +if File.file?('Gemfile.erb') + pwd = Dir.pwd + + Dir.chdir '..' do + File.readlines(File.join(pwd, 'Gemfile.erb')).find_all { |line| line[':git'] }.each do |line| + repo = line[%r{:git => (['"])([^'"]+)\1}, 2] + + puts "Installing #{repo}" + system %{git clone #{repo}} + end + end + + puts "Bundling for local environment" + system %{script/gemfile local} +else + puts "Bundling..." + system %{bundle} +end + +puts "Installing git hooks" +system %{script/install-git-hooks} + +bundle = File.file?('Gemfile') ? 'bundle exec' : '' + +command = [ bundle, 'rake', '-s', '-T', 'bootstrap' ] + +if !(%x{#{command.join(' ')}}).empty? + puts "Trying to run rake bootstrap..." + system %{#{bundle} rake bootstrap} +end + +puts "Done!" + diff --git a/script/install-git-hooks b/script/install-git-hooks new file mode 100755 index 0000000..0644244 --- /dev/null +++ b/script/install-git-hooks @@ -0,0 +1,6 @@ +#!/bin/bash + +for hook in script/hooks/* ; do + ln -sf $PWD/$hook .git/hooks/${hook##*/} +done +