Browse files

initial version, runs a rake task

  • Loading branch information...
0 parents commit 386fcf5298a366d73638aa50faf7ed5b54402819 Scott Barron committed Aug 1, 2011
Showing with 102 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +5 −0 Gemfile
  3. +21 −0 Gemfile.lock
  4. +1 −0 Rakefile
  5. +22 −0 guard-rake.gemspec
  6. +43 −0 lib/guard/rake.rb
  7. +3 −0 lib/guard/rake/templates/Guardfile
  8. +5 −0 lib/guard/version.rb
2 .gitignore
@@ -0,0 +1,2 @@
+.rvmrc
+pkg
5 Gemfile
@@ -0,0 +1,5 @@
+source "http://rubygems.org"
+
+gem 'rake'
+
+gemspec
21 Gemfile.lock
@@ -0,0 +1,21 @@
+PATH
+ remote: .
+ specs:
+ guard-rake (0.0.1)
+ guard
+ rake
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ guard (0.5.1)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ thor (0.14.6)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ guard-rake!
+ rake
1 Rakefile
@@ -0,0 +1 @@
+require 'bundler/gem_tasks'
22 guard-rake.gemspec
@@ -0,0 +1,22 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require 'guard/version'
+
+Gem::Specification.new do |s|
+ s.name = 'guard-rake'
+ s.version = Guard::Rake::VERSION
+ s.authors = ['Scott Barron']
+ s.email = ['scott@elitists.net']
+ s.homepage = 'http://github.com/rubyist/guard-rake'
+ s.summary = %q{Guard for running rake tasks}
+ s.description = %q{guard-rake automatically runs Rake tasks from your Rakefile}
+
+ s.add_dependency 'guard'
+ s.add_dependency 'rake'
+
+ 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
+
43 lib/guard/rake.rb
@@ -0,0 +1,43 @@
+require 'guard'
+require 'guard/guard'
+require 'rake'
+
+module Guard
+ class Rake < Guard
+ include ::Rake::DSL
+
+ def initialize(watchers=[], options={})
+ @task = options[:task]
+ super
+ end
+
+ def start
+ UI.info "Starting guard-rake #{@task}"
+ load 'Rakefile'
+ true
+ end
+
+ def stop
+ UI.info "Stopping guard-rake #{@task}"
+ true
+ end
+
+ def reload
+ stop
+ start
+ end
+
+ def run_all
+ run_rake_task
+ end
+
+ def run_on_change(paths)
+ run_rake_task
+ end
+
+ def run_rake_task
+ UI.info "running #{@task}"
+ ::Rake::Task[@task].execute
+ end
+ end
+end
3 lib/guard/rake/templates/Guardfile
@@ -0,0 +1,3 @@
+guard 'rake', :task => 'build' do
+ watch(%r{^my_file.rb})
+end
5 lib/guard/version.rb
@@ -0,0 +1,5 @@
+module Guard
+ module Rake
+ VERSION = "0.0.1"
+ end
+end

0 comments on commit 386fcf5

Please sign in to comment.