guard 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,17 @@
1
+ ## 0.9.2 - December 22, 2011
2
+
3
+ ### Improvements
4
+
5
+ - Add `interactor` to DSL to allow switching Guard interaction implementation. ([@netzpirat][])
6
+ - Add quit action to the interactor. ([@Maher4Ever][])
7
+
8
+ ## 0.9.1 - December 19, 2011
9
+
10
+ ### Bug fix
11
+
12
+ - Fix wrong `--no-vendor` option. ([@netzpirat][])
13
+ - [#195](https://github.com/guard/guard/issues/195): Empty watch directory prohibit Guard from running. (reported by [@madtrick][], fixed by [@netzpirat][]
14
+
1
15
  ## 0.9.0 - December 19, 2011
2
16
 
3
17
  ### Bug fix
@@ -356,6 +370,8 @@
356
370
  [@jrsacks]: https://github.com/jrsacks
357
371
  [@koshigoe]: https://github.com/koshigoe
358
372
  [@limeyd]: https://github.com/limeyd
373
+ [@madtrick]: https://github.com/madtrick
374
+ [@Maher4Ever]: https://github.com/Maher4Ever
359
375
  [@mcmire]: https://github.com/mcmire
360
376
  [@mislav]: https://github.com/mislav
361
377
  [@monocle]: https://github.com/monocle
data/README.md CHANGED
@@ -34,10 +34,6 @@ Add Guard to your `Gemfile`:
34
34
  ```ruby
35
35
  group :development do
36
36
  gem 'guard'
37
-
38
- platforms :ruby do
39
- gem 'rb-readline'
40
- end
41
37
  end
42
38
  ```
43
39
 
@@ -361,11 +357,7 @@ read more about these files in the shared configuration section below.
361
357
  Interactions
362
358
  ------------
363
359
 
364
- You can interact with Guard and enter commands when Guard has nothing to do. You'll see a command prompt `>` when Guard
365
- is ready to accept a command. The command line supports history navigation with the `↑` and `↓` arrow keys, and
366
- command auto-completion with the `⇥` key.
367
-
368
- You can execute the following commands:
360
+ You can interact with Guard and enter commands when Guard has nothing to do. Guard understands the following commands:
369
361
 
370
362
  * `↩`: Run all Guards.
371
363
  * `h`, `help`: Show a help of the available interactor commands.
@@ -399,6 +391,23 @@ This will reload only the Ronn Guard. You can also reload all Guards within a gr
399
391
  > backend reload
400
392
  ```
401
393
 
394
+ ### Readline support
395
+
396
+ With Readline enabled, you'll see a command prompt `>` when Guard is ready to accept a command. The command line
397
+ supports history navigation with the `↑` and `↓` arrow keys, and command auto-completion with the `⇥` key.
398
+
399
+ Unfortunately Readline [does not work on MRI](http://bugs.ruby-lang.org/issues/5539) on Mac OS X by default. You can
400
+ work around the issue by installing a pure Ruby implementation:
401
+
402
+ ```ruby
403
+ platforms :ruby do
404
+ gem 'rb-readline'
405
+ end
406
+ ```
407
+
408
+ Guard will automatically enable Readline support if your environment supports it, but you can disable Readline with the
409
+ `interactor` DSL method or turn off completely with the `--no-interactions` option.
410
+
402
411
  Guardfile DSL
403
412
  -------------
404
413
 
@@ -529,6 +538,26 @@ or using the cli switch `-n`:
529
538
  notification :off
530
539
  ```
531
540
 
541
+ ### interactor
542
+
543
+ You can disable the interactor auto detection and for a specific implementation:
544
+
545
+ ```ruby
546
+ interactor :readline
547
+ ```
548
+
549
+ will select Readline interactor. You can also force the simple interactor without Readline support with:
550
+
551
+ ```ruby
552
+ interactor :simple
553
+ ```
554
+
555
+ If you do not need the keyboard interactions with Guard at all, you can turn them off:
556
+
557
+ ```ruby
558
+ interactor :off
559
+ ```
560
+
532
561
  ### callback
533
562
 
534
563
  The `callback` method allows you to execute arbitrary code before or after any of the `start`, `stop`, `reload`,
@@ -62,7 +62,6 @@ module Guard
62
62
  @options = options
63
63
  @guards = []
64
64
  self.reset_groups
65
- @interactor = Interactor.new unless options[:no_interactions]
66
65
  @listener = Listener.select_and_init(options)
67
66
 
68
67
  UI.clear if @options[:clear]
@@ -177,7 +176,11 @@ module Guard
177
176
  run_supervised_task(guard, :start)
178
177
  end
179
178
 
180
- interactor.start if interactor
179
+ unless options[:no_interactions]
180
+ @interactor = Interactor.fabricate
181
+ @interactor.start if @interactor
182
+ end
183
+
181
184
  listener.start
182
185
  end
183
186
 
@@ -276,6 +276,21 @@ module Guard
276
276
  ::Guard::Notifier.add_notification(notifier.to_sym, options, false)
277
277
  end
278
278
 
279
+ # Sets the interactor to use.
280
+ #
281
+ # @example Use the readline interactor
282
+ # interactor :readline
283
+ #
284
+ # @example Use the gets interactor
285
+ # interactor :gets
286
+ #
287
+ # @example Turn off interactions
288
+ # interactor :off
289
+ #
290
+ def interactor(interactor)
291
+ ::Guard::Interactor.interactor = interactor.to_sym
292
+ end
293
+
279
294
  # Declares a group of guards to be run with `guard start --group group_name`.
280
295
  #
281
296
  # @example Declare two groups of Guards
@@ -1,21 +1,20 @@
1
- require 'readline'
2
-
3
1
  module Guard
4
2
 
5
- # The interactor reads user input and triggers
6
- # specific action upon them unless its locked.
7
- #
8
- # It used the readline library for history and
9
- # completion support.
3
+ autoload :ReadlineInteractor, 'guard/interactors/readline'
4
+ autoload :SimpleInteractor, 'guard/interactors/simple'
5
+
6
+ # The interactor triggers specific action from input
7
+ # read by a interactor implementation.
10
8
  #
11
9
  # Currently the following actions are implemented:
12
10
  #
13
- # - h, help => Show help
14
- # - e, exit => Exit Guard
15
- # - r, reload => Reload Guard
16
- # - p, pause => Toggle file modification listener
17
- # - n, notification => Toggle notifications
18
- # - <enter> => Run all
11
+ # - h, help => Show help
12
+ # - e, exit,
13
+ # q. quit => Exit Guard
14
+ # - r, reload => Reload Guard
15
+ # - p, pause => Toggle file modification listener
16
+ # - n, notification => Toggle notifications
17
+ # - <enter> => Run all
19
18
  #
20
19
  # It's also possible to scope `reload` and `run all` actions to only a specified group or a guard.
21
20
  #
@@ -28,29 +27,62 @@ module Guard
28
27
  # @example Run all jasmine specs
29
28
  # jasmine
30
29
  #
30
+ # @abstract
31
+ #
31
32
  class Interactor
32
33
 
33
34
  HELP_ENTRIES = %w[help h]
34
35
  RELOAD_ENTRIES = %w[reload r]
35
- STOP_ENTRIES = %w[exit e]
36
+ STOP_ENTRIES = %w[exit e quit q]
36
37
  PAUSE_ENTRIES = %w[pause p]
37
38
  NOTIFICATION_ENTRIES = %w[notification n]
38
39
 
39
- COMPLETION_ACTIONS = %w[help reload exit pause notification]
40
+ # Set the interactor implementation
41
+ #
42
+ # @param [Symbol] interactor the name of the interactor
43
+ #
44
+ def self.interactor=(interactor)
45
+ @interactor = interactor
46
+ end
40
47
 
41
- # Initialize the interactor.
48
+ # Get an instance of the currently configured
49
+ # interactor implementation.
42
50
  #
43
- def initialize
44
- unless defined?(RbReadline) || defined?(JRUBY_VERSION)
45
- ::Guard::UI.info 'Please add rb-readline for proper Readline support.'
51
+ # @return [Interactor] an interactor implementation
52
+ #
53
+ def self.fabricate
54
+ case @interactor
55
+ when :readline
56
+ ReadlineInteractor.new
57
+ when :simple
58
+ SimpleInteractor.new
59
+ when :off
60
+ nil
61
+ else
62
+ auto_detect
46
63
  end
47
-
48
- Readline.completion_proc = proc { |word| auto_complete(word) }
64
+ end
65
+
66
+ # Tries to detect an optimal interactor for the
67
+ # current environment.
68
+ #
69
+ # It returns the Readline implementation when:
70
+ #
71
+ # * rb-readline is installed
72
+ # * The Ruby implementation is JRuby
73
+ # * The current OS is not Mac OS X
74
+ #
75
+ # Otherwise the plain gets interactor is returned.
76
+ #
77
+ # @return [Interactor] an interactor implementation
78
+ #
79
+ def self.auto_detect
80
+ require 'readline'
49
81
 
50
- begin
51
- Readline.completion_append_character = ' '
52
- rescue NotImplementedError
53
- # Ignore, we just don't support it then
82
+ if defined?(RbReadline) || defined?(JRUBY_VERSION) || !RbConfig::CONFIG['target_os'] =~ /darwin/i
83
+ ReadlineInteractor.new
84
+ else
85
+ SimpleInteractor.new
54
86
  end
55
87
  end
56
88
 
@@ -69,40 +101,13 @@ module Guard
69
101
  end
70
102
  end
71
103
 
72
- # Read a line from stdin with Readline.
104
+ # Read the user input. This method must be implemented
105
+ # by each interactor implementation.
73
106
  #
74
- def read_line
75
- while line = Readline.readline(prompt, true)
76
- process_input(line)
77
- end
78
- end
79
-
80
- # Auto complete the given word.
81
- #
82
- # @param [String] word the partial word
83
- # @return [Array<String>] the matching words
84
- #
85
- def auto_complete(word)
86
- completion_list.grep(/^#{ Regexp.escape(word) }/)
87
- end
88
-
89
- # Get the auto completion list.
90
- #
91
- # @return [Array<String>] the list of words
107
+ # @abstract
92
108
  #
93
- def completion_list
94
- groups = ::Guard.groups.map { |group| group.name.to_s }
95
- guards = ::Guard.guards.map { |guard| guard.class.to_s.downcase.sub('guard::', '') }
96
-
97
- COMPLETION_ACTIONS + groups + guards - ['default']
98
- end
99
-
100
- # The current interactor prompt
101
- #
102
- # @return [String] the prompt to show
103
- #
104
- def prompt
105
- ::Guard.listener.paused? ? 'p> ' : '> '
109
+ def read_line
110
+ raise NotImplementedError
106
111
  end
107
112
 
108
113
  # Process the input from readline.
@@ -110,10 +115,6 @@ module Guard
110
115
  # @param [String] line the input line
111
116
  #
112
117
  def process_input(line)
113
- if line =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == line
114
- Readline::HISTORY.pop
115
- end
116
-
117
118
  scopes, action = extract_scopes_and_action(line)
118
119
 
119
120
  case action
@@ -159,10 +160,10 @@ module Guard
159
160
  #
160
161
  def help
161
162
  puts ''
162
- puts 'e, exit Exit Guard'
163
- puts 'p, pause Toggle file modification listener'
164
- puts 'r, reload Reload Guard'
165
- puts 'n, notification Toggle notifications'
163
+ puts '[e]xit, [q]uit Exit Guard'
164
+ puts '[p]ause Toggle file modification listener'
165
+ puts '[r]eload Reload Guard'
166
+ puts '[n]otification Toggle notifications'
166
167
  puts '<enter> Run all Guards'
167
168
  puts ''
168
169
  puts 'You can scope the reload action to a specific guard or group:'
@@ -0,0 +1,72 @@
1
+ module Guard
2
+
3
+ # Interactor that used readline for getting the user input.
4
+ # This enables history support and auto-completion, but is
5
+ # broken on OS X without installing `rb-readline` or using JRuby.
6
+ #
7
+ # @see http://bugs.ruby-lang.org/issues/5539
8
+ #
9
+ class ReadlineInteractor < Interactor
10
+
11
+ COMPLETION_ACTIONS = %w[help reload exit pause notification]
12
+
13
+ # Initialize the interactor.
14
+ #
15
+ def initialize
16
+ require 'readline'
17
+
18
+ unless defined?(RbReadline) || defined?(JRUBY_VERSION)
19
+ ::Guard::UI.info 'Please add rb-readline for proper Readline support.'
20
+ end
21
+
22
+ Readline.completion_proc = proc { |word| auto_complete(word) }
23
+
24
+ begin
25
+ Readline.completion_append_character = ' '
26
+ rescue NotImplementedError
27
+ # Ignore, we just don't support it then
28
+ end
29
+ end
30
+
31
+ # Read a line from stdin with Readline.
32
+ #
33
+ def read_line
34
+ while line = Readline.readline(prompt, true)
35
+ if line =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == line
36
+ Readline::HISTORY.pop
37
+ end
38
+
39
+ process_input(line)
40
+ end
41
+ end
42
+
43
+ # Auto complete the given word.
44
+ #
45
+ # @param [String] word the partial word
46
+ # @return [Array<String>] the matching words
47
+ #
48
+ def auto_complete(word)
49
+ completion_list.grep(/^#{ Regexp.escape(word) }/)
50
+ end
51
+
52
+ # Get the auto completion list.
53
+ #
54
+ # @return [Array<String>] the list of words
55
+ #
56
+ def completion_list
57
+ groups = ::Guard.groups.map { |group| group.name.to_s }
58
+ guards = ::Guard.guards.map { |guard| guard.class.to_s.downcase.sub('guard::', '') }
59
+
60
+ COMPLETION_ACTIONS + groups + guards - ['default']
61
+ end
62
+
63
+ # The current interactor prompt
64
+ #
65
+ # @return [String] the prompt to show
66
+ #
67
+ def prompt
68
+ ::Guard.listener.paused? ? 'p> ' : '> '
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,17 @@
1
+ module Guard
2
+
3
+ # Simple interactor that that reads user
4
+ # input from standard input.
5
+ #
6
+ class SimpleInteractor < Interactor
7
+
8
+ # Read a line from stdin with Readline.
9
+ #
10
+ def read_line
11
+ while line = $stdin.gets
12
+ process_input(line.chomp)
13
+ end
14
+ end
15
+
16
+ end
17
+ end
@@ -1,6 +1,6 @@
1
1
  module Guard
2
2
  unless defined? Guard::VERSION
3
3
  # The current gem version of Guard
4
- VERSION = '0.9.1'
4
+ VERSION = '0.9.2'
5
5
  end
6
6
  end
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "GUARD" "1" "October 2011" "" ""
4
+ .TH "GUARD" "1" "December 2011" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBguard\fR \- Guard keeps an eye on your file modifications\.
@@ -27,7 +27,7 @@ The following options are available:
27
27
  \fB\-n\fR, \fB\-\-notify\fR \fIFLAG\fR Disable notifications (Growl or Libnotify depending on your system)\. Notifications can be disabled globally by setting a GUARD_NOTIFY environment variable to false\. FLAG can be \fBtrue\fR/\fBfalse\fR or \fBt\fR/\fBf\fR\.
28
28
  .
29
29
  .P
30
- \fB\-d\fR, \fB\-\-debug\fR Runs Guard in debug mode\.
30
+ \fB\-v\fR, \fB\-\-verbose\fR Runs Guard in verbose mode\.
31
31
  .
32
32
  .P
33
33
  \fB\-g\fR, \fB\-\-group\fR \fIGROUP1\fR \fIGROUP2\fR\.\.\. Runs only the groups specified by GROUP1, GROUP2 etc\. Groups name should be separated by spaces\. Guards that don\'t belong to a group are considered global and are always run\.
@@ -44,7 +44,7 @@ The following options are available:
44
44
  .P
45
45
  \fB\-i\fR, \fB\-\-no\-interactions\fR Turn off completely any Guard terminal interactions\.
46
46
  .
47
- .SS "init <a href=\"guard\.html\">GUARD</a>"
47
+ .SS "init [GUARD]"
48
48
  If no Guardfile is present in the current directory, creates an empty Guardfile\.
49
49
  .
50
50
  .P
@@ -97,8 +97,8 @@
97
97
  Notifications can be disabled globally by setting a GUARD_NOTIFY environment variable to false.
98
98
  FLAG can be <code>true</code>/<code>false</code> or <code>t</code>/<code>f</code>.</p>
99
99
 
100
- <p><code>-d</code>, <code>--debug</code>
101
- Runs Guard in debug mode.</p>
100
+ <p><code>-v</code>, <code>--verbose</code>
101
+ Runs Guard in verbose mode.</p>
102
102
 
103
103
  <p><code>-g</code>, <code>--group</code> <var>GROUP1</var> <var>GROUP2</var>...
104
104
  Runs only the groups specified by GROUP1, GROUP2 etc.
@@ -117,7 +117,7 @@
117
117
  <p><code>-i</code>, <code>--no-interactions</code>
118
118
  Turn off completely any Guard terminal interactions.</p>
119
119
 
120
- <h3 id="init-GUARD">init <a href="guard.html">GUARD</a></h3>
120
+ <h3 id="init-GUARD-">init [GUARD]</h3>
121
121
 
122
122
  <p>If no Guardfile is present in the current directory, creates an empty Guardfile.</p>
123
123
 
@@ -172,7 +172,7 @@ https://github.com/guard/guard/blob/master/CHANGELOG.md</p>
172
172
 
173
173
  <ol class='man-decor man-foot man foot'>
174
174
  <li class='tl'></li>
175
- <li class='tc'>October 2011</li>
175
+ <li class='tc'>December 2011</li>
176
176
  <li class='tr'>guard(1)</li>
177
177
  </ol>
178
178
 
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: 0.9.1
4
+ version: 0.9.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: 2011-12-19 00:00:00.000000000Z
12
+ date: 2011-12-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70121759712180 !ruby/object:Gem::Requirement
16
+ requirement: &70324163239920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.14.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70121759712180
24
+ version_requirements: *70324163239920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: ffi
27
- requirement: &70121759711540 !ruby/object:Gem::Requirement
27
+ requirement: &70324163237020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.5.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70121759711540
35
+ version_requirements: *70324163237020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70121759710920 !ruby/object:Gem::Requirement
38
+ requirement: &70324163234420 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70121759710920
46
+ version_requirements: *70324163234420
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70121759709980 !ruby/object:Gem::Requirement
49
+ requirement: &70324163232220 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.7.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70121759709980
57
+ version_requirements: *70324163232220
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-rspec
60
- requirement: &70121759709280 !ruby/object:Gem::Requirement
60
+ requirement: &70324163230380 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.5.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70121759709280
68
+ version_requirements: *70324163230380
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
- requirement: &70121759708200 !ruby/object:Gem::Requirement
71
+ requirement: &70324163229000 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.7.3
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70121759708200
79
+ version_requirements: *70324163229000
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: redcarpet
82
- requirement: &70121759706360 !ruby/object:Gem::Requirement
82
+ requirement: &70324163221540 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.17.2
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70121759706360
90
+ version_requirements: *70324163221540
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: pry
93
- requirement: &70121759704960 !ruby/object:Gem::Requirement
93
+ requirement: &70324163213600 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: 0.9.6.2
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70121759704960
101
+ version_requirements: *70324163213600
102
102
  description: Guard is a command line tool to easily handle events on file system modifications.
103
103
  email:
104
104
  - thibaud@thibaud.me
@@ -119,6 +119,8 @@ files:
119
119
  - lib/guard/guard.rb
120
120
  - lib/guard/hook.rb
121
121
  - lib/guard/interactor.rb
122
+ - lib/guard/interactors/readline.rb
123
+ - lib/guard/interactors/simple.rb
122
124
  - lib/guard/listener.rb
123
125
  - lib/guard/listeners/darwin.rb
124
126
  - lib/guard/listeners/linux.rb