From f59463d31ad0b6d873435fd7892e353e45751308 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 18 Aug 2011 17:45:59 -0400 Subject: [PATCH] bump version, eat own dog food, and fix a problem --- Gemfile | 1 + Rakefile | 11 ++++++++++ lib/penchant/version.rb | 2 +- script/gemfile | 11 ++++++++++ script/hooks/pre-commit | 15 ++++++++++++++ script/initialize-environment | 35 ++++++++++++++++++++++++++++++++ script/install-git-hooks | 6 ++++++ template/script/hooks/pre-commit | 2 +- 8 files changed, 81 insertions(+), 2 deletions(-) create mode 100755 script/gemfile create mode 100755 script/hooks/pre-commit create mode 100755 script/initialize-environment create mode 100755 script/install-git-hooks diff --git a/Gemfile b/Gemfile index aebb6ed..3ccc20a 100644 --- a/Gemfile +++ b/Gemfile @@ -8,3 +8,4 @@ gem 'guard-rspec' gem 'mocha' gem 'fakefs' gem 'rspec', '~> 2.6.0' +gem 'rake' diff --git a/Rakefile b/Rakefile index 14cfe0b..8ce01f9 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,13 @@ require 'bundler' Bundler::GemHelper.install_tasks + +begin + require 'rspec/core/rake_task' + + RSpec::Core::RakeTask.new(:spec) +rescue LoadError + "#$! - no rspec" +end + +task :default => :spec + diff --git a/lib/penchant/version.rb b/lib/penchant/version.rb index 14a61ce..b1f7f9d 100644 --- a/lib/penchant/version.rb +++ b/lib/penchant/version.rb @@ -1,3 +1,3 @@ module Penchant - VERSION = "0.0.1" + VERSION = "0.0.2" end 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/pre-commit b/script/hooks/pre-commit new file mode 100755 index 0000000..e1b1e1c --- /dev/null +++ b/script/hooks/pre-commit @@ -0,0 +1,15 @@ +#!/bin/bash + +OLD_GIT_DIR=$GIT_DIR + +if [ "$(penchant gemfile-env)" != "remote" ]; then + unset GIT_DIR + penchant gemfile remote + GIT_DIR=$OLD_GIT_DIR + git add Gemfile* +fi + +bundle exec rake +R=$? +if [ $R -ne 0 ]; then exit $R; fi + diff --git a/script/initialize-environment b/script/initialize-environment new file mode 100755 index 0000000..222c8f1 --- /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 + diff --git a/template/script/hooks/pre-commit b/template/script/hooks/pre-commit index 1e30cb0..e1b1e1c 100755 --- a/template/script/hooks/pre-commit +++ b/template/script/hooks/pre-commit @@ -2,7 +2,7 @@ OLD_GIT_DIR=$GIT_DIR -if [ $(penchant gemfile-env) != "remote" ]; then +if [ "$(penchant gemfile-env)" != "remote" ]; then unset GIT_DIR penchant gemfile remote GIT_DIR=$OLD_GIT_DIR