guard 0.4.0.rc → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{README.markdown → README.md} +33 -4
- data/lib/guard.rb +3 -3
- data/lib/guard/dsl.rb +1 -1
- data/lib/guard/listener.rb +0 -5
- data/lib/guard/listeners/darwin.rb +4 -6
- data/lib/guard/listeners/linux.rb +3 -5
- data/lib/guard/notifier.rb +25 -9
- data/lib/guard/version.rb +1 -1
- metadata +5 -5
@@ -3,6 +3,8 @@ Guard [![Build Status](http://travis-ci.org/guard/guard.png)](http://travis-ci.o
|
|
3
3
|
|
4
4
|
Guard is a command line tool that easily handle events on files modifications.
|
5
5
|
|
6
|
+
If you have any questions/issues please join us on our [Google group](http://groups.google.com/group/guard-dev) or on `#guard` (irc.freenode.net).
|
7
|
+
|
6
8
|
Features
|
7
9
|
--------
|
8
10
|
|
@@ -103,7 +105,7 @@ or if you use Bundler, to run the Guard executable specific to your bundle:
|
|
103
105
|
$ bundle exec guard
|
104
106
|
```
|
105
107
|
|
106
|
-
Guard will look for a Guardfile in your current directory. If it does not find one, it will look in your
|
108
|
+
Guard will look for a Guardfile in your current directory. If it does not find one, it will look in your `$HOME` directory for one.
|
107
109
|
|
108
110
|
Command line options
|
109
111
|
--------------------
|
@@ -122,7 +124,7 @@ $ guard --notify false
|
|
122
124
|
$ guard -n f # shortcut
|
123
125
|
```
|
124
126
|
|
125
|
-
Notifications can also be disabled by setting a `GUARD_NOTIFY` environment variable to `false`
|
127
|
+
Notifications can also be disabled globally by setting a `GUARD_NOTIFY` environment variable to `false`
|
126
128
|
|
127
129
|
The guards to start can be specified by group (see the Guardfile DSL below) specifying the `--group` (or `-g`) option:
|
128
130
|
|
@@ -146,6 +148,8 @@ Signal handlers are used to interact with Guard:
|
|
146
148
|
* `Ctrl-\` - Calls each guard's `run_all` method, in the same order they are declared in the Guardfile.
|
147
149
|
* `Ctrl-Z` - Calls each guard's `reload` method, in the same order they are declared in the Guardfile.
|
148
150
|
|
151
|
+
You can read more about [configure the signal keyboard shortcuts](https://github.com/guard/guard/wiki/Configure-keyboard-shortcuts) on the wiki.
|
152
|
+
|
149
153
|
Available Guards
|
150
154
|
----------------
|
151
155
|
|
@@ -212,6 +216,31 @@ group 'frontend' do
|
|
212
216
|
end
|
213
217
|
```
|
214
218
|
|
219
|
+
The Guardfile DSL can also be used in a programmatic fashion by calling directly `Guard::Dsl.evaluate_guardfile`.
|
220
|
+
Available options are as follow:
|
221
|
+
|
222
|
+
* `:guardfile` - The path to a valid Guardfile.
|
223
|
+
* `:guardfile_contents` - A string representing the content of a valid Guardfile
|
224
|
+
|
225
|
+
Without any options given, Guard will look for a Guardfile in your current directory and if it does not find one, it will look in your `$HOME` directory for one.
|
226
|
+
|
227
|
+
For instance, you could use it as follow:
|
228
|
+
|
229
|
+
``` ruby
|
230
|
+
gem 'guard'
|
231
|
+
require 'guard'
|
232
|
+
|
233
|
+
Guard.setup
|
234
|
+
|
235
|
+
Guard::Dsl.evaluate_guardfile(:guardfile => '/Your/Custom/Path/To/A/Valid/Guardfile')
|
236
|
+
# or
|
237
|
+
Guard::Dsl.evaluate_guardfile(:guardfile_contents => "
|
238
|
+
guard 'rspec' do
|
239
|
+
watch(%r{^spec/.+_spec\.rb})
|
240
|
+
end
|
241
|
+
")
|
242
|
+
```
|
243
|
+
|
215
244
|
Create a new guard
|
216
245
|
------------------
|
217
246
|
|
@@ -301,10 +330,10 @@ Development
|
|
301
330
|
-----------
|
302
331
|
|
303
332
|
* Source hosted at [GitHub](https://github.com/guard/guard).
|
304
|
-
* Report Issues/
|
333
|
+
* Report Issues/Feature requests on [GitHub Issues](https://github.com/guard/guard/issues).
|
305
334
|
|
306
335
|
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
|
307
|
-
you make.
|
336
|
+
you make. Please do not change the version in your pull-request.
|
308
337
|
|
309
338
|
Author
|
310
339
|
------
|
data/lib/guard.rb
CHANGED
@@ -81,14 +81,14 @@ module Guard
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def get_guard_class(name)
|
84
|
-
try_to_load_gem
|
85
|
-
self.const_get(self.constants.find{ |klass_name| klass_name.to_s.downcase == name.to_s.downcase.gsub('-', '') })
|
84
|
+
try_to_load_gem(name)
|
85
|
+
self.const_get(self.constants.find { |klass_name| klass_name.to_s.downcase == name.to_s.downcase.gsub('-', '') })
|
86
86
|
rescue TypeError
|
87
87
|
UI.error "Could not find load find gem 'guard-#{name}' or find class Guard::#{name}"
|
88
88
|
end
|
89
89
|
|
90
90
|
def try_to_load_gem(name)
|
91
|
-
require "guard/#{name.downcase}"
|
91
|
+
require "guard/#{name.to_s.downcase}"
|
92
92
|
rescue LoadError
|
93
93
|
end
|
94
94
|
|
data/lib/guard/dsl.rb
CHANGED
@@ -90,7 +90,7 @@ module Guard
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def group(name, &guard_definition)
|
93
|
-
guard_definition.call if guard_definition && (@@options[:group].empty? || @@options[:group].include?(name))
|
93
|
+
guard_definition.call if guard_definition && (@@options[:group].empty? || @@options[:group].include?(name.to_s))
|
94
94
|
end
|
95
95
|
|
96
96
|
def guard(name, options = {}, &watch_definition)
|
data/lib/guard/listener.rb
CHANGED
@@ -47,10 +47,6 @@ module Guard
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def modified_files(dirs, options = {})
|
50
|
-
# <<<<<<< HEAD
|
51
|
-
# files = potentially_modified_files(dirs, options).select { |path| File.file?(path) && file_modified?(path) }
|
52
|
-
# files.map! { |file| file.gsub("#{Dir.pwd}/", '') }
|
53
|
-
# =======
|
54
50
|
files = potentially_modified_files(dirs, options).select { |path| File.file?(path) && file_modified?(path) }
|
55
51
|
relativate_paths files
|
56
52
|
end
|
@@ -66,7 +62,6 @@ module Guard
|
|
66
62
|
|
67
63
|
def all_files
|
68
64
|
potentially_modified_files [directory + '/'], :all => true
|
69
|
-
# >>>>>>> b12769d2bf385b3c69973721144cae3d5d8fbed9
|
70
65
|
end
|
71
66
|
|
72
67
|
# scopes all given paths to the current #directory
|
@@ -23,19 +23,17 @@ module Guard
|
|
23
23
|
|
24
24
|
def self.usable?
|
25
25
|
require 'rb-fsevent'
|
26
|
-
if !defined?(FSEvent::VERSION) || Gem::Version.new(FSEvent::VERSION) < Gem::Version.new('0.
|
27
|
-
UI.info "Please update rb-fsevent (>= 0.
|
28
|
-
false
|
29
|
-
else
|
30
|
-
true
|
26
|
+
if !defined?(FSEvent::VERSION) || Gem::Version.new(FSEvent::VERSION) < Gem::Version.new('0.4.0')
|
27
|
+
UI.info "Please update rb-fsevent (>= 0.4.0)"
|
31
28
|
end
|
29
|
+
true
|
32
30
|
rescue LoadError
|
33
31
|
UI.info "Please install rb-fsevent gem for Mac OSX FSEvents support"
|
34
32
|
false
|
35
33
|
end
|
36
34
|
|
37
35
|
private
|
38
|
-
|
36
|
+
|
39
37
|
def watch(directory)
|
40
38
|
worker.watch directory do |modified_dirs|
|
41
39
|
files = modified_files(modified_dirs)
|
@@ -24,12 +24,10 @@ module Guard
|
|
24
24
|
|
25
25
|
def self.usable?
|
26
26
|
require 'rb-inotify'
|
27
|
-
if !defined?(INotify::VERSION) || Gem::Version.new(INotify::VERSION.join('.')) < Gem::Version.new('0.5
|
28
|
-
UI.info "Please update rb-inotify (>= 0.5
|
29
|
-
false
|
30
|
-
else
|
31
|
-
true
|
27
|
+
if !defined?(INotify::VERSION) || Gem::Version.new(INotify::VERSION.join('.')) < Gem::Version.new('0.8.5')
|
28
|
+
UI.info "Please update rb-inotify (>= 0.8.5)"
|
32
29
|
end
|
30
|
+
true
|
33
31
|
rescue LoadError
|
34
32
|
UI.info "Please install rb-inotify gem for Linux inotify support"
|
35
33
|
false
|
data/lib/guard/notifier.rb
CHANGED
@@ -23,18 +23,16 @@ module Guard
|
|
23
23
|
|
24
24
|
def self.notify(message, options = {})
|
25
25
|
if enabled?
|
26
|
-
image = options
|
27
|
-
title = options
|
26
|
+
image = options.delete(:image) || :success
|
27
|
+
title = options.delete(:title) || "Guard"
|
28
|
+
|
28
29
|
case Config::CONFIG['target_os']
|
29
30
|
when /darwin/i
|
30
|
-
|
31
|
-
Growl.notify message, :title => title, :icon => image_path(image), :name => "Guard"
|
31
|
+
notify_mac(title, message, image, options)
|
32
32
|
when /linux/i
|
33
|
-
|
34
|
-
Libnotify.show :body => message, :summary => title, :icon_path => image_path(image)
|
33
|
+
notify_linux(title, message, image, options)
|
35
34
|
when /mswin|mingw/i
|
36
|
-
|
37
|
-
Notifu.show :message => message, :title => title, :type => image_level(image), :time => 3
|
35
|
+
notify_windows(title, message, image, options)
|
38
36
|
end
|
39
37
|
end
|
40
38
|
end
|
@@ -45,6 +43,24 @@ module Guard
|
|
45
43
|
|
46
44
|
private
|
47
45
|
|
46
|
+
def self.notify_mac(title, message, image, options)
|
47
|
+
require_growl # need for guard-rspec formatter that is called out of guard scope
|
48
|
+
default_options = { :title => title, :icon => image_path(image), :name => "Guard" }
|
49
|
+
Growl.notify message, default_options.merge(options)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.notify_linux(title, message, image, options)
|
53
|
+
require_libnotify # need for guard-rspec formatter that is called out of guard scope
|
54
|
+
default_options = { :body => message, :summary => title, :icon_path => image_path(image) }
|
55
|
+
Libnotify.show default_options.merge(options)
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.notify_windows(title, message, image, options)
|
59
|
+
require_rbnotifu # need for guard-rspec formatter that is called out of guard scope
|
60
|
+
default_options = { :message => message, :title => title, :type => image_level(image), :time => 3 }
|
61
|
+
Notifu.show default_options.merge(options)
|
62
|
+
end
|
63
|
+
|
48
64
|
def self.image_path(image)
|
49
65
|
images_path = Pathname.new(File.dirname(__FILE__)).join('../../images')
|
50
66
|
case image
|
@@ -72,7 +88,7 @@ module Guard
|
|
72
88
|
:info
|
73
89
|
end
|
74
90
|
end
|
75
|
-
|
91
|
+
|
76
92
|
def self.require_growl
|
77
93
|
require 'growl'
|
78
94
|
rescue LoadError
|
data/lib/guard/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.4.0
|
4
|
+
prerelease:
|
5
|
+
version: 0.4.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Thibaud Guillaume-Gentil
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05
|
13
|
+
date: 2011-06-05 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -86,7 +86,7 @@ files:
|
|
86
86
|
- lib/guard/watcher.rb
|
87
87
|
- lib/guard.rb
|
88
88
|
- LICENSE
|
89
|
-
- README.
|
89
|
+
- README.md
|
90
90
|
homepage: http://rubygems.org/gems/guard
|
91
91
|
licenses: []
|
92
92
|
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
requirements: []
|
111
111
|
|
112
112
|
rubyforge_project: guard
|
113
|
-
rubygems_version: 1.8.
|
113
|
+
rubygems_version: 1.8.1
|
114
114
|
signing_key:
|
115
115
|
specification_version: 3
|
116
116
|
summary: Guard keep an eye on your files modifications.
|