guard 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/CHANGELOG.md +17 -0
  2. data/README.md +50 -30
  3. data/bin/fsevent_watch_guard_guard +0 -0
  4. data/lib/guard.rb +44 -26
  5. data/lib/guard/cli.rb +23 -6
  6. data/lib/guard/dsl.rb +33 -15
  7. data/lib/guard/listener.rb +1 -1
  8. data/lib/guard/listeners/darwin.rb +1 -1
  9. data/lib/guard/notifier.rb +3 -1
  10. data/lib/guard/notifiers/notifysend.rb +81 -0
  11. data/lib/guard/version.rb +1 -1
  12. data/lib/guard/version.rbc +180 -0
  13. data/lib/vendor/darwin/README.rdoc +3 -2
  14. data/lib/vendor/darwin/bin/fsevent_watch +0 -0
  15. data/lib/vendor/darwin/ext/fsevent_watch/Info.plist +38 -0
  16. data/lib/vendor/darwin/ext/fsevent_watch/LICENSE +21 -0
  17. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch.xcodeproj/project.pbxproj +254 -0
  18. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/TSICTString.c +394 -0
  19. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/TSICTString.h +74 -0
  20. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/cli.c +160 -0
  21. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/cli.h +45 -0
  22. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/common.h +34 -0
  23. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/compat.c +20 -0
  24. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/compat.h +40 -0
  25. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/main.c +509 -0
  26. data/lib/vendor/darwin/ext/fsevent_watch/xcconfig/Common.xcconfig +82 -0
  27. data/lib/vendor/darwin/ext/fsevent_watch/xcconfig/Debug.xcconfig +19 -0
  28. data/lib/vendor/darwin/ext/fsevent_watch/xcconfig/Release.xcconfig +23 -0
  29. data/lib/vendor/darwin/ext/fsevent_watch/xcconfig/fsevent_watch.xcconfig +17 -0
  30. data/lib/vendor/darwin/ext/rakefile.rb +47 -0
  31. data/lib/vendor/darwin/ext/rb-fsevent.xcconfig +33 -0
  32. data/lib/vendor/darwin/lib/rb-fsevent/version.rb +1 -1
  33. data/lib/vendor/darwin/rb-fsevent.gemspec +3 -2
  34. data/lib/vendor/darwin/spec/spec_helper.rb +1 -2
  35. metadata +40 -25
  36. data/lib/vendor/darwin/ext/extconf.rb +0 -64
  37. data/lib/vendor/darwin/ext/fsevent/fsevent_watch.c +0 -226
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## Master
2
+
3
+ ## 1.0.1 - 7 March, 2012
4
+
5
+ ### Improvements
6
+
7
+ - [#236](https://github.com/guard/guard/pull/236) Add support for `notifysend`. ([@alandipert][])
8
+ - Update vendor/darwin to rb-fsevent 0.9.0. ([@thibaudgg][])
9
+ - [#249 & #250](https://github.com/guard/guard/issues/250) Fix programmatic examples that didn't work. ([@oreoshake][])
10
+ - [#238](https://github.com/guard/guard/issues/238) Don't try to load the FSEvents listener on older versions of OSX. ([@philomory][])
11
+ - [#233](https://github.com/guard/guard/issues/233) Guard::Listener.select_and_init requires hash. (reported by [@sunaku][], fixed by [@thibaudgg][])
12
+ - [#227 & #232](https://github.com/guard/guard/issues/232) Add the ability to initialize all guards at once. (proposed by [@rupert654][], done by [@Maher4Ever][])
13
+
1
14
  ## 1.0.0 - 19 January, 2012
2
15
 
3
16
  ### Improvements
@@ -385,6 +398,7 @@
385
398
  - Improved listeners support (`rb-fsevent` & `rb-inotify`). ([@thibaudgg][])
386
399
  - Added polling listening fallback. ([@thibaudgg][])
387
400
 
401
+ [@alandipert]: https://github.com/alandipert
388
402
  [@anithri]: https://github.com/anithri
389
403
  [@benolee]: https://github.com/benolee
390
404
  [@brainopia]: https://github.com/brainopia
@@ -426,9 +440,12 @@
426
440
  [@nicksieger]: https://github.com/nicksieger
427
441
  [@niklas]: https://github.com/niklas
428
442
  [@oliamb]: https://github.com/oliamb
443
+ [@oreoshake]: https://github.com/oreoshake
429
444
  [@pcreux]: https://github.com/pcreux
445
+ [@philomory]: https://github.com/philomory
430
446
  [@pirukire]: https://github.com/pirukire
431
447
  [@rmm5t]: https://github.com/rmm5t
448
+ [@rupert654]: https://github.com/rupert654
432
449
  [@rymai]: https://github.com/rymai
433
450
  [@scottdavis]: https://github.com/scottdavis
434
451
  [@semperos]: https://github.com/semperos
data/README.md CHANGED
@@ -66,8 +66,31 @@ the time, try the [Rubygems Bundler](https://github.com/mpapis/rubygems-bundler)
66
66
  You can configure Guard to make use of the following system notification libraries, but it's strongly recommended
67
67
  to use either Ruby GNTP, Libnotify or Notifu:
68
68
 
69
+ #### Growl
70
+
71
+ * Runs on Mac OS X
72
+ * Supports all [Growl](http://growl.info/) versions
73
+
74
+ The [growl](https://rubygems.org/gems/growl) gem is compatible with all versions of Growl and uses a command line tool
75
+ [growlnotify](http://growl.info/extras.php#growlnotify) that must be separately downloaded and installed. The version of
76
+ the command line tool must match your Growl version. The `growl` gem does **not** support multiple notification
77
+ channels.
78
+
79
+ You have to download the installer for `growlnotify` from the [Growl download section](http://growl.info/downloads).
80
+
81
+ To use `growl` you have to add it to your `Gemfile` and run bundler:
82
+
83
+ ```ruby
84
+ group :development do
85
+ gem 'growl'
86
+ end
87
+ ```
88
+
69
89
  #### Ruby GNTP
70
90
 
91
+ **There's currently a bug in Growl that prevents displaying the icons through GNTP, see
92
+ [issue #231](https://github.com/guard/guard/issues/231). Use the growl gem until fixed.**
93
+
71
94
  * Runs on Mac OS X, Linux and Windows
72
95
  * Supports [Growl](http://growl.info/) version >= 1.3, [Growl for Linux](http://mattn.github.com/growl-for-linux/),
73
96
  [Growl for Windows](http://www.growlforwindows.com/gfw/default.aspx) and
@@ -105,6 +128,10 @@ group :development do
105
128
  end
106
129
  ```
107
130
 
131
+ If you are unable to build the `libnotify` gem on your system, Guard
132
+ also has a built in notifier - `notifysend` - that shells out to the
133
+ `notify-send` utility that comes with `libnotify-bin`.
134
+
108
135
  #### Notifu
109
136
 
110
137
  * Runs on Windows
@@ -120,26 +147,6 @@ group :development do
120
147
  end
121
148
  ```
122
149
 
123
- #### Growl
124
-
125
- * Runs on Mac OS X
126
- * Supports all [Growl](http://growl.info/) versions
127
-
128
- The [growl](https://rubygems.org/gems/growl) gem is compatible with all versions of Growl and uses a command line tool
129
- [growlnotify](http://growl.info/extras.php#growlnotify) that must be separately downloaded and installed. The version of
130
- the command line tool must match your Growl version. The `growl` gem does **not** support multiple notification
131
- channels.
132
-
133
- You have to download the installer for `growlnotify` from the [Growl download section](http://growl.info/downloads).
134
-
135
- To use `growl` you have to add it to your `Gemfile` and run bundler:
136
-
137
- ```ruby
138
- group :development do
139
- gem 'growl'
140
- end
141
- ```
142
-
143
150
  #### GrowlNotify
144
151
 
145
152
  * Runs on Mac OS X
@@ -201,26 +208,41 @@ $ guard help start
201
208
 
202
209
  ### Init
203
210
 
204
- You can generate an empty `Guardfile` by running the `init` task:
211
+ You can generate a Guardfile and have all installed guards be automatically added into
212
+ it by running the `init` task without any option:
205
213
 
206
214
  ```bash
207
215
  $ guard init
208
216
  ```
209
217
 
210
- In addition, the `init` task can be used to append a supplied Guard template from an installed Guard to your existing
211
- `Guardfile`:
218
+ You can also specify the name of an installed Guard to only get that Guard
219
+ in the generated Guardfile:
212
220
 
213
221
  ```bash
214
222
  $ guard init <guard-name>
215
223
  ```
216
224
 
217
- You can also define your own templates in `~/.guard/templates/` which can be appended in the same way to your existing
225
+ You can also define your own templates in `~/.guard/templates/` which can be appended in the same way to your existing
218
226
  `Guardfile`:
219
227
 
220
228
  ```bash
221
229
  $ guard init <template-name>
222
230
  ```
223
231
 
232
+ **Note**: If you already have a `Guardfile` in the current directory, the `init` task can be used
233
+ to append a supplied Guard template from an installed Guard to your existing
234
+ `Guardfile`.
235
+
236
+ #### `-b`/`--bare` option
237
+
238
+ You can generate an empty `Guardfile` by running the `init` task with the bare
239
+ option:
240
+
241
+ ```bash
242
+ $ guard init --bare
243
+ $ guard init -b # shortcut
244
+ ```
245
+
224
246
  ### Start
225
247
 
226
248
  Just launch Guard inside your Ruby or Rails project with:
@@ -796,8 +818,7 @@ Evaluate a `Guardfile`:
796
818
  require 'guard'
797
819
 
798
820
  Guard.setup
799
- Guard::Dsl.evaluate_guardfile(:guardfile => '/path/to/Guardfile')
800
- Guard.start
821
+ Guard.start(:guardfile => '/path/to/Guardfile')
801
822
  ```
802
823
 
803
824
  Evaluate a string as `Guardfile`:
@@ -813,8 +834,7 @@ guardfile = <<-EOF
813
834
  end
814
835
  EOF
815
836
 
816
- Guard::Dsl.evaluate_guardfile(:guardfile_contents => guardfile)
817
- Guard.start
837
+ Guard.start(:guardfile_contents => guardfile)
818
838
  ```
819
839
 
820
840
  Issues
@@ -832,7 +852,7 @@ When you file an issue, please try to follow to these simple rules if applicable
832
852
  * Add your `Guardfile` and `Gemfile` to the issue.
833
853
  * Make sure that the issue is reproducible with your description.
834
854
 
835
- Development [![Dependency Status](https://gemnasium.com/guard/guard.png?branch=master)](https://gemnasium.com/guard/guard)
855
+ Development [![Dependency Status](https://gemnasium.com/guard/guard.png?branch=master)](https://gemnasium.com/guard/guard)
836
856
  -----------
837
857
 
838
858
  * Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/guard/master/frames).
@@ -854,7 +874,7 @@ For questions please join us in our [Google group](http://groups.google.com/grou
854
874
  Core Team
855
875
  ---------
856
876
 
857
- * [Michael Kessler](https://github.com/netzpirat) ([@netzpirat](http://twitter.com/netzpirat))
877
+ * [Michael Kessler](https://github.com/netzpirat) ([@netzpirat](http://twitter.com/netzpirat)), sponsored by [mksoft.ch](https://mksoft.ch)
858
878
  * [Rémy Coutable](https://github.com/rymai) ([@rymai](http://twitter.com/rymai))
859
879
  * [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](http://twitter.com/thibaudgg))
860
880
 
Binary file
data/lib/guard.rb CHANGED
@@ -23,44 +23,62 @@ module Guard
23
23
  class << self
24
24
  attr_accessor :options, :interactor, :listener, :lock
25
25
 
26
- # Creates the initial Guardfile template and/or add a Guard implementation
27
- # Guardfile template to an existing Guardfile.
26
+ # Creates the initial Guardfile template when it does not
27
+ # already exist.
28
28
  #
29
- # @see Guard::Guard.init
29
+ # @see Guard::CLI.init
30
30
  #
31
- # @param [String] guard_name the name of the Guard or template to initialize
31
+ # @param [Hash] options The options for creating a Guardfile
32
+ # @option options [Boolean] :abort_on_existence Whether to abort or not when a Guardfile already exists
32
33
  #
33
- def initialize_template(guard_name = nil)
34
+ def create_guardfile(options = {})
34
35
  if !File.exist?('Guardfile')
35
36
  ::Guard::UI.info "Writing new Guardfile to #{ Dir.pwd }/Guardfile"
36
37
  FileUtils.cp(GUARDFILE_TEMPLATE, 'Guardfile')
37
- elsif guard_name.nil?
38
+ elsif options[:abort_on_existence]
38
39
  ::Guard::UI.error "Guardfile already exists at #{ Dir.pwd }/Guardfile"
39
- exit 1
40
+ abort
40
41
  end
42
+ end
41
43
 
42
- if guard_name
43
- guard_class = ::Guard.get_guard_class(guard_name, true)
44
- if guard_class
45
- guard_class.init(guard_name)
46
- elsif File.exist?(File.join(HOME_TEMPLATES, guard_name))
47
- content = File.read('Guardfile')
48
- template = File.read(File.join(HOME_TEMPLATES, guard_name))
49
-
50
- File.open('Guardfile', 'wb') do |f|
51
- f.puts(content)
52
- f.puts("")
53
- f.puts(template)
54
- end
44
+ # Adds the Guardfile template of a Guard implementation
45
+ # to an existing Guardfile.
46
+ #
47
+ # @see Guard::CLI.init
48
+ #
49
+ # @param [String] guard_name the name of the Guard or template to initialize
50
+ #
51
+ def initialize_template(guard_name)
52
+ guard_class = ::Guard.get_guard_class(guard_name, true)
55
53
 
56
- ::Guard::UI.info "#{ guard_name } template added to Guardfile, feel free to edit it"
57
- else
58
- const_name = guard_name.downcase.gsub('-', '')
59
- UI.error "Could not load 'guard/#{ guard_name.downcase }' or '~/.guard/templates/#{ guard_name.downcase }' or find class Guard::#{ const_name.capitalize }"
54
+ if guard_class
55
+ guard_class.init(guard_name)
56
+ elsif File.exist?(File.join(HOME_TEMPLATES, guard_name))
57
+ content = File.read('Guardfile')
58
+ template = File.read(File.join(HOME_TEMPLATES, guard_name))
59
+
60
+ File.open('Guardfile', 'wb') do |f|
61
+ f.puts(content)
62
+ f.puts("")
63
+ f.puts(template)
60
64
  end
65
+
66
+ ::Guard::UI.info "#{ guard_name } template added to Guardfile, feel free to edit it"
67
+ else
68
+ const_name = guard_name.downcase.gsub('-', '')
69
+ UI.error "Could not load 'guard/#{ guard_name.downcase }' or '~/.guard/templates/#{ guard_name.downcase }' or find class Guard::#{ const_name.capitalize }"
61
70
  end
62
71
  end
63
72
 
73
+ # Adds the templates of all installed Guard implementations
74
+ # to an existing Guardfile.
75
+ #
76
+ # @see Guard::CLI.init
77
+ #
78
+ def initialize_all_templates
79
+ guard_gem_names.each {|g| initialize_template(g) }
80
+ end
81
+
64
82
  # Initialize the Guard singleton:
65
83
  #
66
84
  # - Initialize the internal Guard state.
@@ -206,14 +224,14 @@ module Guard
206
224
  # Stop Guard listening to file changes
207
225
  #
208
226
  def stop
209
- UI.info 'Bye bye...', :reset => true
210
-
211
227
  run_on_guards do |guard|
212
228
  run_supervised_task(guard, :stop)
213
229
  end
214
230
 
215
231
  interactor.stop if interactor
216
232
  listener.stop
233
+
234
+ UI.info 'Bye bye...', :reset => true
217
235
  end
218
236
 
219
237
  # Reload all Guards currently enabled.
data/lib/guard/cli.rb CHANGED
@@ -102,18 +102,35 @@ module Guard
102
102
  ::Guard::UI.info "Guard version #{ ::Guard::VERSION }"
103
103
  end
104
104
 
105
- desc 'init [GUARD]', 'Generates a Guardfile at the current working directory, or insert the given GUARD to an existing Guardfile'
105
+ desc 'init [GUARD]', 'Generates a Guardfile at the current directory (if it is not already there) and adds all installed guards or the given GUARD into it'
106
106
 
107
- # Appends the Guard template to the `Guardfile`, or creates an initial
108
- # `Guardfile` when no Guard name is passed.
107
+ method_option :bare,
108
+ :type => :boolean,
109
+ :default => false,
110
+ :aliases => '-b',
111
+ :banner => 'Generate a bare Guardfile without adding any installed guard into it'
112
+
113
+ # Initializes the templates of all installed Guards and adds them
114
+ # to the `Guardfile` when no Guard name is passed. When passed
115
+ # a guard name is does the same but only for that Guard.
109
116
  #
110
- # @see Guard.initialize_template
117
+ # @see Guard::Guard.initialize_template
118
+ # @see Guard::Guard.initialize_all_templates
111
119
  #
112
120
  # @param [String] guard_name the name of the Guard to initialize
113
121
  #
114
122
  def init(guard_name = nil)
115
123
  verify_bundler_presence
116
- ::Guard.initialize_template(guard_name)
124
+
125
+ ::Guard.create_guardfile(:abort_on_existence => options[:bare])
126
+
127
+ return if options[:bare]
128
+
129
+ if guard_name.nil?
130
+ ::Guard::initialize_all_templates
131
+ else
132
+ ::Guard.initialize_template(guard_name)
133
+ end
117
134
  end
118
135
 
119
136
  desc 'show', 'Show all defined Guards and their options'
@@ -135,7 +152,7 @@ module Guard
135
152
  # shows a hint to do so if not.
136
153
  #
137
154
  def verify_bundler_presence
138
- ::Guard::UI.warning "You are using Guard outside of Bundler, this is dangerous and could not work. Using `bundle exec guard` is safer." unless ENV['BUNDLE_GEMFILE']
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']
139
156
  end
140
157
 
141
158
  end
data/lib/guard/dsl.rb CHANGED
@@ -106,20 +106,40 @@ module Guard
106
106
  #
107
107
  def reevaluate_guardfile
108
108
  ::Guard.run do
109
- # Stop each old guards
110
- ::Guard.run_on_guards do |guard|
111
- ::Guard.run_supervised_task(guard, :stop)
112
- end
113
- ::Guard.guards.clear
114
- ::Guard.reset_groups
115
- ::Guard::Notifier.clear_notifications
116
- @@options.delete(:guardfile_contents)
109
+ before_reevaluate_guardfile
117
110
  Dsl.evaluate_guardfile(@@options)
118
- UI.error 'No guards found in Guardfile, please add at least one.' if ::Guard.guards.empty?
111
+ after_reevaluate_guardfile
112
+ end
113
+ end
114
+
115
+ # Stop Guards and clear internal state
116
+ # before the Guardfile will be re-evaluated.
117
+ #
118
+ def before_reevaluate_guardfile
119
+ ::Guard.run_on_guards do |guard|
120
+ ::Guard.run_supervised_task(guard, :stop)
121
+ end
122
+
123
+ ::Guard.guards.clear
124
+ ::Guard.reset_groups
125
+ ::Guard::Notifier.clear_notifications
126
+
127
+ @@options.delete(:guardfile_contents)
128
+ end
129
+
130
+ # Start Guards and notification and show a message
131
+ # after the Guardfile has been re-evaluated.
132
+ #
133
+ def after_reevaluate_guardfile
134
+ ::Guard::Notifier.turn_on if ::Guard::Notifier.enabled?
135
+
136
+ if ::Guard.guards.empty?
137
+ ::Guard::Notifier.notify('No guards found in Guardfile, please add at least one.', :title => 'Guard re-evaluate', :image => :failed)
138
+ else
119
139
  msg = 'Guardfile has been re-evaluated.'
120
- UI.info(msg)
121
- Notifier.notify(msg)
122
- # Start each new guards
140
+ ::Guard::UI.info(msg)
141
+ ::Guard::Notifier.notify(msg, :title => 'Guard re-evaluate')
142
+
123
143
  ::Guard.run_on_guards do |guard|
124
144
  ::Guard.run_supervised_task(guard, :start)
125
145
  end
@@ -134,7 +154,6 @@ module Guard
134
154
  new.instance_eval(contents, @@options[:guardfile_path], 1)
135
155
  rescue
136
156
  UI.error "Invalid Guardfile, original error is:\n#{ $! }"
137
- exit 1
138
157
  end
139
158
 
140
159
  # Test if the current `Guardfile` contains a specific Guard.
@@ -185,8 +204,7 @@ module Guard
185
204
  end
186
205
 
187
206
  unless guardfile_contents_usable?
188
- UI.error "The command file(#{ @@options[:guardfile] }) seems to be empty."
189
- exit 1
207
+ UI.error 'No Guards found in Guardfile, please add at least one.'
190
208
  end
191
209
  end
192
210
 
@@ -32,7 +32,7 @@ module Guard
32
32
  # @option options [String] watchdir the directory to watch
33
33
  # @return [Guard::Listener] the chosen listener
34
34
  #
35
- def self.select_and_init(options = nil)
35
+ def self.select_and_init(options = {})
36
36
  watchdir = options && options[:watchdir] && File.expand_path(options[:watchdir])
37
37
  watchdir = Dir.pwd unless watchdir
38
38
 
@@ -30,7 +30,7 @@ module Guard
30
30
  # @return [Boolean] whether usable or not
31
31
  #
32
32
  def self.usable?(no_vendor = false)
33
- return false unless RbConfig::CONFIG['target_os'] =~ /darwin/i
33
+ return false unless RbConfig::CONFIG['target_os'] =~ /darwin(9|1\d)/i
34
34
 
35
35
  $LOAD_PATH << File.expand_path('../../../vendor/darwin/lib', __FILE__) unless no_vendor
36
36
  require 'rb-fsevent'
@@ -7,6 +7,7 @@ require 'guard/notifiers/gntp'
7
7
  require 'guard/notifiers/growl'
8
8
  require 'guard/notifiers/growl_notify'
9
9
  require 'guard/notifiers/libnotify'
10
+ require 'guard/notifiers/notifysend'
10
11
  require 'guard/notifiers/rb_notifu'
11
12
 
12
13
  module Guard
@@ -47,6 +48,7 @@ module Guard
47
48
  :growl => ::Guard::Notifier::Growl,
48
49
  :growl_notify => ::Guard::Notifier::GrowlNotify,
49
50
  :libnotify => ::Guard::Notifier::Libnotify,
51
+ :notifysend => ::Guard::Notifier::NotifySend,
50
52
  :notifu => ::Guard::Notifier::Notifu
51
53
  }
52
54
 
@@ -151,7 +153,7 @@ module Guard
151
153
  # is available.
152
154
  #
153
155
  def auto_detect_notification
154
- available = [:growl_notify, :gntp, :growl, :libnotify, :notifu].any? { |notifier| add_notification(notifier, { }, true) }
156
+ available = [:growl_notify, :gntp, :growl, :libnotify, :notifysend, :notifu].any? { |notifier| add_notification(notifier, { }, true) }
155
157
  ::Guard::UI.info('Guard could not detect any of the supported notification libraries.') unless available
156
158
  end
157
159