From 7904e67e089ee4b7705e2de36341e95ed4a3646b Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 14 Jul 2011 15:50:51 -0400 Subject: [PATCH] initial commit --- .gitignore | 4 ++++ Gemfile | 4 ++++ Rakefile | 2 ++ bin/penchant | 18 ++++++++++++++++++ lib/penchant.rb | 3 +++ lib/penchant/version.rb | 3 +++ penchant.gemspec | 21 +++++++++++++++++++++ template/script/gemfile | 11 +++++++++++ template/script/hooks/pre-commit | 5 +++++ template/script/initialize-environment | 21 +++++++++++++++++++++ template/script/install-git-hooks | 6 ++++++ 11 files changed, 98 insertions(+) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 Rakefile create mode 100755 bin/penchant create mode 100644 lib/penchant.rb create mode 100644 lib/penchant/version.rb create mode 100644 penchant.gemspec create mode 100755 template/script/gemfile create mode 100755 template/script/hooks/pre-commit create mode 100755 template/script/initialize-environment create mode 100755 template/script/install-git-hooks diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4040c6c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.gem +.bundle +Gemfile.lock +pkg/* diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..bbc1414 --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source "http://rubygems.org" + +# Specify your gem's dependencies in penchant.gemspec +gemspec diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..14cfe0b --- /dev/null +++ b/Rakefile @@ -0,0 +1,2 @@ +require 'bundler' +Bundler::GemHelper.install_tasks diff --git a/bin/penchant b/bin/penchant new file mode 100755 index 0000000..30be87b --- /dev/null +++ b/bin/penchant @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby + +require 'rubygems' +require 'thor' + +class Penchant < Thor + include Thor::Actions + source_root File.expand_path('../..', __FILE__) + + desc "install", "Copy the common scripts to the project" + method_options :dir => 'script' + def install + directory 'template/script', options[:dir] + Dir[File.join(options[:dir], '**/*')].each { |file| File.chmod(0755, file) } + end +end + +Penchant.start diff --git a/lib/penchant.rb b/lib/penchant.rb new file mode 100644 index 0000000..aa2748b --- /dev/null +++ b/lib/penchant.rb @@ -0,0 +1,3 @@ +module Penchant + # Your code goes here... +end diff --git a/lib/penchant/version.rb b/lib/penchant/version.rb new file mode 100644 index 0000000..14a61ce --- /dev/null +++ b/lib/penchant/version.rb @@ -0,0 +1,3 @@ +module Penchant + VERSION = "0.0.1" +end diff --git a/penchant.gemspec b/penchant.gemspec new file mode 100644 index 0000000..40909db --- /dev/null +++ b/penchant.gemspec @@ -0,0 +1,21 @@ +# -*- encoding: utf-8 -*- +$:.push File.expand_path("../lib", __FILE__) +require "penchant/version" + +Gem::Specification.new do |s| + s.name = "penchant" + s.version = Penchant::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ["TODO: Write your name"] + s.email = ["TODO: Write your email address"] + s.homepage = "" + s.summary = %q{TODO: Write a gem summary} + s.description = %q{TODO: Write a gem description} + + s.rubyforge_project = "penchant" + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.require_paths = ["lib"] +end diff --git a/template/script/gemfile b/template/script/gemfile new file mode 100755 index 0000000..89a15a4 --- /dev/null +++ b/template/script/gemfile @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby + +require 'erb' + +env = ARGV[0] + +File.open('Gemfile', 'w') { |fh| fh.print ERB.new(File.read('Gemfile.erb')).result(binding) } +system %{bundle} + +puts "Gemfile switched to #{env}" + diff --git a/template/script/hooks/pre-commit b/template/script/hooks/pre-commit new file mode 100755 index 0000000..384bb47 --- /dev/null +++ b/template/script/hooks/pre-commit @@ -0,0 +1,5 @@ +#!/bin/bash + +bundle exec rake +if [ $? -ne 0 ]; then exit $?; fi + diff --git a/template/script/initialize-environment b/template/script/initialize-environment new file mode 100755 index 0000000..ed32339 --- /dev/null +++ b/template/script/initialize-environment @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby + +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} + +puts "Installing git hooks" +system %{script/install-git-hooks} + +puts "Done!" + diff --git a/template/script/install-git-hooks b/template/script/install-git-hooks new file mode 100755 index 0000000..0644244 --- /dev/null +++ b/template/script/install-git-hooks @@ -0,0 +1,6 @@ +#!/bin/bash + +for hook in script/hooks/* ; do + ln -sf $PWD/$hook .git/hooks/${hook##*/} +done +