Class: Guard::CoffeeScript
- Defined in:
- lib/guard/coffeescript.rb,
lib/guard/coffeescript/runner.rb,
lib/guard/coffeescript/formatter.rb,
lib/guard/coffeescript/inspector.rb
Overview
The CoffeeScript guard that gets notifications about the following Guard events: ‘start`, `stop`, `reload`, `run_all` and `run_on_change`.
Defined Under Namespace
Modules: Formatter, Inspector, Runner
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :bare => false, :shallow => false, :hide_success => false, :noop => false, :error_to_js => false, :all_on_start => false, :source_map => false }
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ CoffeeScript
constructor
Initialize Guard::CoffeeScript.
-
#run_all ⇒ Object
Gets called when all files should be regenerated.
-
#run_on_changes(paths) ⇒ Object
Gets called when watched paths and files have changes.
-
#run_on_removals(paths) ⇒ Object
Called on file(s) deletions that the Guard watches.
-
#start ⇒ Object
Gets called once when Guard starts.
Constructor Details
#initialize(watchers = [], options = {}) ⇒ CoffeeScript
Initialize Guard::CoffeeScript.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/guard/coffeescript.rb', line 39 def initialize(watchers = [], = {}) watchers = [] if !watchers defaults = DEFAULT_OPTIONS.clone if [:input] defaults.merge!({ :output => [:input] }) watchers << ::Guard::Watcher.new(%r{^#{ [:input] }/(.+\.coffee)$}) end super(watchers, defaults.merge()) end |
Instance Method Details
#run_all ⇒ Object
Gets called when all files should be regenerated.
63 64 65 |
# File 'lib/guard/coffeescript.rb', line 63 def run_all run_on_changes(Watcher.match_files(self, Dir.glob('**{,/*/**}/*.coffee'))) end |
#run_on_changes(paths) ⇒ Object
Gets called when watched paths and files have changes.
72 73 74 75 76 |
# File 'lib/guard/coffeescript.rb', line 72 def run_on_changes(paths) changed_files, success = Runner.run(Inspector.clean(paths), watchers, ) throw :task_has_failed unless success end |
#run_on_removals(paths) ⇒ Object
Called on file(s) deletions that the Guard watches.
83 84 85 |
# File 'lib/guard/coffeescript.rb', line 83 def run_on_removals(paths) Runner.remove(Inspector.clean(paths, :missing_ok => true), watchers, ) end |
#start ⇒ Object
Gets called once when Guard starts.
55 56 57 |
# File 'lib/guard/coffeescript.rb', line 55 def start run_all if [:all_on_start] end |