rb-fsevent 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,6 +14,10 @@ class FSEvent
14
14
 
15
15
  attr_reader :paths, :callback
16
16
 
17
+ def initialize args = nil, &block
18
+ watch(args, &block) unless args.nil?
19
+ end
20
+
17
21
  def watch(watch_paths, options=nil, &block)
18
22
  @paths = watch_paths.kind_of?(Array) ? watch_paths : [watch_paths]
19
23
  @callback = block
@@ -28,12 +32,14 @@ class FSEvent
28
32
  end
29
33
 
30
34
  def run
35
+ @pipe = open_pipe
31
36
  @running = true
37
+
32
38
  # please note the use of IO::select() here, as it is used specifically to
33
39
  # preserve correct signal handling behavior in ruby 1.8.
34
- while @running && IO::select([pipe], nil, nil, nil)
35
- if line = pipe.readline
36
- modified_dir_paths = line.split(":").select { |dir| dir != "\n" }
40
+ while @running && IO::select([@pipe], nil, nil, nil)
41
+ if line = @pipe.readline
42
+ modified_dir_paths = line.split(':').select { |dir| dir != "\n" }
37
43
  callback.call(modified_dir_paths)
38
44
  end
39
45
  end
@@ -43,18 +49,18 @@ class FSEvent
43
49
  end
44
50
 
45
51
  def stop
46
- if pipe
47
- Process.kill("KILL", pipe.pid)
48
- pipe.close
52
+ unless @pipe.nil?
53
+ Process.kill('KILL', @pipe.pid)
54
+ @pipe.close
49
55
  end
50
56
  rescue IOError
51
57
  ensure
52
- @pipe = @running = nil
58
+ @running = false
53
59
  end
54
60
 
55
61
  if RUBY_VERSION < '1.9'
56
- def pipe
57
- @pipe ||= IO.popen("#{self.class.watcher_path} #{options_string} #{shellescaped_paths}")
62
+ def open_pipe
63
+ IO.popen("#{self.class.watcher_path} #{options_string} #{shellescaped_paths}")
58
64
  end
59
65
 
60
66
  private
@@ -85,8 +91,8 @@ class FSEvent
85
91
  return str
86
92
  end
87
93
  else
88
- def pipe
89
- @pipe ||= IO.popen([self.class.watcher_path] + @options + @paths)
94
+ def open_pipe
95
+ IO.popen([self.class.watcher_path] + @options + @paths)
90
96
  end
91
97
  end
92
98
 
@@ -1,3 +1,3 @@
1
1
  class FSEvent
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb-fsevent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-01-29 00:00:00.000000000 Z
13
+ date: 2012-04-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
- requirement: &70188653990400 !ruby/object:Gem::Requirement
17
+ requirement: &70197998257960 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 1.0.10
22
+ version: '1.0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *70188653990400
25
+ version_requirements: *70197998257960
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &70188653989600 !ruby/object:Gem::Requirement
28
+ requirement: &70197998257020 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 2.5.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70188653989600
36
+ version_requirements: *70197998257020
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: guard-rspec
39
- requirement: &70188653988820 !ruby/object:Gem::Requirement
39
+ requirement: &70197998256420 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: 0.1.9
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70188653988820
47
+ version_requirements: *70197998256420
48
48
  description: FSEvents API with Signals catching (without RubyCocoa)
49
49
  email:
50
50
  - thibaud@thibaud.me
@@ -88,15 +88,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
88
  - - ! '>='
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
+ segments:
92
+ - 0
93
+ hash: -149870082174800762
91
94
  required_rubygems_version: !ruby/object:Gem::Requirement
92
95
  none: false
93
96
  requirements:
94
97
  - - ! '>='
95
98
  - !ruby/object:Gem::Version
96
99
  version: '0'
100
+ segments:
101
+ - 0
102
+ hash: -149870082174800762
97
103
  requirements: []
98
104
  rubyforge_project: rb-fsevent
99
- rubygems_version: 1.8.13
105
+ rubygems_version: 1.8.11
100
106
  signing_key:
101
107
  specification_version: 3
102
108
  summary: Very simple & usable FSEvents API