guard 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,11 +1,28 @@
1
- ## Master
1
+ ## 1.0.2 - 30 April, 2012
2
+
3
+ ### Improvements
4
+
5
+ - [#274 & #275](https://github.com/guard/guard/issues/274) Make the Bundler warning less scary and more friendly. ([@mcmire][])
6
+ - [#270](https://github.com/guard/guard/issues/270) Make urgency configurable for libnotify/notifysend. ([@viking][])
7
+ - [#254](https://github.com/guard/guard/issues/254) Add the possibility to pause/unpause by sending OS signal. ([@steakknife][])
8
+ - [#261](https://github.com/guard/guard/issues/261) Clarify the usage of the term `guard-name` in the README. ([@spadin][])
9
+ - Add a `--no-bundler-warning` option to Guard start. ([@netzpirat][])
10
+ - Update vendor/darwin. ([@thibaudgg][])
11
+
12
+ ### Bug fixes
13
+
14
+ - [#260](https://github.com/guard/guard/issues/260) Don't show Bundler warning when no Gemfile present. ([@netzpirat][])
15
+ - [#259](https://github.com/guard/guard/issues/259) Fix `guard show` on Ruby 1.8.7. ([@netzpirat][] and [@rymai][])
2
16
 
3
17
  ## 1.0.1 - 7 March, 2012
4
18
 
5
19
  ### Improvements
6
20
 
7
- - [#236](https://github.com/guard/guard/pull/236) Add support for `notifysend`. ([@alandipert][])
21
+ - [#236](https://github.com/guard/guard/issues/236) Add support for `notifysend`. ([@alandipert][])
8
22
  - Update vendor/darwin to rb-fsevent 0.9.0. ([@thibaudgg][])
23
+
24
+ ### Bug fixes
25
+
9
26
  - [#249 & #250](https://github.com/guard/guard/issues/250) Fix programmatic examples that didn't work. ([@oreoshake][])
10
27
  - [#238](https://github.com/guard/guard/issues/238) Don't try to load the FSEvents listener on older versions of OSX. ([@philomory][])
11
28
  - [#233](https://github.com/guard/guard/issues/233) Guard::Listener.select_and_init requires hash. (reported by [@sunaku][], fixed by [@thibaudgg][])
@@ -449,6 +466,8 @@
449
466
  [@rymai]: https://github.com/rymai
450
467
  [@scottdavis]: https://github.com/scottdavis
451
468
  [@semperos]: https://github.com/semperos
469
+ [@spadin]: https://github.com/spadin
470
+ [@steakknife]: https://github.com/steakknife
452
471
  [@stereobooster]: https://github.com/stereobooster
453
472
  [@stouset]: https://github.com/stouset
454
473
  [@sunaku]: https://github.com/sunaku
@@ -459,6 +478,7 @@
459
478
  [@tpope]: https://github.com/tpope
460
479
  [@uk-ar]: https://github.com/uk-ar
461
480
  [@veged]: https://github.com/veged
481
+ [@viking]: https://github.com/viking
462
482
  [@waldo]: https://github.com/waldo
463
483
  [@wereHamster]: https://github.com/wereHamster
464
484
  [@yannlugrin]: https://github.com/yannlugrin
data/README.md CHANGED
@@ -3,9 +3,47 @@ Guard [![Build Status](https://secure.travis-ci.org/guard/guard.png?branch=maste
3
3
 
4
4
  Guard is a command line tool to easily handle events on file system modifications.
5
5
 
6
- If you have any questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
7
- `#guard` (irc.freenode.net).
6
+ This document contains a lot of information, please take your time and read these instructions carefully. If you have
7
+ any questions, ask them in our [Google group](http://groups.google.com/group/guard-dev) or on `#guard`
8
+ (irc.freenode.net).
9
+
10
+ Before you file an issue, make sure you have read the [file an issue](#file-an-issue) section that contains some
11
+ important information.
12
+
13
+ Contents
14
+ --------
8
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_paths](#guardfile-dsl-ignore-paths)
38
+ * [Example](#guardfile-dsl-example)
39
+ * [Shared configurations](#shared-configurations)
40
+ * [Advanced Linux system configuration](#advanced-linux-system-configuration)
41
+ * [Create a Guard](#create-a-guard)
42
+ * [Programmatic use of Guard](#programmatic-use-of-guard)
43
+ * [File an issue](#file-an-issue)
44
+ * [Development](#development)
45
+
46
+ <a name="features" />
9
47
  Features
10
48
  --------
11
49
 
@@ -18,12 +56,14 @@ Features
18
56
  * Support for visual system notifications.
19
57
  * Tested against Ruby 1.8.7, 1.9.2, 1.9.3, REE and the latest versions of JRuby & Rubinius.
20
58
 
59
+ <a name="screencast" />
21
60
  Screencast
22
61
  ----------
23
62
 
24
63
  Ryan Bates made an excellent [RailsCast about Guard](http://railscasts.com/episodes/264-guard) and you should definitely
25
64
  watch it for a nice introduction to Guard.
26
65
 
66
+ <a name="installation" />
27
67
  Installation
28
68
  ------------
29
69
 
@@ -61,6 +101,7 @@ end
61
101
  **It's important that you always run Guard through Bundler to avoid errors.** If you're getting sick of typing `bundle exec` all
62
102
  the time, try the [Rubygems Bundler](https://github.com/mpapis/rubygems-bundler).
63
103
 
104
+ <a name="installation-system-notifications" />
64
105
  ### System notifications
65
106
 
66
107
  You can configure Guard to make use of the following system notification libraries, but it's strongly recommended
@@ -168,6 +209,7 @@ group :development do
168
209
  end
169
210
  ```
170
211
 
212
+ <a name="add-more-guards" />
171
213
  Add more Guards
172
214
  ---------------
173
215
 
@@ -186,11 +228,13 @@ end
186
228
  See the init section of the Guard usage below to see how to install the supplied Guard template that you can install and
187
229
  to suit your needs.
188
230
 
231
+ <a name="usage" />
189
232
  Usage
190
233
  -----
191
234
 
192
235
  Guard is run from the command line. Please open your terminal and go to your project work directory.
193
236
 
237
+ <a name="usage-help" />
194
238
  ### Help
195
239
 
196
240
  You can always get help on the available tasks with the `help` task:
@@ -206,6 +250,7 @@ For example, to get help for the `start` task, simply run:
206
250
  $ guard help start
207
251
  ```
208
252
 
253
+ <a name="usage-init" />
209
254
  ### Init
210
255
 
211
256
  You can generate a Guardfile and have all installed guards be automatically added into
@@ -243,6 +288,7 @@ $ guard init --bare
243
288
  $ guard init -b # shortcut
244
289
  ```
245
290
 
291
+ <a name="usage-start" />
246
292
  ### Start
247
293
 
248
294
  Just launch Guard inside your Ruby or Rails project with:
@@ -330,7 +376,7 @@ $ guard start -i
330
376
  $ guard start --no-interactions
331
377
  ```
332
378
 
333
- ### `-I`/`--no-vendor` option
379
+ #### `-I`/`--no-vendor` option
334
380
 
335
381
  Ignore the use of vendored gems with:
336
382
 
@@ -339,6 +385,16 @@ $ guard start -I
339
385
  $ guard start --no-vendor
340
386
  ```
341
387
 
388
+ #### `-B`/`--no-bundler-warning` option
389
+
390
+ Skip Bundler warning when a Gemfile exists in the project directory but Guard is not run with Bundler.
391
+
392
+ ```bash
393
+ $ guard start -B
394
+ $ guard start --no-bundler-warning
395
+ ```
396
+
397
+ <a name="usage-list" />
342
398
  ### List
343
399
 
344
400
  You can list the available Guards with the `list` task:
@@ -359,6 +415,7 @@ See also https://github.com/guard/guard/wiki/List-of-available-Guards
359
415
  * denotes ones already in your Guardfile
360
416
  ```
361
417
 
418
+ <a name="usage-show" />
362
419
  ### Show
363
420
 
364
421
  You can show the structure of the groups and their Guards with the `show` task:
@@ -379,6 +436,7 @@ Group frontend:
379
436
  This shows the internal structure of the evaluated `Guardfile` or `.Guardfile`, with the `.guard.rb` file. You can
380
437
  read more about these files in the shared configuration section below.
381
438
 
439
+ <a name="interactions" />
382
440
  Interactions
383
441
  ------------
384
442
 
@@ -389,7 +447,7 @@ You can interact with Guard and enter commands when Guard has nothing to do. Gua
389
447
  * `r`, `reload`: Reload all Guards.
390
448
  * `n`, `notification`: Toggle system notifications on and off.
391
449
  * `p`, `pause`: Toggles the file modification listener. The prompt will change to `p>` when paused.
392
- This is useful when switching Git branches.
450
+ This is useful when switching Git branches, rebase Git or change whitespace.
393
451
  * `e`, `exit`: Stop all Guards and quit Guard.
394
452
 
395
453
  Instead of running all Guards with the `↩` key, you can also run a single Guard by entering its name:
@@ -416,6 +474,7 @@ This will reload only the Ronn Guard. You can also reload all Guards within a gr
416
474
  > backend reload
417
475
  ```
418
476
 
477
+ <a name="interactions-readline-support" />
419
478
  ### Readline support
420
479
 
421
480
  With Readline enabled, you'll see a command prompt `>` when Guard is ready to accept a command. The command line
@@ -433,12 +492,31 @@ end
433
492
  Guard will automatically enable Readline support if your environment supports it, but you can disable Readline with the
434
493
  `interactor` DSL method or turn off completely with the `--no-interactions` option.
435
494
 
495
+ <a name="interactions-signal" />
496
+ ### Signals
497
+
498
+ You can also interact with Guard by sending POSIX signals to the Guard process (all but Windows).
499
+
500
+ #### Pause watching
501
+
502
+ ```bash
503
+ $ kill -USR1 <guard_pid>
504
+ ```
505
+
506
+ #### Continue watching
507
+
508
+ ```bash
509
+ $ kill -USR2 <guard_pid>
510
+ ```
511
+
512
+ <a name="guardfile-dsl" />
436
513
  Guardfile DSL
437
514
  -------------
438
515
 
439
516
  The Guardfile DSL is evaluated as plain Ruby, so you can use normal Ruby code in your `Guardfile`.
440
517
  Guard itself provides the following DSL methods that can be used for configuration:
441
518
 
519
+ <a name="guardfile-dsl-guard" />
442
520
  ### guard
443
521
 
444
522
  The `guard` method allows you to add a Guard to your toolchain and configure it by passing the
@@ -455,6 +533,7 @@ guard :coffeescript, :input => 'coffeescripts', :output => 'javascripts'
455
533
  guard :coffeescript, :input => 'specs', :output => 'specs'
456
534
  ```
457
535
 
536
+ <a name="guardfile-dsl-watch" />
458
537
  ### watch
459
538
 
460
539
  The `watch` method allows you to define which files are watched by a Guard:
@@ -500,6 +579,7 @@ guard :shell do
500
579
  end
501
580
  ```
502
581
 
582
+ <a name="guardfile-dsl-group" />
503
583
  ### group
504
584
 
505
585
  The `group` method allows you to group several Guards together. This comes in handy especially when you
@@ -527,6 +607,7 @@ $ guard -g specs
527
607
 
528
608
  Guards that don't belong to a group are considered global and are always run.
529
609
 
610
+ <a name="guardfile-dsl-notification" />
530
611
  ### notification
531
612
 
532
613
  If you don't specify any notification configuration in your `Guardfile`, Guard goes through the list of available
@@ -549,7 +630,7 @@ Each notifier has a slightly different set of supported options:
549
630
  notification :growl, :sticky => true, :host => '192.168.1.5', :password => 'secret'
550
631
  notification :gntp, :sticky => true, :host => '192.168.1.5', :password => 'secret'
551
632
  notification :growl_notify, :sticky => true, :priority => 0
552
- notification :libnotify, :timeout => 5, :transient => true, :append => false
633
+ notification :libnotify, :timeout => 5, :transient => true, :append => false, :urgency => :critical
553
634
  notification :notifu, :time => 5, :nosound => true, :xp => true
554
635
  ```
555
636
 
@@ -563,6 +644,7 @@ or using the cli switch `-n`:
563
644
  notification :off
564
645
  ```
565
646
 
647
+ <a name="guardfile-dsl-interactor" />
566
648
  ### interactor
567
649
 
568
650
  You can disable the interactor auto detection and for a specific implementation:
@@ -583,6 +665,7 @@ If you do not need the keyboard interactions with Guard at all, you can turn the
583
665
  interactor :off
584
666
  ```
585
667
 
668
+ <a name="guardfile-dsl-callback" />
586
669
  ### callback
587
670
 
588
671
  The `callback` method allows you to execute arbitrary code before or after any of the `start`, `stop`, `reload`,
@@ -599,6 +682,7 @@ end
599
682
  Please see the [hooks and callbacks](https://github.com/guard/guard/wiki/Hooks-and-callbacks) page in the Guard wiki for
600
683
  more details.
601
684
 
685
+ <a name="guardfile-dsl-ignore-paths" />
602
686
  ### ignore_paths
603
687
 
604
688
  The `ignore_paths` method allows you to ignore top level directories altogether. This comes is handy when you have large
@@ -609,6 +693,7 @@ Currently it is only possible to ignore the immediate descendants of the watched
609
693
  ignore_paths 'public'
610
694
  ```
611
695
 
696
+ <a name="guardfile-dsl-example" />
612
697
  ### Example
613
698
 
614
699
  ```ruby
@@ -642,6 +727,7 @@ group :frontend do
642
727
  end
643
728
  ```
644
729
 
730
+ <a name="shared-configurations" />
645
731
  Shared configurations
646
732
  ---------------------
647
733
 
@@ -659,6 +745,7 @@ guard :shell do
659
745
  end
660
746
  ```
661
747
 
748
+ <a name="advanced-linux-system-configuration" />
662
749
  Advanced Linux system configuration
663
750
  -----------------------------------
664
751
 
@@ -687,16 +774,16 @@ sudo sysctl -p
687
774
 
688
775
  You may also need to pay attention to the values of `max_queued_events` and `max_user_instances`.
689
776
 
777
+ <a name="create-a-guard" />
690
778
  Create a Guard
691
779
  --------------
692
780
 
693
- Creating a new Guard is very easy, just create a new gem by running `bundle gem guard-name`, where `name` is
694
- the name of your Guard. Please make your Guard start with `guard-`, so that it can easily be found on RubyGems.
781
+ Creating a new Guard is very easy. For example, to create a Guard named `yoyo` just create a new gem by running `bundle gem guard-yoyo`. Please make your Guard start with `guard-`, so that it can easily be found on RubyGems.
695
782
 
696
783
  ```bash
697
- $ mkdir guard-name
698
- $ cd guard-name
699
- $ bundle gem guard-name
784
+ $ mkdir guard-yoyo
785
+ $ cd guard-yoyo
786
+ $ bundle gem guard-yoyo
700
787
  ```
701
788
 
702
789
  Now extend the project structure to have an initial Guard:
@@ -705,31 +792,31 @@ Now extend the project structure to have an initial Guard:
705
792
  .travis.yml # bonus point!
706
793
  CHANGELOG.md # bonus point!
707
794
  Gemfile
708
- guard-name.gemspec
795
+ guard-yoyo.gemspec
709
796
  Guardfile
710
797
  lib/
711
798
  guard/
712
- guard-name/
799
+ yoyo/
713
800
  templates/
714
801
  Guardfile # needed for `guard init <guard-name>`
715
802
  version.rb
716
- guard-name.rb
803
+ yoyo.rb
717
804
  test/ # or spec/
718
805
  README.md
719
806
  ```
720
807
 
721
- Your Guard main class `Guard::GuardName` in `lib/guard/guard-name.rb` must inherit from
808
+ Your Guard main class `Guard::Yoyo` in `lib/guard/guard-yoyo.rb` must inherit from
722
809
  [Guard::Guard](http://rubydoc.info/github/guard/guard/master/Guard/Guard) and should overwrite at least the
723
810
  `#run_on_change` task methods.
724
811
 
725
- Here is an example scaffold for `lib/guard/guard-name.rb`:
812
+ Here is an example scaffold for `lib/guard/yoyo.rb`:
726
813
 
727
814
  ```ruby
728
815
  require 'guard'
729
816
  require 'guard/guard'
730
817
 
731
818
  module Guard
732
- class GuardName < Guard
819
+ class Yoyo < Guard
733
820
 
734
821
  # Initialize a Guard.
735
822
  # @param [Array<Guard::Watcher>] watchers the Guard file watchers
@@ -798,6 +885,7 @@ end
798
885
  [@avdi](https://github.com/avdi) has a very cool inline Guard example in his blog post
799
886
  [A Guardfile for Redis](http://avdi.org/devblog/2011/06/15/a-guardfile-for-redis).
800
887
 
888
+ <a name="programmatic-use-of-guard" />
801
889
  Programmatic use of Guard
802
890
  -------------------------
803
891
 
@@ -837,21 +925,28 @@ EOF
837
925
  Guard.start(:guardfile_contents => guardfile)
838
926
  ```
839
927
 
840
- Issues
841
- ------
928
+ <a name="file-an-issue" />
929
+ File an issue
930
+ -------------
842
931
 
843
- You can report issues and feature requests to [GitHub Issues](https://github.com/guard/guard/issues). Try to figure out
844
- where the issue belongs to: Is it an issue with Guard itself or with a Guard implementation you're using? Please don't
845
- ask question in the issue tracker, instead join us in our [Google group](http://groups.google.com/group/guard-dev) or on
846
- `#guard` (irc.freenode.net).
932
+ You can report bugs and feature requests to [GitHub Issues](https://github.com/guard/guard/issues).
847
933
 
848
- When you file an issue, please try to follow to these simple rules if applicable:
934
+ **Please don't ask question in the issue tracker**, instead ask them in our
935
+ [Google group](http://groups.google.com/group/guard-dev) or on `#guard` (irc.freenode.net).
936
+
937
+ Try to figure out where the issue belongs to: Is it an issue with Guard itself or with a Guard implementation you're
938
+ using?
939
+
940
+ When you file a bug, please try to follow these simple rules if applicable:
849
941
 
850
942
  * Make sure you run Guard with `bundle exec` first.
851
943
  * Add verbose information to the issue by running Guard with the `--verbose` option.
852
944
  * Add your `Guardfile` and `Gemfile` to the issue.
853
945
  * Make sure that the issue is reproducible with your description.
854
946
 
947
+ **It's most likely that your bug gets resolved faster if you provide as much information as possible!**
948
+
949
+ <a name="development" />
855
950
  Development [![Dependency Status](https://gemnasium.com/guard/guard.png?branch=master)](https://gemnasium.com/guard/guard)
856
951
  -----------
857
952
 
@@ -871,19 +966,17 @@ Pull requests are very welcome! Please try to follow these simple rules if appli
871
966
  For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
872
967
  `#guard` (irc.freenode.net).
873
968
 
874
- Core Team
875
- ---------
969
+ ### Author
876
970
 
877
- * [Michael Kessler](https://github.com/netzpirat) ([@netzpirat](http://twitter.com/netzpirat)), sponsored by [mksoft.ch](https://mksoft.ch)
878
- * [Rémy Coutable](https://github.com/rymai) ([@rymai](http://twitter.com/rymai))
879
- * [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](http://twitter.com/thibaudgg))
971
+ [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](http://twitter.com/thibaudgg))
880
972
 
881
- Author
882
- ------
973
+ ### Core Team
883
974
 
884
- [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](http://twitter.com/thibaudgg))
975
+ * [Maher Sallam](https://github.com/Maher4Ever) ([@mahersalam](http://twitter.com/mahersalam))
976
+ * [Michael Kessler](https://github.com/netzpirat) ([@netzpirat](http://twitter.com/netzpirat), [mksoft.ch](https://mksoft.ch))
977
+ * [Rémy Coutable](https://github.com/rymai) ([@rymai](http://twitter.com/rymai), [rymai.me](http://rymai.me/))
978
+ * [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](http://twitter.com/thibaudgg), [thibaud.me](http://thibaud.me/))
885
979
 
886
- Contributors
887
- ------------
980
+ ### Contributors
888
981
 
889
982
  [https://github.com/guard/guard/contributors](https://github.com/guard/guard/contributors)
data/lib/guard.rb CHANGED
@@ -100,6 +100,14 @@ module Guard
100
100
  self.reset_groups
101
101
  @listener = Listener.select_and_init(options)
102
102
 
103
+ if Signal.list.keys.include?('USR1')
104
+ Signal.trap('USR1') { ::Guard.pause unless @listener.paused? }
105
+ end
106
+
107
+ if Signal.list.keys.include?('USR2')
108
+ Signal.trap('USR2') { ::Guard.pause if @listener.paused? }
109
+ end
110
+
103
111
  UI.clear if @options[:clear]
104
112
  debug_command_execution if @options[:verbose]
105
113
 
data/lib/guard/cli.rb CHANGED
@@ -65,13 +65,19 @@ module Guard
65
65
  :aliases => '-i',
66
66
  :banner => 'Turn off completely any guard terminal interactions'
67
67
 
68
+ method_option :no_bundler_warning,
69
+ :type => :boolean,
70
+ :default => false,
71
+ :aliases => '-B',
72
+ :banner => 'Turn off warning when Bundler is not present'
73
+
68
74
  # Start Guard by initialize the defined Guards and watch the file system.
69
75
  # This is the default task, so calling `guard` is the same as calling `guard start`.
70
76
  #
71
77
  # @see Guard.start
72
78
  #
73
79
  def start
74
- verify_bundler_presence
80
+ verify_bundler_presence unless options[:no_bundler_warning]
75
81
  ::Guard.start(options)
76
82
  rescue Interrupt
77
83
  ::Guard.stop
@@ -152,7 +158,16 @@ module Guard
152
158
  # shows a hint to do so if not.
153
159
  #
154
160
  def verify_bundler_presence
155
- ::Guard::UI.warning "You are using Guard outside of Bundler, this is dangerous and may not work. Using `bundle exec guard` is safer." unless ENV['BUNDLE_GEMFILE']
161
+ if File.exists?('Gemfile') && !ENV['BUNDLE_GEMFILE']
162
+ ::Guard::UI.info <<EOF
163
+
164
+ Guard here! It looks like your project has a Gemfile, yet you are running
165
+ `guard` outside of Bundler. If this is your intent, feel free to ignore this
166
+ message. Otherwise, consider using `bundle exec guard` to ensure your
167
+ dependencies are loaded correctly.
168
+ (You can run `guard` with --no-bundler-warning to get rid of this message.)
169
+ EOF
170
+ end
156
171
  end
157
172
 
158
173
  end
@@ -91,7 +91,7 @@ module Guard
91
91
  line = " #{ guard[:name] }"
92
92
 
93
93
  unless guard[:options].empty?
94
- line += ": #{ guard[:options].sort.collect { |k, v| "#{ k } => #{ v.inspect }" }.join(', ') }"
94
+ line += ": #{ guard[:options].inject({}) { |options, (k, v)| options[k.to_s] = v; options }.sort.collect { |k, v| "#{ k } => #{ v.inspect }" }.join(', ') }"
95
95
  end
96
96
 
97
97
  UI.info line
@@ -76,24 +76,6 @@ module Guard
76
76
  start_reactor
77
77
  end
78
78
 
79
- # Start the listener thread.
80
- #
81
- def start_reactor
82
- return if ENV["GUARD_ENV"] == 'test'
83
-
84
- Thread.new do
85
- loop do
86
- if @changed_files != [] && !@paused
87
- changed_files = @changed_files.dup
88
- clear_changed_files
89
- ::Guard.run_on_change(changed_files)
90
- else
91
- sleep 0.1
92
- end
93
- end
94
- end
95
- end
96
-
97
79
  # Start watching the root directory.
98
80
  #
99
81
  def start
@@ -240,6 +222,24 @@ module Guard
240
222
 
241
223
  private
242
224
 
225
+ # Start the listener thread.
226
+ #
227
+ def start_reactor
228
+ return if ENV["GUARD_ENV"] == 'test'
229
+
230
+ Thread.new do
231
+ loop do
232
+ if @changed_files != [] && !@paused
233
+ changed_files = @changed_files.dup
234
+ clear_changed_files
235
+ ::Guard.run_on_change(changed_files)
236
+ else
237
+ sleep 0.1
238
+ end
239
+ end
240
+ end
241
+ end
242
+
243
243
  # Gets a list of files that are in the modified directories.
244
244
  #
245
245
  # @param [Array<String>] dirs the list of directories
@@ -17,7 +17,7 @@ module Guard
17
17
  # notification :libnotify
18
18
  #
19
19
  # @example Add the `:libnotify` notifier with configuration options to your `Guardfile`
20
- # notification :libnotify, :timeout => 5, :transient => true, :append => false
20
+ # notification :libnotify, :timeout => 5, :transient => true, :append => false, :urgency => :critical
21
21
  #
22
22
  module Libnotify
23
23
  extend self
@@ -64,12 +64,13 @@ module Guard
64
64
  def notify(type, title, message, image, options = { })
65
65
  require 'libnotify'
66
66
 
67
- ::Libnotify.show(DEFAULTS.merge(options).merge({
68
- :urgency => libnotify_urgency(type),
67
+ options = DEFAULTS.merge(options).merge({
69
68
  :summary => title,
70
69
  :body => message,
71
70
  :icon_path => image
72
- }))
71
+ })
72
+ options[:urgency] ||= libnotify_urgency(type)
73
+ ::Libnotify.show(options)
73
74
  end
74
75
 
75
76
  private
@@ -83,8 +84,6 @@ module Guard
83
84
  def libnotify_urgency(type)
84
85
  case type
85
86
  when 'failed'
86
- :critical
87
- when 'pending'
88
87
  :normal
89
88
  else
90
89
  :low
@@ -14,7 +14,7 @@ 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
18
  }
19
19
 
20
20
  # Full list of options supported by notify-send
@@ -46,10 +46,11 @@ module Guard
46
46
  #
47
47
  def notify(type, title, message, image, options = { })
48
48
  command = "notify-send '#{title}' '#{message}'"
49
- system(to_command_string(command, SUPPORTED, DEFAULTS.merge(options).merge({
50
- :u => notifysend_urgency(type),
49
+ options = DEFAULTS.merge(options).merge({
51
50
  :i => image
52
- })))
51
+ })
52
+ options[:u] ||= notifysend_urgency(type)
53
+ system(to_command_string(command, SUPPORTED, options))
53
54
  end
54
55
 
55
56
  private
@@ -61,7 +62,7 @@ module Guard
61
62
  # @return [String] the notify-send urgency
62
63
  #
63
64
  def notifysend_urgency(type)
64
- {'failed' => 'critical', 'pending' => 'normal'}.fetch(type, 'low')
65
+ { 'failed' => 'normal', 'pending' => 'low' }.fetch(type, 'low')
65
66
  end
66
67
 
67
68
  # Build a shell command out of a command string and option hash.
data/lib/guard/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Guard
2
2
  unless defined? Guard::VERSION
3
3
  # The current gem version of Guard
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
6
6
  end
@@ -14,6 +14,10 @@ class FSEvent
14
14
 
15
15
  attr_reader :paths, :callback
16
16
 
17
+ def initialize args = nil, &block
18
+ watch(args, &block) unless args.nil?
19
+ end
20
+
17
21
  def watch(watch_paths, options=nil, &block)
18
22
  @paths = watch_paths.kind_of?(Array) ? watch_paths : [watch_paths]
19
23
  @callback = block
@@ -28,12 +32,14 @@ class FSEvent
28
32
  end
29
33
 
30
34
  def run
35
+ @pipe = open_pipe
31
36
  @running = true
37
+
32
38
  # please note the use of IO::select() here, as it is used specifically to
33
39
  # preserve correct signal handling behavior in ruby 1.8.
34
- while @running && IO::select([pipe], nil, nil, nil)
35
- if line = pipe.readline
36
- modified_dir_paths = line.split(":").select { |dir| dir != "\n" }
40
+ while @running && IO::select([@pipe], nil, nil, nil)
41
+ if line = @pipe.readline
42
+ modified_dir_paths = line.split(':').select { |dir| dir != "\n" }
37
43
  callback.call(modified_dir_paths)
38
44
  end
39
45
  end
@@ -43,18 +49,18 @@ class FSEvent
43
49
  end
44
50
 
45
51
  def stop
46
- if pipe
47
- Process.kill("KILL", pipe.pid)
48
- pipe.close
52
+ unless @pipe.nil?
53
+ Process.kill('KILL', @pipe.pid)
54
+ @pipe.close
49
55
  end
50
56
  rescue IOError
51
57
  ensure
52
- @pipe = @running = nil
58
+ @running = false
53
59
  end
54
60
 
55
61
  if RUBY_VERSION < '1.9'
56
- def pipe
57
- @pipe ||= IO.popen("#{self.class.watcher_path} #{options_string} #{shellescaped_paths}")
62
+ def open_pipe
63
+ IO.popen("#{self.class.watcher_path} #{options_string} #{shellescaped_paths}")
58
64
  end
59
65
 
60
66
  private
@@ -85,8 +91,8 @@ class FSEvent
85
91
  return str
86
92
  end
87
93
  else
88
- def pipe
89
- @pipe ||= IO.popen([self.class.watcher_path] + @options + @paths)
94
+ def open_pipe
95
+ IO.popen([self.class.watcher_path] + @options + @paths)
90
96
  end
91
97
  end
92
98
 
@@ -1,3 +1,3 @@
1
1
  class FSEvent
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "rb-fsevent"
16
16
 
17
- s.add_development_dependency 'bundler', '~> 1.0.10'
17
+ s.add_development_dependency 'bundler', '~> 1.0'
18
18
  s.add_development_dependency 'rspec', '~> 2.5.0'
19
19
  s.add_development_dependency 'guard-rspec', '~> 0.1.9'
20
20
 
@@ -10,6 +10,19 @@ describe FSEvent do
10
10
  end
11
11
  end
12
12
 
13
+ it "shouldn't pass anything to watch when instantiated without a path" do
14
+ fsevent = FSEvent.new
15
+ fsevent.paths.should be_nil
16
+ fsevent.callback.should be_nil
17
+ end
18
+
19
+ it "should pass path and block to watch when instantiated with them" do
20
+ blk = proc { }
21
+ fsevent = FSEvent.new(@fixture_path, &blk)
22
+ fsevent.paths.should == [@fixture_path]
23
+ fsevent.callback.should == blk
24
+ end
25
+
13
26
  it "should have a watcher_path that resolves to an executable file" do
14
27
  File.exists?(FSEvent.watcher_path).should be_true
15
28
  File.executable?(FSEvent.watcher_path).should be_true
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.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-07 00:00:00.000000000 Z
12
+ date: 2012-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70307690665580 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 0.14.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70307690665580
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.14.6
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: ffi
27
- requirement: &70307690665040 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 0.5.0
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70307690665040
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.5.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: bundler
38
- requirement: &70307690664440 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70307690664440
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: rspec
49
- requirement: &70307690663480 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: 2.8.0
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70307690663480
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.8.0
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: guard-rspec
60
- requirement: &70307690662360 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: 0.6.0
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *70307690662360
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.6.0
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: yard
71
- requirement: &70307690661980 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: '0'
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *70307690661980
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: redcarpet
82
- requirement: &70307690661460 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ! '>='
@@ -87,10 +117,15 @@ dependencies:
87
117
  version: '0'
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *70307690661460
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: pry
93
- requirement: &70307690660580 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ! '>='
@@ -98,7 +133,12 @@ dependencies:
98
133
  version: '0'
99
134
  type: :development
100
135
  prerelease: false
101
- version_requirements: *70307690660580
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
102
142
  description: Guard is a command line tool to easily handle events on file system modifications.
103
143
  email:
104
144
  - thibaud@thibaud.me
@@ -137,7 +177,6 @@ files:
137
177
  - lib/guard/templates/Guardfile
138
178
  - lib/guard/ui.rb
139
179
  - lib/guard/version.rb
140
- - lib/guard/version.rbc
141
180
  - lib/guard/watcher.rb
142
181
  - lib/guard.rb
143
182
  - lib/vendor/darwin/bin/fsevent_watch
@@ -214,6 +253,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
214
253
  - - ! '>='
215
254
  - !ruby/object:Gem::Version
216
255
  version: '0'
256
+ segments:
257
+ - 0
258
+ hash: -3612619536525068345
217
259
  required_rubygems_version: !ruby/object:Gem::Requirement
218
260
  none: false
219
261
  requirements:
@@ -222,8 +264,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
264
  version: 1.3.6
223
265
  requirements: []
224
266
  rubyforge_project: guard
225
- rubygems_version: 1.8.15
267
+ rubygems_version: 1.8.23
226
268
  signing_key:
227
269
  specification_version: 3
228
270
  summary: Guard keeps an eye on your file modifications
229
271
  test_files: []
272
+ has_rdoc:
@@ -1,180 +0,0 @@
1
- !RBIX
2
- 16846133056282117387
3
- x
4
- M
5
- 1
6
- n
7
- n
8
- x
9
- 10
10
- __script__
11
- i
12
- 28
13
- 99
14
- 7
15
- 0
16
- 65
17
- 49
18
- 1
19
- 2
20
- 13
21
- 99
22
- 12
23
- 7
24
- 2
25
- 12
26
- 7
27
- 3
28
- 12
29
- 65
30
- 12
31
- 49
32
- 4
33
- 4
34
- 15
35
- 49
36
- 2
37
- 0
38
- 15
39
- 2
40
- 11
41
- I
42
- 6
43
- I
44
- 0
45
- I
46
- 0
47
- I
48
- 0
49
- n
50
- p
51
- 5
52
- x
53
- 5
54
- Guard
55
- x
56
- 11
57
- open_module
58
- x
59
- 15
60
- __module_init__
61
- M
62
- 1
63
- n
64
- n
65
- x
66
- 5
67
- Guard
68
- i
69
- 48
70
- 5
71
- 66
72
- 26
73
- 93
74
- 0
75
- 15
76
- 29
77
- 21
78
- 0
79
- 45
80
- 0
81
- 1
82
- 7
83
- 2
84
- 3
85
- 98
86
- 3
87
- 3
88
- 30
89
- 8
90
- 27
91
- 25
92
- 92
93
- 0
94
- 27
95
- 8
96
- 32
97
- 15
98
- 7
99
- 4
100
- 8
101
- 33
102
- 1
103
- 9
104
- 38
105
- 1
106
- 8
107
- 47
108
- 65
109
- 7
110
- 2
111
- 7
112
- 5
113
- 64
114
- 49
115
- 6
116
- 2
117
- 11
118
- I
119
- 4
120
- I
121
- 0
122
- I
123
- 0
124
- I
125
- 0
126
- n
127
- p
128
- 7
129
- x
130
- 5
131
- Guard
132
- n
133
- x
134
- 7
135
- VERSION
136
- x
137
- 22
138
- vm_const_defined_under
139
- s
140
- 8
141
- constant
142
- s
143
- 5
144
- 0.6.3
145
- x
146
- 9
147
- const_set
148
- p
149
- 5
150
- I
151
- 2
152
- I
153
- 2
154
- I
155
- 2f
156
- I
157
- 0
158
- I
159
- 30
160
- x
161
- 66
162
- /Users/remy/Development/Ruby/Gems/guard/guard/lib/guard/version.rb
163
- p
164
- 0
165
- x
166
- 13
167
- attach_method
168
- p
169
- 3
170
- I
171
- 0
172
- I
173
- 1
174
- I
175
- 1c
176
- x
177
- 66
178
- /Users/remy/Development/Ruby/Gems/guard/guard/lib/guard/version.rb
179
- p
180
- 0