guard 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/guard.rb CHANGED
@@ -55,7 +55,7 @@ module Guard
55
55
  end
56
56
 
57
57
  def locate_guard(name)
58
- `gem open guard-#{name} --latest --command echo`
58
+ `gem open guard-#{name} --latest --command echo`.chomp
59
59
  rescue
60
60
  UI.error "Could not find 'guard-#{name}' gem path."
61
61
  end
@@ -25,8 +25,8 @@ module Guard
25
25
 
26
26
  def self.usable?
27
27
  require 'rb-fsevent'
28
- if !defined?(FSEvent::VERSION) || Gem::Version.new(FSEvent::VERSION) < Gem::Version.new('0.3.2')
29
- UI.info "Please update rb-fsevent (>= 0.3.2)"
28
+ if !defined?(FSEvent::VERSION) || Gem::Version.new(FSEvent::VERSION) < Gem::Version.new('0.3.3')
29
+ UI.info "Please update rb-fsevent (>= 0.3.3)"
30
30
  false
31
31
  else
32
32
  true
@@ -3,6 +3,8 @@ module Guard
3
3
  attr_reader :inotify, :files, :latency, :callback
4
4
 
5
5
  def initialize
6
+ super
7
+
6
8
  @inotify = INotify::Notifier.new
7
9
  @files = []
8
10
  @latency = 0.5
@@ -10,7 +12,7 @@ module Guard
10
12
 
11
13
  def on_change(&callback)
12
14
  @callback = callback
13
- inotify.watch(Dir.pwd, :recursive, :attrib, :modify, :create) do |event|
15
+ inotify.watch(Dir.pwd, :recursive, :modify, :create, :delete, :move) do |event|
14
16
  unless event.name == "" # Event on root directory
15
17
  @files << event.absolute_name
16
18
  end
@@ -20,12 +22,12 @@ module Guard
20
22
 
21
23
  def start
22
24
  @stop = false
23
- watch_change
25
+ watch_change unless @watch_change
24
26
  end
25
27
 
26
28
  def stop
27
29
  @stop = true
28
- inotify.stop
30
+ sleep latency
29
31
  end
30
32
 
31
33
  def self.usable?
@@ -44,18 +46,24 @@ module Guard
44
46
  private
45
47
 
46
48
  def watch_change
49
+ @watch_change = true
47
50
  while !@stop
48
51
  if Config::CONFIG['build'] =~ /java/ || IO.select([inotify.to_io], [], [], latency)
52
+ break if @stop
53
+
49
54
  inotify.process
55
+ update_last_event
50
56
 
51
57
  unless files.empty?
52
58
  files.map! { |file| file.gsub("#{Dir.pwd}/", '') }
53
59
  callback.call(files)
54
60
  files.clear
55
61
  end
56
- sleep latency
62
+
63
+ sleep latency unless @stop
57
64
  end
58
65
  end
66
+ @watch_change = false
59
67
  end
60
68
 
61
69
  end
data/lib/guard/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Guard
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thibaud Guillaume-Gentil
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-21 00:00:00 +02:00
18
+ date: 2010-10-24 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency