Class: Guard::Post
- Inherits:
-
Guard
- Object
- Guard
- Guard::Post
- Defined in:
- lib/guard/post.rb
Instance Method Summary collapse
- #ignored?(path) ⇒ Boolean
-
#initialize(watchers = [], options = {}, &block) ⇒ Post
constructor
A new instance of Post.
- #run_all ⇒ Object
- #run_on_change(paths) ⇒ Object
- #start ⇒ Object
- #update_file(file) ⇒ Object
Constructor Details
#initialize(watchers = [], options = {}, &block) ⇒ Post
Returns a new instance of Post.
7 8 9 10 11 12 13 |
# File 'lib/guard/post.rb', line 7 def initialize(watchers = [], = {}, &block) super @options = { :all_on_start => true, :rails => false }.update() end |
Instance Method Details
#ignored?(path) ⇒ Boolean
54 55 56 |
# File 'lib/guard/post.rb', line 54 def ignored?(path) File.basename(path)[0] == "_" end |
#run_all ⇒ Object
24 25 26 |
# File 'lib/guard/post.rb', line 24 def run_all run_on_change(Watcher.match_files(self, Dir.glob(File.join('**', '*.*')))) end |
#run_on_change(paths) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/guard/post.rb', line 28 def run_on_change(paths) trap("SIGINT") { exit! } changed_files = paths.reject { |f| ignored?(f) }.map do |file| begin = ::File.(file) ::Guard::UI.info "-> updating '#{file}'...", :reset => true update_file(file) ::Guard::UI.info "-> updated '#{file}'", :reset => true file rescue Exception => e puts e.backtrace.join("\n") puts e.inspect end file end.compact end |
#start ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/guard/post.rb', line 15 def start if @options[:rails] == true ::Guard::UI.info "-> Loading Rails...", :reset => true require File.("../config/environment", __FILE__) ::Guard::UI.info "-> Loaded Rails '#{Rails.env.to_s}' environment", :reset => true end true end |
#update_file(file) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/guard/post.rb', line 45 def update_file(file) case @options[:update] when ::Symbol Object.send(@options[:update], file) else @options[:update].call(file) end end |