guard 1.1.0.alpha.2 → 1.1.0.beta

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ ## 1.1.0 - Unreleased
2
+
3
+ ### Improvements
4
+
5
+ - Listening is now handled by the [Listen gem](https://github.com/guard/listen).
6
+ - New `--latency`/`-l` option to overwrite Listen's default latency.
7
+ - New `--force-polling`/`-p` option to force usage of the Listen polling listener.
8
+ - `--watch-all-modifications`/`-A` option is removed and is now always on.
9
+ - `--no-vendor`/`-I` option is removed because the monitoring gems are now part of the [Listen gem](https://github.com/guard/listen). You can specify a custom version of any monitoring gem directly in your Gemfile if you want to overwrite Listen's default monitoring gems.
10
+ - Guards implementations must now implement `run_on_additions`, `run_on_modifications`, `run_on_removals` and / or `run_on_changes`. The `run_on_change` and `run_on_deletion` methods are deprecated and should be removed as soon as possible. See the [Upgrade guide for existing guards to Guard v1.1](https://github.com/guard/guard/wiki/Upgrade-guide-for-existing-guards-to-Guard-v1.1) for more info.
11
+
12
+ The Listen integration has been supervised by [@thibaudgg][] and executed by [@Maher4Ever][], [@rymai][] and [@thibaudgg][].
13
+
14
+ ## 1.0.3 - 14 May, 2012
15
+
16
+ ### Improvement
17
+
18
+ - Improve Thor dependency '~> 0.14.6' => '>= 0.14.6'. ([@thibaudgg][])
19
+
1
20
  ## 1.0.2 - 30 April, 2012
2
21
 
3
22
  ### Improvements
data/README.md CHANGED
@@ -7,44 +7,9 @@ This document contains a lot of information, please take your time and read thes
7
7
  any questions, ask them in our [Google group](http://groups.google.com/group/guard-dev) or on `#guard`
8
8
  (irc.freenode.net).
9
9
 
10
- Before you file an issue, make sure you have read the [file an issue](#file-an-issue) section that contains some
10
+ Before you file an issue, make sure you have read the file an issue section that contains some
11
11
  important information.
12
12
 
13
- Contents
14
- --------
15
-
16
- * [Features](#features)
17
- * [Screencast](#screencast)
18
- * [Installation](#installation)
19
- * [System notifications](#installation-system-notifications)
20
- * [Add more Guards](#add-more-guards)
21
- * [Usage](#usage)
22
- * [Help](#usage-help)
23
- * [Init](#usage-init)
24
- * [Start](#usage-start)
25
- * [List](#usage-list)
26
- * [Show](#usage-show)
27
- * [Interactions](#interactions)
28
- * [Readline support](#interactions-readline-support)
29
- * [Signals](#interactions-signal)
30
- * [Guardfile DSL](#guardfile-dsl)
31
- * [guard](#guardfile-dsl-guard)
32
- * [watch](#guardfile-dsl-watch)
33
- * [group](#guardfile-dsl-group)
34
- * [notification](#guardfile-dsl-notification)
35
- * [interactor](#guardfile-dsl-interactor)
36
- * [callback](#guardfile-dsl-callback)
37
- * [ignore](#guardfile-dsl-ignore)
38
- * [filter](#guardfile-dsl-filter)
39
- * [Example](#guardfile-dsl-example)
40
- * [Shared configurations](#shared-configurations)
41
- * [Advanced Linux system configuration](#advanced-linux-system-configuration)
42
- * [Create a Guard](#create-a-guard)
43
- * [Programmatic use of Guard](#programmatic-use-of-guard)
44
- * [File an issue](#file-an-issue)
45
- * [Development](#development)
46
-
47
- <a name="features" />
48
13
  Features
49
14
  --------
50
15
 
@@ -53,14 +18,12 @@ Features
53
18
  * Huge ([more than 120](https://rubygems.org/search?query=guard-)) guard extensions eco-system.
54
19
  * Tested against Ruby 1.8.7, 1.9.2, 1.9.3, REE and the latest versions of JRuby & Rubinius.
55
20
 
56
- <a name="screencast" />
57
21
  Screencast
58
22
  ----------
59
23
 
60
24
  Ryan Bates made an excellent [RailsCast about Guard](http://railscasts.com/episodes/264-guard) and you should definitely
61
25
  watch it for a nice introduction to Guard.
62
26
 
63
- <a name="installation" />
64
27
  Installation
65
28
  ------------
66
29
 
@@ -98,7 +61,6 @@ end
98
61
  **It's important that you always run Guard through Bundler to avoid errors.** If you're getting sick of typing `bundle exec` all
99
62
  the time, try the [Rubygems Bundler](https://github.com/mpapis/rubygems-bundler).
100
63
 
101
- <a name="installation-system-notifications" />
102
64
  ### System notifications
103
65
 
104
66
  You can configure Guard to make use of the following system notification libraries, but it's strongly recommended
@@ -206,7 +168,6 @@ group :development do
206
168
  end
207
169
  ```
208
170
 
209
- <a name="add-more-guards" />
210
171
  Add more Guards
211
172
  ---------------
212
173
 
@@ -225,13 +186,11 @@ end
225
186
  See the init section of the Guard usage below to see how to install the supplied Guard template that you can install and
226
187
  to suit your needs.
227
188
 
228
- <a name="usage" />
229
189
  Usage
230
190
  -----
231
191
 
232
192
  Guard is run from the command line. Please open your terminal and go to your project work directory.
233
193
 
234
- <a name="usage-help" />
235
194
  ### Help
236
195
 
237
196
  You can always get help on the available tasks with the `help` task:
@@ -247,7 +206,6 @@ For example, to get help for the `start` task, simply run:
247
206
  $ guard help start
248
207
  ```
249
208
 
250
- <a name="usage-init" />
251
209
  ### Init
252
210
 
253
211
  You can generate a Guardfile and have all installed guards be automatically added into
@@ -285,7 +243,6 @@ $ guard init --bare
285
243
  $ guard init -b # shortcut
286
244
  ```
287
245
 
288
- <a name="usage-start" />
289
246
  ### Start
290
247
 
291
248
  Just launch Guard inside your Ruby or Rails project with:
@@ -375,7 +332,7 @@ $ guard start --no-bundler-warning
375
332
 
376
333
  #### `-l`/`--latency` option
377
334
 
378
- Overwrite Listen default latency, usefull when your harddrive/system is slow.
335
+ Overwrite Listen's default latency, useful when your hard-drive / system is slow.
379
336
 
380
337
  ```bash
381
338
  $ guard start -l 1.5
@@ -391,7 +348,6 @@ $ guard start -p
391
348
  $ guard start --force-polling
392
349
  ```
393
350
 
394
- <a name="usage-list" />
395
351
  ### List
396
352
 
397
353
  You can list the available Guards with the `list` task:
@@ -412,7 +368,6 @@ See also https://github.com/guard/guard/wiki/List-of-available-Guards
412
368
  * denotes ones already in your Guardfile
413
369
  ```
414
370
 
415
- <a name="usage-show" />
416
371
  ### Show
417
372
 
418
373
  You can show the structure of the groups and their Guards with the `show` task:
@@ -433,7 +388,6 @@ Group frontend:
433
388
  This shows the internal structure of the evaluated `Guardfile` or `.Guardfile`, with the `.guard.rb` file. You can
434
389
  read more about these files in the shared configuration section below.
435
390
 
436
- <a name="interactions" />
437
391
  Interactions
438
392
  ------------
439
393
 
@@ -471,7 +425,6 @@ This will reload only the Ronn Guard. You can also reload all Guards within a gr
471
425
  > backend reload
472
426
  ```
473
427
 
474
- <a name="interactions-readline-support" />
475
428
  ### Readline support
476
429
 
477
430
  With Readline enabled, you'll see a command prompt `>` when Guard is ready to accept a command. The command line
@@ -489,7 +442,6 @@ end
489
442
  Guard will automatically enable Readline support if your environment supports it, but you can disable Readline with the
490
443
  `interactor` DSL method or turn off completely with the `--no-interactions` option.
491
444
 
492
- <a name="interactions-signal" />
493
445
  ### Signals
494
446
 
495
447
  You can also interact with Guard by sending POSIX signals to the Guard process (all but Windows).
@@ -506,14 +458,12 @@ $ kill -USR1 <guard_pid>
506
458
  $ kill -USR2 <guard_pid>
507
459
  ```
508
460
 
509
- <a name="guardfile-dsl" />
510
461
  Guardfile DSL
511
462
  -------------
512
463
 
513
464
  The Guardfile DSL is evaluated as plain Ruby, so you can use normal Ruby code in your `Guardfile`.
514
465
  Guard itself provides the following DSL methods that can be used for configuration:
515
466
 
516
- <a name="guardfile-dsl-guard" />
517
467
  ### guard
518
468
 
519
469
  The `guard` method allows you to add a Guard to your toolchain and configure it by passing the
@@ -530,7 +480,6 @@ guard :coffeescript, :input => 'coffeescripts', :output => 'javascripts'
530
480
  guard :coffeescript, :input => 'specs', :output => 'specs'
531
481
  ```
532
482
 
533
- <a name="guardfile-dsl-watch" />
534
483
  ### watch
535
484
 
536
485
  The `watch` method allows you to define which files are watched by a Guard:
@@ -576,7 +525,6 @@ guard :shell do
576
525
  end
577
526
  ```
578
527
 
579
- <a name="guardfile-dsl-group" />
580
528
  ### group
581
529
 
582
530
  The `group` method allows you to group several Guards together. This comes in handy especially when you
@@ -604,7 +552,6 @@ $ guard -g specs
604
552
 
605
553
  Guards that don't belong to a group are considered global and are always run.
606
554
 
607
- <a name="guardfile-dsl-notification" />
608
555
  ### notification
609
556
 
610
557
  If you don't specify any notification configuration in your `Guardfile`, Guard goes through the list of available
@@ -641,7 +588,6 @@ or using the cli switch `-n`:
641
588
  notification :off
642
589
  ```
643
590
 
644
- <a name="guardfile-dsl-interactor" />
645
591
  ### interactor
646
592
 
647
593
  You can disable the interactor auto detection and for a specific implementation:
@@ -662,7 +608,6 @@ If you do not need the keyboard interactions with Guard at all, you can turn the
662
608
  interactor :off
663
609
  ```
664
610
 
665
- <a name="guardfile-dsl-callback" />
666
611
  ### callback
667
612
 
668
613
  The `callback` method allows you to execute arbitrary code before or after any of the `start`, `stop`, `reload`,
@@ -679,7 +624,6 @@ end
679
624
  Please see the [hooks and callbacks](https://github.com/guard/guard/wiki/Hooks-and-callbacks) page in the Guard wiki for
680
625
  more details.
681
626
 
682
- <a name="guardfile-dsl-ignore" />
683
627
  ### ignore
684
628
 
685
629
  The `ignore` method allows you to ignore specific paths. This comes is handy when you have large
@@ -690,7 +634,6 @@ Please note that method only accept regexps. More on the [Listen README](https:/
690
634
  ignore %r{^ignored/path/}, /public/
691
635
  ```
692
636
 
693
- <a name="guardfile-dsl-filter" />
694
637
  ### filter
695
638
 
696
639
  The `filter` method allows you to filter specific paths.
@@ -700,7 +643,6 @@ Please note that method only accept regexps. More on the [Listen README](https:/
700
643
  filter /\.txt$/, /.*\.zip/
701
644
  ```
702
645
 
703
- <a name="guardfile-dsl-example" />
704
646
  ### Example
705
647
 
706
648
  ```ruby
@@ -735,7 +677,6 @@ group :frontend do
735
677
  end
736
678
  ```
737
679
 
738
- <a name="shared-configurations" />
739
680
  Shared configurations
740
681
  ---------------------
741
682
 
@@ -753,7 +694,6 @@ guard :shell do
753
694
  end
754
695
  ```
755
696
 
756
- <a name="advanced-linux-system-configuration" />
757
697
  Advanced Linux system configuration
758
698
  -----------------------------------
759
699
 
@@ -782,7 +722,6 @@ sudo sysctl -p
782
722
 
783
723
  You may also need to pay attention to the values of `max_queued_events` and `max_user_instances`.
784
724
 
785
- <a name="create-a-guard" />
786
725
  Create a Guard
787
726
  --------------
788
727
 
@@ -814,8 +753,9 @@ README.md
814
753
  ```
815
754
 
816
755
  Your Guard main class `Guard::Yoyo` in `lib/guard/guard-yoyo.rb` must inherit from
817
- [Guard::Guard](http://rubydoc.info/github/guard/guard/master/Guard/Guard) and should overwrite at least the
818
- `#run_on_change` task methods.
756
+ [Guard::Guard](http://rubydoc.info/github/guard/guard/master/Guard/Guard) and should implement at least the
757
+ `#run_on_changes` task method. `#run_on_additions`, `#run_on_modifications` and `#run_on_removals` task methods
758
+ could be use instead of `#run_on_changes` task method for more control about how changes are handled.
819
759
 
820
760
  Here is an example scaffold for `lib/guard/yoyo.rb`:
821
761
 
@@ -855,18 +795,11 @@ module Guard
855
795
  def run_all
856
796
  end
857
797
 
858
- # Called on file(s) modifications that the Guard watches.
798
+ # Default behaviour on file(s) changes that the Guard watches.
859
799
  # @param [Array<String>] paths the changes files or paths
860
800
  # @raise [:task_has_failed] when run_on_change has failed
861
- def run_on_change(paths)
862
- end
863
-
864
- # Called on file(s) deletions that the Guard watches.
865
- # @param [Array<String>] paths the deleted files or paths
866
- # @raise [:task_has_failed] when run_on_change has failed
867
- def run_on_deletion(paths)
801
+ def run_on_changes(paths)
868
802
  end
869
-
870
803
  end
871
804
  end
872
805
  ```
@@ -884,7 +817,7 @@ module ::Guard
884
817
  def run_all
885
818
  end
886
819
 
887
- def run_on_change(paths)
820
+ def run_on_changes(paths)
888
821
  end
889
822
  end
890
823
  end
@@ -893,7 +826,6 @@ end
893
826
  [@avdi](https://github.com/avdi) has a very cool inline Guard example in his blog post
894
827
  [A Guardfile for Redis](http://avdi.org/devblog/2011/06/15/a-guardfile-for-redis).
895
828
 
896
- <a name="programmatic-use-of-guard" />
897
829
  Programmatic use of Guard
898
830
  -------------------------
899
831
 
@@ -933,7 +865,6 @@ EOF
933
865
  Guard.start(:guardfile_contents => guardfile)
934
866
  ```
935
867
 
936
- <a name="file-an-issue" />
937
868
  File an issue
938
869
  -------------
939
870
 
@@ -954,7 +885,6 @@ When you file a bug, please try to follow these simple rules if applicable:
954
885
 
955
886
  **It's most likely that your bug gets resolved faster if you provide as much information as possible!**
956
887
 
957
- <a name="development" />
958
888
  Development [![Dependency Status](https://gemnasium.com/guard/guard.png?branch=master)](https://gemnasium.com/guard/guard)
959
889
  -----------
960
890
 
data/lib/guard.rb CHANGED
@@ -406,8 +406,8 @@ module Guard
406
406
 
407
407
  # Deprecation message for the `no_vendor` start option
408
408
  NO_VENDOR_DEPRECATION = <<-EOS.gsub(/^\s*/, '')
409
- Starting with Guard v1.1 the 'no_vendor' option is removed because the monitoring gems are now
410
- a part of a new gem called Listen.
409
+ Starting with Guard v1.1 the 'no_vendor' option is removed because the monitoring
410
+ gems are now part of a new gem called Listen. (https://github.com/guard/listen)
411
411
 
412
412
  You can specify a custom version of any monitoring gem directly in your Gemfile
413
413
  if you want to overwrite Listen's default monitoring gems.
data/lib/guard/cli.rb CHANGED
@@ -77,13 +77,13 @@ module Guard
77
77
  method_option :latency,
78
78
  :type => :numeric,
79
79
  :aliases => '-l',
80
- :banner => 'Overwrite Listen default latency'
80
+ :banner => 'Overwrite Listen\'s default latency'
81
81
 
82
82
  method_option :force_polling,
83
83
  :type => :boolean,
84
84
  :default => false,
85
85
  :aliases => '-p',
86
- :banner => 'Force Listen polling listener usage'
86
+ :banner => 'Force usage of the Listen polling listener'
87
87
 
88
88
  # Start Guard by initialize the defined Guards and watch the file system.
89
89
  # This is the default task, so calling `guard` is the same as calling `guard start`.
data/lib/guard/guard.rb CHANGED
@@ -2,8 +2,13 @@ module Guard
2
2
 
3
3
  # Base class that every Guard implementation must inherit from.
4
4
  #
5
- # Guard will trigger the `start`, `stop`, `reload`, `run_all`, `run_on_change` and
6
- # `run_on_deletion` task methods depending on user interaction and file modification.
5
+ # Guard will trigger the `start`, `stop`, `reload`, `run_all` and `run_on_changes`
6
+ # (`run_on_additions`, `run_on_modifications` and `run_on_removals`) task methods
7
+ # depending on user interaction and file modification.
8
+ #
9
+ # `run_on_changes` could be implemented to handle all the changes task case (additions,
10
+ # modifications, removals) in once, or each task can be implemented separatly with a
11
+ # specific behavior.
7
12
  #
8
13
  # In each of these Guard task methods you have to implement some work when you want to
9
14
  # support this kind of task. The return value of each Guard task method is not evaluated
@@ -81,16 +86,16 @@ module Guard
81
86
  # @raise [:task_has_failed] when start has failed
82
87
  # @return [Object] the task result
83
88
  #
84
- def start
85
- end
89
+ # def start
90
+ # end
86
91
 
87
92
  # Called when `stop|quit|exit|s|q|e + enter` is pressed (when Guard quits).
88
93
  #
89
94
  # @raise [:task_has_failed] when stop has failed
90
95
  # @return [Object] the task result
91
96
  #
92
- def stop
93
- end
97
+ # def stop
98
+ # end
94
99
 
95
100
  # Called when `reload|r|z + enter` is pressed.
96
101
  # This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
@@ -98,8 +103,8 @@ module Guard
98
103
  # @raise [:task_has_failed] when reload has failed
99
104
  # @return [Object] the task result
100
105
  #
101
- def reload
102
- end
106
+ # def reload
107
+ # end
103
108
 
104
109
  # Called when just `enter` is pressed
105
110
  # This method should be principally used for long action like running all specs/tests/...
@@ -107,18 +112,17 @@ module Guard
107
112
  # @raise [:task_has_failed] when run_all has failed
108
113
  # @return [Object] the task result
109
114
  #
110
- def run_all
111
- end
115
+ # def run_all
116
+ # end
112
117
 
113
- # Default behavious on file(s) changes that the Guard watches.
118
+ # Default behaviour on file(s) changes that the Guard watches.
114
119
  #
115
120
  # @param [Array<String>] paths the changes files or paths
116
121
  # @raise [:task_has_failed] when run_on_change has failed
117
122
  # @return [Object] the task result
118
123
  #
119
- def run_on_changes(paths)
120
- raise NotImplementedError
121
- end
124
+ # def run_on_changes(paths)
125
+ # end
122
126
 
123
127
  # Called on file(s) additions that the Guard watches.
124
128
  #
@@ -126,9 +130,8 @@ module Guard
126
130
  # @raise [:task_has_failed] when run_on_change has failed
127
131
  # @return [Object] the task result
128
132
  #
129
- def run_on_addtions(paths)
130
- run_on_changes(paths)
131
- end
133
+ # def run_on_additions(paths)
134
+ # end
132
135
 
133
136
  # Called on file(s) modifications that the Guard watches.
134
137
  #
@@ -136,9 +139,8 @@ module Guard
136
139
  # @raise [:task_has_failed] when run_on_change has failed
137
140
  # @return [Object] the task result
138
141
  #
139
- def run_on_modifications(paths)
140
- run_on_changes(paths)
141
- end
142
+ # def run_on_modifications(paths)
143
+ # end
142
144
 
143
145
  # Called on file(s) removals that the Guard watches.
144
146
  #
@@ -146,20 +148,7 @@ module Guard
146
148
  # @raise [:task_has_failed] when run_on_change has failed
147
149
  # @return [Object] the task result
148
150
  #
149
- def run_on_removals(paths)
150
- run_on_changes(paths)
151
- end
152
-
153
- # @deprecated Use #run_on_modifications or #run_on_addtions instead
154
- #
155
- # def run_on_change(paths)
156
- # raise NotImplementedError
157
- # end
158
-
159
- # @deprecated Use #run_on_removals instead
160
- #
161
- # def run_on_deletion(paths)
162
- # raise NotImplementedError
151
+ # def run_on_removals(paths)
163
152
  # end
164
153
 
165
154
  end
@@ -14,7 +14,8 @@ module Guard
14
14
 
15
15
  # Default options for the notify-send program
16
16
  DEFAULTS = {
17
- :t => 3000 # Default timeout is 3000ms
17
+ :t => 3000, # Default timeout is 3000ms
18
+ :h => 'int:transient:1' # Automatically close the notification
18
19
  }
19
20
 
20
21
  # Full list of options supported by notify-send
data/lib/guard/runner.rb CHANGED
@@ -9,7 +9,7 @@ module Guard
9
9
  Starting with Guard v1.1 the use of the 'run_on_change' method in the '%s' guard is deprecated.
10
10
 
11
11
  Please consider replacing that method-call with 'run_on_changes' if the type of change
12
- is not important for your usecase or using either 'run_on_modifications' or 'run_on_addtions'
12
+ is not important for your usecase or using either 'run_on_modifications' or 'run_on_additions'
13
13
  based on the type of the changes you want to handle.
14
14
 
15
15
  For more information on how to update existing guards, please head over to:
@@ -48,6 +48,10 @@ module Guard
48
48
  end
49
49
  end
50
50
 
51
+ MODIFICATION_TASKS = [:run_on_modifications, :run_on_changes, :run_on_change]
52
+ ADDITION_TASKS = [:run_on_additions, :run_on_changes, :run_on_change]
53
+ REMOVAL_TASKS = [:run_on_removals, :run_on_changes, :run_on_deletion]
54
+
51
55
  # Runs the appropriate tasks on all registered guards
52
56
  # based on the passed changes.
53
57
  #
@@ -61,19 +65,11 @@ module Guard
61
65
  added_paths = Watcher.match_files(guard, added)
62
66
  removed_paths = Watcher.match_files(guard, removed)
63
67
 
64
- if !modified_paths.empty? || !added_paths.empty? || !removed_paths.empty?
65
- UI.clear
68
+ UI.clear if clearable?(guard, modified_paths, added_paths, removed_paths)
66
69
 
67
- unless modified_paths.empty?
68
- run_first_task_found(guard, [:run_on_modifications, :run_on_change], modified_paths)
69
- end
70
- unless added_paths.empty?
71
- run_first_task_found(guard, [:run_on_addtions, :run_on_change], added_paths)
72
- end
73
- unless removed_paths.empty?
74
- run_first_task_found(guard, [:run_on_removals, :run_on_deletion], removed_paths)
75
- end
76
- end
70
+ run_first_task_found(guard, MODIFICATION_TASKS, modified_paths) unless modified_paths.empty?
71
+ run_first_task_found(guard, ADDITION_TASKS, added_paths) unless added_paths.empty?
72
+ run_first_task_found(guard, REMOVAL_TASKS, removed_paths) unless removed_paths.empty?
77
73
  end
78
74
  end
79
75
 
@@ -97,8 +93,8 @@ module Guard
97
93
  result
98
94
  end
99
95
 
100
- rescue NotImplementedError => ex
101
- raise ex
96
+ rescue NoMethodError
97
+ # Do nothing
102
98
  rescue Exception => ex
103
99
  UI.error("#{ guard.class.name } failed to achieve its <#{ task.to_s }>, exception was:" +
104
100
  "\n#{ ex.class }: #{ ex.message }\n#{ ex.backtrace.join("\n") }")
@@ -129,7 +125,7 @@ module Guard
129
125
  group.options[:halt_on_fail] ? :no_catch : :task_has_failed
130
126
  end
131
127
 
132
- private
128
+ private
133
129
 
134
130
  # Tries to run the first implemented task by a given guard
135
131
  # from a collection of tasks.
@@ -139,16 +135,13 @@ module Guard
139
135
  # @param [Object] task_param the param to pass to each task
140
136
  #
141
137
  def run_first_task_found(guard, tasks, task_param)
142
- enum = tasks.to_enum
143
-
144
- begin
145
- task = enum.next
146
- UI.debug "Trying to run #{ guard.class.name }##{ task.to_s } with #{ task_param.inspect }"
147
- run_supervised_task(guard, task, task_param)
148
- rescue StopIteration
149
- # Do nothing
150
- rescue NotImplementedError
151
- retry
138
+ tasks.each do |task|
139
+ if guard.respond_to?(task)
140
+ run_supervised_task(guard, task, task_param)
141
+ break
142
+ else
143
+ UI.debug "Trying to run #{ guard.class.name }##{ task.to_s } with #{ task_param.inspect }"
144
+ end
152
145
  end
153
146
  end
154
147
 
@@ -175,5 +168,19 @@ module Guard
175
168
  end
176
169
  end
177
170
 
171
+ # Logic to know if the UI can be cleared or not in the run_on_changes method
172
+ # based on the guard and the changes.
173
+ #
174
+ # @param [Guard::Guard] guard the guard where run_on_changes is called
175
+ # @param [Array<String>] modified_paths the modified paths.
176
+ # @param [Array<String>] added_paths the added paths.
177
+ # @param [Array<String>] removed_paths the removed paths.
178
+ #
179
+ def clearable?(guard, modified_paths, added_paths, removed_paths)
180
+ (MODIFICATION_TASKS.any? { |task| guard.respond_to?(task) } && !modified_paths.empty?) ||
181
+ (ADDITION_TASKS.any? { |task| guard.respond_to?(task) } && !added_paths.empty?) ||
182
+ (REMOVAL_TASKS.any? { |task| guard.respond_to?(task) } && !removed_paths.empty?)
183
+ end
184
+
178
185
  end
179
186
  end
data/lib/guard/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Guard
2
2
  # The current gem version of Guard
3
- VERSION = '1.1.0.alpha.2'
3
+ VERSION = '1.1.0.beta'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.alpha.2
4
+ version: 1.1.0.beta
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-14 00:00:00.000000000 Z
12
+ date: 2012-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor