This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
forked from guillermo/rake-hooks
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Todd Blackman
committed
Jul 9, 2012
1 parent
8e8063f
commit 6e3e0b7
Showing
12 changed files
with
274 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.gem | ||
.bundle | ||
Gemfile.lock | ||
pkg/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
language: ruby | ||
rvm: | ||
- 1.8.7 | ||
- 1.9.2 | ||
- 1.9.3 | ||
- jruby-18mode # JRuby in 1.8 mode | ||
- jruby-19mode # JRuby in 1.9 mode | ||
- rbx-18mode | ||
script: rake test | ||
gemfile: | ||
- Gemfile.rake-0.8.7 | ||
- Gemfile.rake-0.9.2.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source "http://rubygems.org" | ||
|
||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "http://rubygems.org" | ||
|
||
gem "rake", "0.8.7" | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "http://rubygems.org" | ||
|
||
gem "rake", "0.9.2.2" | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# rake-hooks | ||
|
||
Rake hooks let you add callbacks to rake: | ||
|
||
[![Build Status](https://secure.travis-ci.org/guillermo/rake-hooks.png)](http://travis-ci.org/guillermo/rake-hooks) | ||
[![endorse](http://api.coderwall.com/guillermo/endorsecount.png)](http://coderwall.com/guillermo) | ||
|
||
|
||
## Usage | ||
|
||
For example in your Rakefile | ||
|
||
```ruby | ||
require 'rake/hooks' | ||
|
||
task :say_hello do | ||
puts "Good Morning !" | ||
end | ||
|
||
after :say_hello do | ||
puts "GoodBye" | ||
end | ||
|
||
after :say_hello do | ||
puts "Now go to bed !" | ||
end | ||
|
||
before :say_hello do | ||
puts "Hi !" | ||
end | ||
``` | ||
|
||
Now run with rake | ||
|
||
```bash | ||
$ rake say_hello | ||
Hi ! | ||
Good Morning ! | ||
GoodBye | ||
Now go to bed ! | ||
``` | ||
|
||
You can also pass more than one task and each task will be setup with the | ||
callback | ||
|
||
```ruby | ||
before :say_hello, :say_goodbye do | ||
puts "Hi !" | ||
end | ||
``` | ||
|
||
|
||
## Installation | ||
|
||
With rubygems use: | ||
```bash | ||
$ gem install rake-hooks | ||
``` | ||
|
||
With other systems | ||
Add lib dir to load path. | ||
|
||
## Dependencies | ||
|
||
* Rake | ||
|
||
## Author | ||
|
||
* [Joel Moss](mailto:joel@developwithstyle.com) | ||
* [Guillermo Álvarez](mailto:guillermo@cientifico.net) | ||
|
||
## Web | ||
|
||
http://github.com/guillermo/rake-hooks | ||
|
||
## Date of writing | ||
|
||
9 Sep 2011 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
require "bundler/gem_tasks" | ||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new do |t| | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
def before(task_name, &new_task) | ||
old_task = Rake.application.instance_variable_get('@tasks').delete(task_name.to_s) | ||
task task_name do | ||
new_task.call | ||
old_task.invoke | ||
module Rake::Hooks | ||
def before(*task_names, &new_task) | ||
task_names.each do |task_name| | ||
old_task = Rake.application.instance_variable_get('@tasks').delete(task_name.to_s) | ||
desc old_task.full_comment | ||
task task_name => old_task.prerequisites do | ||
new_task.call | ||
old_task.invoke | ||
end | ||
end | ||
end | ||
end | ||
|
||
def after(task_name, &new_task) | ||
old_task = Rake.application.instance_variable_get('@tasks').delete(task_name.to_s) | ||
|
||
task task_name do | ||
old_task.invoke | ||
new_task.call | ||
def after(*task_names, &new_task) | ||
options = task_names.last.is_a?(Hash) ? task_names.pop : {} | ||
ignore_exceptions = options.delete(:ignore_exceptions) || false | ||
|
||
task_names.each do |task_name| | ||
old_task = Rake.application.instance_variable_get('@tasks').delete(task_name.to_s) | ||
desc old_task.full_comment | ||
task task_name => old_task.prerequisites do | ||
begin | ||
old_task.invoke | ||
rescue | ||
raise unless ignore_exceptions | ||
end | ||
|
||
new_task.call | ||
end | ||
end | ||
end | ||
end | ||
|
||
Rake::DSL.send(:include, Rake::Hooks) if defined?(Rake::DSL) | ||
include Rake::Hooks unless self.class.included_modules.include?(Rake::Hooks) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Rake | ||
module Hooks | ||
VERSION = "1.2.3" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,25 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "rake/hooks/version" | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "rake-hooks" | ||
s.version = "0.1" | ||
s.date = "2010-06-22" | ||
s.authors = ["Guillermo Álvarez"] | ||
s.email = "guillermo@cientifico.net" | ||
s.summary = "Add after and before hooks to rake tasks" | ||
s.homepage = "http://github.com/guillermo/rake-hooks" | ||
s.name = "rake-hooks" | ||
s.version = Rake::Hooks::VERSION | ||
s.email = ["guillermo@cientifico.net", "joel@developwithstyle.com"] | ||
s.authors = ["Guillermo Álvarez", "Joel Moss"] | ||
s.summary = "Add after and before hooks to rake tasks" | ||
s.description = "Add after and before hooks to rake tasks. You can use \"after :task do ... end\" and \"before :task do ... end\"." | ||
s.files = [ "README", "LICENSE", "Rakefile", "test/test_rake_hooks.rb", "lib/rake/hooks.rb"] | ||
|
||
s.rubyforge_project = "rake-hooks" | ||
|
||
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"] | ||
|
||
s.add_runtime_dependency "rake" | ||
|
||
s.add_development_dependency "bundler" | ||
end | ||
|
||
|
Oops, something went wrong.