guard 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown ADDED
@@ -0,0 +1,269 @@
1
+ Guard
2
+ =====
3
+
4
+ Guard is a command line tool that easily handle events on files modifications.
5
+
6
+ Features
7
+ --------
8
+
9
+ * [FSEvent](http://en.wikipedia.org/wiki/FSEvents) support on Mac OS X 10.5+ (without RubyCocoa!, [rb-fsevent gem, >= 0.3.5](https://rubygems.org/gems/rb-fsevent) required).
10
+ * [Inotify](http://en.wikipedia.org/wiki/Inotify) support on Linux ([rb-inotify gem, >= 0.5.1](https://rubygems.org/gems/rb-inotify) required).
11
+ * Polling on the other operating systems (help us to support more OS).
12
+ * Automatic & Super fast (when polling is not used) files modifications detection (even new files are detected).
13
+ * Growl notifications ([growlnotify](http://growl.info/documentation/growlnotify.php) & [growl gem](https://rubygems.org/gems/growl) required).
14
+ * Libnotify notifications ([libnotify gem](https://rubygems.org/gems/libnotify) required).
15
+ * Tested on Ruby 1.8.6, 1.8.7 & 1.9.2.
16
+
17
+ Install
18
+ -------
19
+
20
+ Install the gem:
21
+
22
+ $ gem install guard
23
+
24
+ Add it to your Gemfile (inside the <tt>test</tt> group):
25
+
26
+ ``` ruby
27
+ gem 'guard'
28
+ ```
29
+
30
+ Generate an empty Guardfile with:
31
+
32
+ $ guard init
33
+
34
+ Add the guards you need to your Guardfile (see the existing guards below).
35
+
36
+ ### On Mac OS X
37
+
38
+ Install the rb-fsevent gem for [FSEvent](http://en.wikipedia.org/wiki/FSEvents) support:
39
+
40
+ $ gem install rb-fsevent
41
+
42
+ Install the Growl gem if you want notification support:
43
+
44
+ $ gem install growl
45
+
46
+ And add it to you Gemfile:
47
+
48
+ ``` ruby
49
+ gem 'growl'
50
+ ```
51
+
52
+ ### On Linux
53
+
54
+ Install the rb-inotify gem for [inotify](http://en.wikipedia.org/wiki/Inotify) support:
55
+
56
+ $ gem install rb-inotify
57
+
58
+ Install the Libnotify gem if you want notification support:
59
+
60
+ $ gem install libnotify
61
+
62
+ And add it to you Gemfile:
63
+
64
+ ``` ruby
65
+ gem 'libnotify'
66
+ ```
67
+
68
+ Usage
69
+ -----
70
+
71
+ Just launch Guard inside your Ruby / Rails project with:
72
+
73
+ $ guard [start]
74
+
75
+ or if you use Bundler, to run the Guard executable specific to your bundle:
76
+
77
+ $ bundle exec guard
78
+
79
+ Command line options
80
+ --------------------
81
+
82
+ Shell can be cleared after each change with:
83
+
84
+ $ guard --clear
85
+ $ guard -c # shortcut
86
+
87
+ Notifications (growl/libnotify) can be disabled with:
88
+
89
+ $ guard --notify false
90
+ $ guard -n false # shortcut
91
+
92
+ The guards to start can be specified by group (see the Guardfile DSL below) specifying the <tt>--group</tt> (or <tt>-g</tt>) option:
93
+
94
+ $ guard --group group_name another_group_name
95
+ $ guard -g group_name another_group_name # shortcut
96
+
97
+ Options list is available with:
98
+
99
+ $ guard help [TASK]
100
+
101
+ Signal handlers
102
+ ---------------
103
+
104
+ Signal handlers are used to interact with Guard:
105
+
106
+ * <tt>Ctrl-C</tt> - Calls each guard's <tt>stop</tt> method, in the same order they are declared in the Guardfile, and then quits Guard itself.
107
+ * <tt>Ctrl-\\</tt> - Calls each guard's <tt>run_all</tt> method, in the same order they are declared in the Guardfile.
108
+ * <tt>Ctrl-Z</tt> - Calls each guard's <tt>reload</tt> method, in the same order they are declared in the Guardfile.
109
+
110
+ Available Guards
111
+ ----------------
112
+
113
+ [Available Guards list](https://github.com/guard/guard/wiki/List-of-available-Guards) (on the wiki now)
114
+
115
+ ### Add a guard to your Guardfile
116
+
117
+ Add it to your Gemfile (inside the <tt>test</tt> group):
118
+
119
+ ``` ruby
120
+ gem '<guard-name>'
121
+ ```
122
+
123
+ Insert default guard's definition to your Guardfile by running this command:
124
+
125
+ $ guard init <guard-name>
126
+
127
+ You are good to go!
128
+
129
+ Guardfile DSL
130
+ -------------
131
+
132
+ The Guardfile DSL consists of just three simple methods: <tt>guard</tt>, <tt>watch</tt> & <tt>group</tt>.
133
+
134
+ Required:
135
+ * The <tt>guard</tt> method allows you to add a guard with an optional hash of options.
136
+ * The <tt>watch</tt> method allows you to define which files are supervised by this guard. An optional block can be added to overwrite the paths sent to the <tt>run_on_change</tt> guard method or to launch any arbitrary command.
137
+
138
+ Optional:
139
+ * The <tt>group</tt> method allows you to group several guards together. Groups to be run can be specified with the Guard DSL option <tt>--group</tt> (or <tt>-g</tt>). This comes in handy especially when you have a huge Guardfile and want to focus your development on a certain part.
140
+
141
+ Example:
142
+
143
+ ``` ruby
144
+ group 'backend' do
145
+ guard 'bundler' do
146
+ watch('Gemfile')
147
+ end
148
+
149
+ guard 'rspec', :cli => '--color --format doc' do
150
+ # Regexp watch patterns are matched with Regexp#match
151
+ watch(%r{^spec/.+_spec\.rb})
152
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
153
+ watch(%r{^spec/models/.+\.rb}) { ["spec/models", "spec/acceptance"] }
154
+ watch(%r{^spec/.+\.rb}) { `say hello` }
155
+
156
+ # String watch patterns are matched with simple '=='
157
+ watch('spec/spec_helper.rb') { "spec" }
158
+ end
159
+ end
160
+
161
+ group 'frontend' do
162
+ guard 'coffeescript', :output => 'public/javascripts/compiled' do
163
+ watch(%r{^app/coffeescripts/.+\.coffee})
164
+ end
165
+
166
+ guard 'livereload' do
167
+ watch(%r{^app/.+\.(erb|haml)})
168
+ end
169
+ end
170
+ ```
171
+
172
+ Create a new guard
173
+ ------------------
174
+
175
+ Creating a new guard is very easy, just create a new gem (<tt>bundle gem</tt> if you use Bundler) with this basic structure:
176
+
177
+ lib/
178
+ guard/
179
+ guard-name/
180
+ templates/
181
+ Guardfile (needed for guard init <guard-name>)
182
+ guard-name.rb
183
+
184
+ <tt>Guard::GuardName</tt> (in <tt>lib/guard/guard-name.rb</tt>) must inherit from <tt>Guard::Guard</tt> and should overwrite at least one of the five basic <tt>Guard::Guard</tt> instance methods. Example:
185
+
186
+ ``` ruby
187
+ require 'guard'
188
+ require 'guard/guard'
189
+
190
+ module Guard
191
+ class GuardName < Guard
192
+
193
+ def initialize(watchers=[], options={})
194
+ super
195
+ # init stuff here, thx!
196
+ end
197
+
198
+ # =================
199
+ # = Guard methods =
200
+ # =================
201
+
202
+ # If one of those methods raise an exception, the Guard::GuardName instance
203
+ # will be removed from the active guards.
204
+
205
+ # Called once when Guard starts
206
+ # Please override initialize method to init stuff
207
+ def start
208
+ true
209
+ end
210
+
211
+ # Called on Ctrl-C signal (when Guard quits)
212
+ def stop
213
+ true
214
+ end
215
+
216
+ # Called on Ctrl-Z signal
217
+ # This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
218
+ def reload
219
+ true
220
+ end
221
+
222
+ # Called on Ctrl-/ signal
223
+ # This method should be principally used for long action like running all specs/tests/...
224
+ def run_all
225
+ true
226
+ end
227
+
228
+ # Called on file(s) modifications
229
+ def run_on_change(paths)
230
+ true
231
+ end
232
+
233
+ end
234
+ end
235
+ ```
236
+
237
+ Please take a look at the existing guards' source code (see the list above) for more concrete example.
238
+
239
+ Alternatively, a new guard can be added inline to a Guardfile with this basic structure:
240
+
241
+ ``` ruby
242
+ require 'guard/guard'
243
+
244
+ module ::Guard
245
+ class Example < ::Guard::Guard
246
+ def run_all
247
+ true
248
+ end
249
+
250
+ def run_on_change(paths)
251
+ true
252
+ end
253
+ end
254
+ end
255
+ ```
256
+
257
+ Development
258
+ -----------
259
+
260
+ * Source hosted at [GitHub](https://github.com/guard/guard).
261
+ * Report Issues/Questions/Feature requests on [GitHub Issues](https://github.com/guard/guard/issues).
262
+
263
+ Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
264
+ you make.
265
+
266
+ Author
267
+ ------
268
+
269
+ [Thibaud Guillaume-Gentil](https://github.com/thibaudgg)
data/lib/guard.rb CHANGED
@@ -83,10 +83,15 @@ module Guard
83
83
  end
84
84
 
85
85
  def get_guard_class(name)
86
- require "guard/#{name.downcase}"
86
+ try_to_load_gem name
87
87
  self.const_get(self.constants.find{|klass_name| klass_name.to_s.downcase == name.downcase })
88
+ rescue TypeError
89
+ UI.error "Could not find load find gem 'guard-#{name}' or find class Guard::#{name}"
90
+ end
91
+
92
+ def try_to_load_gem(name)
93
+ require "guard/#{name.downcase}"
88
94
  rescue LoadError
89
- UI.error "Could not find gem 'guard-#{name}', please add it in your Gemfile."
90
95
  end
91
96
 
92
97
  def locate_guard(name)
data/lib/guard/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Guard
2
- VERSION = "0.3.3"
3
- end
2
+ VERSION = "0.3.4"
3
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: guard
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.3
5
+ version: 0.3.4
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-04-19 00:00:00 +02:00
13
+ date: 2011-04-25 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -86,7 +86,7 @@ files:
86
86
  - lib/guard/watcher.rb
87
87
  - lib/guard.rb
88
88
  - LICENSE
89
- - README.rdoc
89
+ - README.markdown
90
90
  has_rdoc: true
91
91
  homepage: http://rubygems.org/gems/guard
92
92
  licenses: []
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  requirements: []
112
112
 
113
113
  rubyforge_project: guard
114
- rubygems_version: 1.5.3
114
+ rubygems_version: 1.6.2
115
115
  signing_key:
116
116
  specification_version: 3
117
117
  summary: Guard keep an eye on your files modifications.
data/README.rdoc DELETED
@@ -1,228 +0,0 @@
1
- = Guard
2
-
3
- Guard is a command line tool that easily handle events on files modifications.
4
-
5
- == Features
6
-
7
- - {FSEvent}[http://en.wikipedia.org/wiki/FSEvents] support on Mac OS X 10.5+ (without RubyCocoa!, {rb-fsevent gem, >= 0.3.5}[https://rubygems.org/gems/rb-fsevent] required).
8
- - {Inotify}[http://en.wikipedia.org/wiki/Inotify] support on Linux ({rb-inotify gem, >= 0.5.1}[https://rubygems.org/gems/rb-inotify] required).
9
- - Polling on the other operating systems (help us to support more OS).
10
- - Automatic & Super fast (when polling is not used) files modifications detection (even new files are detected).
11
- - Growl notifications ({growlnotify}[http://growl.info/documentation/growlnotify.php] & {growl gem}[https://rubygems.org/gems/growl] required).
12
- - Libnotify notifications ({libnotify gem}[https://rubygems.org/gems/libnotify] required).
13
- - Tested on Ruby 1.8.6, 1.8.7 & 1.9.2.
14
-
15
- == Install
16
-
17
- Install the gem:
18
-
19
- $ gem install guard
20
-
21
- Add it to your Gemfile (inside the <tt>test</tt> group):
22
-
23
- gem 'guard'
24
-
25
- Generate an empty Guardfile with:
26
-
27
- $ guard init
28
-
29
- Add the guards you need to your Guardfile (see the existing guards below).
30
-
31
- === On Mac OS X
32
-
33
- Install the rb-fsevent gem for {FSEvent}[http://en.wikipedia.org/wiki/FSEvents] support:
34
-
35
- $ gem install rb-fsevent
36
-
37
- Install the Growl gem if you want notification support:
38
-
39
- $ gem install growl
40
-
41
- And add it to you Gemfile:
42
-
43
- gem 'growl'
44
-
45
- === On Linux
46
-
47
- Install the rb-inotify gem for {inotify}[http://en.wikipedia.org/wiki/Inotify] support:
48
-
49
- $ gem install rb-inotify
50
-
51
- Install the Libnotify gem if you want notification support:
52
-
53
- $ gem install libnotify
54
-
55
- And add it to you Gemfile:
56
-
57
- gem 'libnotify'
58
-
59
- == Usage
60
-
61
- Just launch Guard inside your Ruby / Rails project with:
62
-
63
- $ guard [start]
64
-
65
- or if you use Bundler, to run the Guard executable specific to your bundle:
66
-
67
- $ bundle exec guard
68
-
69
- == Command line options
70
-
71
- Shell can be cleared after each change with:
72
-
73
- $ guard --clear
74
- $ guard -c # shortcut
75
-
76
- Notifications (growl/libnotify) can be disabled with:
77
-
78
- $ guard --notify false
79
- $ guard -n false # shortcut
80
-
81
- The guards to start can be specified by group (see the Guardfile DSL below) specifying the <tt>--group</tt> (or <tt>-g</tt>) option:
82
-
83
- $ guard --group group_name another_group_name
84
- $ guard -g group_name another_group_name # shortcut
85
-
86
- Options list is available with:
87
-
88
- $ guard help [TASK]
89
-
90
- == Signal handlers
91
-
92
- Signal handlers are used to interact with Guard:
93
-
94
- - <tt>Ctrl-C</tt> - Calls each guard's <tt>stop</tt> method, in the same order they are declared in the Guardfile, and then quits Guard itself.
95
- - <tt>Ctrl-\\</tt> - Calls each guard's <tt>run_all</tt> method, in the same order they are declared in the Guardfile.
96
- - <tt>Ctrl-Z</tt> - Calls each guard's <tt>reload</tt> method, in the same order they are declared in the Guardfile.
97
-
98
- == Available Guards
99
-
100
- {Available Guards list}[https://github.com/guard/guard/wiki/List-of-available-Guards] (on the wiki now)
101
-
102
- === Add a guard to your Guardfile
103
-
104
- Add it to your Gemfile (inside the <tt>test</tt> group):
105
-
106
- gem '<guard-name>'
107
-
108
- Insert default guard's definition to your Guardfile by running this command:
109
-
110
- $ guard init <guard-name>
111
-
112
- You are good to go!
113
-
114
- == Guardfile DSL
115
-
116
- The Guardfile DSL consists of just three simple methods: <tt>guard</tt>, <tt>watch</tt> & <tt>group</tt>.
117
-
118
- Required:
119
- - The <tt>guard</tt> method allows you to add a guard with an optional hash of options.
120
- - The <tt>watch</tt> method allows you to define which files are supervised by this guard. An optional block can be added to overwrite the paths sent to the <tt>run_on_change</tt> guard method or to launch any arbitrary command.
121
-
122
- Optional:
123
- - The <tt>group</tt> method allows you to group several guards together. Groups to be run can be specified with the Guard DSL option <tt>--group</tt> (or <tt>-g</tt>). This comes in handy especially when you have a huge Guardfile and want to focus your development on a certain part.
124
-
125
- Example:
126
-
127
- group 'backend' do
128
- guard 'bundler' do
129
- watch('Gemfile')
130
- end
131
-
132
- guard 'rspec', :cli => '--color --format doc' do
133
- # Regexp watch patterns are matched with Regexp#match
134
- watch(%r{^spec/.+_spec\.rb})
135
- watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
136
- watch(%r{^spec/models/.+\.rb}) { ["spec/models", "spec/acceptance"] }
137
- watch(%r{^spec/.+\.rb}) { `say hello` }
138
-
139
- # String watch patterns are matched with simple '=='
140
- watch('spec/spec_helper.rb') { "spec" }
141
- end
142
- end
143
-
144
- group 'frontend' do
145
- guard 'coffeescript', :output => 'public/javascripts/compiled' do
146
- watch(%r{^app/coffeescripts/.+\.coffee})
147
- end
148
-
149
- guard 'livereload' do
150
- watch(%r{^app/.+\.(erb|haml)})
151
- end
152
- end
153
-
154
- == Create a new guard
155
-
156
- Creating a new guard is very easy, just create a new gem (<tt>bundle gem</tt> if you use Bundler) with this basic structure:
157
-
158
- lib/
159
- guard/
160
- guard-name/
161
- templates/
162
- Guardfile (needed for guard init <guard-name>)
163
- guard-name.rb
164
-
165
- <tt>Guard::GuardName</tt> (in <tt>lib/guard/guard-name.rb</tt>) must inherit from <tt>Guard::Guard</tt> and should overwrite at least one of the five basic <tt>Guard::Guard</tt> instance methods. Example:
166
-
167
- require 'guard'
168
- require 'guard/guard'
169
-
170
- module Guard
171
- class GuardName < Guard
172
-
173
- def initialize(watchers=[], options={})
174
- super
175
- # init stuff here, thx!
176
- end
177
-
178
- # =================
179
- # = Guard methods =
180
- # =================
181
-
182
- # If one of those methods raise an exception, the Guard::GuardName instance
183
- # will be removed from the active guards.
184
-
185
- # Called once when Guard starts
186
- # Please override initialize method to init stuff
187
- def start
188
- true
189
- end
190
-
191
- # Called on Ctrl-C signal (when Guard quits)
192
- def stop
193
- true
194
- end
195
-
196
- # Called on Ctrl-Z signal
197
- # This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
198
- def reload
199
- true
200
- end
201
-
202
- # Called on Ctrl-/ signal
203
- # This method should be principally used for long action like running all specs/tests/...
204
- def run_all
205
- true
206
- end
207
-
208
- # Called on file(s) modifications
209
- def run_on_change(paths)
210
- true
211
- end
212
-
213
- end
214
- end
215
-
216
- Please take a look at the existing guards' source code (see the list above) for more concrete example.
217
-
218
- == Development
219
-
220
- - Source hosted at {GitHub}[https://github.com/guard/guard].
221
- - Report Issues/Questions/Feature requests on {GitHub Issues}[https://github.com/guard/guard/issues].
222
-
223
- Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
224
- you make.
225
-
226
- == Authors
227
-
228
- {Thibaud Guillaume-Gentil}[https://github.com/thibaudgg]