Class: Guard::Rake
Class Attribute Summary collapse
-
.rakefile_loaded ⇒ Object
Returns the value of attribute rakefile_loaded.
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ Rake
constructor
A new instance of Rake.
- #load_rakefile ⇒ Object
- #reload ⇒ Object
- #run_all ⇒ Object
- #run_on_change(paths) ⇒ Object
- #run_on_changes(paths) ⇒ Object
- #run_rake_task(paths = []) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(watchers = [], options = {}) ⇒ Rake
Returns a new instance of Rake.
12 13 14 15 16 17 18 19 20 |
# File 'lib/guard/rake.rb', line 12 def initialize(watchers=[], ={}) super @options = { :run_on_start => true, :run_on_all => true, :task_args => [] }.update() @task = @options[:task] end |
Class Attribute Details
.rakefile_loaded ⇒ Object
Returns the value of attribute rakefile_loaded.
9 10 11 |
# File 'lib/guard/rake.rb', line 9 def rakefile_loaded @rakefile_loaded end |
Instance Method Details
#load_rakefile ⇒ Object
72 73 74 75 76 77 |
# File 'lib/guard/rake.rb', line 72 def load_rakefile ARGV.clear ::Rake.application.init ::Rake.application.load_rakefile self.class.rakefile_loaded = true end |
#reload ⇒ Object
34 35 36 37 |
# File 'lib/guard/rake.rb', line 34 def reload stop start end |
#run_all ⇒ Object
39 40 41 |
# File 'lib/guard/rake.rb', line 39 def run_all run_rake_task if @options[:run_on_all] end |
#run_on_change(paths) ⇒ Object
44 45 46 |
# File 'lib/guard/rake.rb', line 44 def run_on_change(paths) run_rake_task(paths) end |
#run_on_changes(paths) ⇒ Object
48 49 50 |
# File 'lib/guard/rake.rb', line 48 def run_on_changes(paths) run_rake_task(paths) end |
#run_rake_task(paths = []) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/guard/rake.rb', line 53 def run_rake_task(paths=[]) UI.info "running #{@task}" ::Rake::Task.tasks.each { |t| t.reenable } ::Rake::Task[@task].invoke(*@options[:task_args], paths) Notifier.notify( "watched files: #{paths}", :title => "running rake task: #{@task}", :image => :success ) rescue Exception => e UI.error "#{self.class.name} failed to run rake task <#{@task}>, exception was:\n\t#{e.class}: #{e.}" UI.debug "\n#{e.backtrace.join("\n")}" Notifier.notify( " #{e.class}: #{e.}", :title => "fail to run rake task: #{@task}", :image => :failed) throw :task_has_failed end |
#start ⇒ Object
22 23 24 25 26 27 |
# File 'lib/guard/rake.rb', line 22 def start UI.info "Starting guard-rake #{@task}" load_rakefile unless self.class.rakefile_loaded run_rake_task if @options[:run_on_start] true end |
#stop ⇒ Object
29 30 31 32 |
# File 'lib/guard/rake.rb', line 29 def stop UI.info "Stopping guard-rake #{@task}" true end |