rb-fsevent 0.3.9 → 0.3.10

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.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Thibaud Guillaume-Gentil
1
+ Copyright (c) 2011 Thibaud Guillaume-Gentil
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -19,9 +19,14 @@ void callback(ConstFSEventStreamRef streamRef,
19
19
  }
20
20
 
21
21
  int main (int argc, const char * argv[]) {
22
+ // Collect arguments as paths to watch
23
+ CFMutableArrayRef pathsToWatch = CFArrayCreateMutable(NULL, argc-1, NULL);
24
+ int i;
25
+ for(i=1; i<argc; i++) {
26
+ CFArrayAppendValue(pathsToWatch, CFStringCreateWithCString(kCFAllocatorDefault, argv[i], kCFStringEncodingUTF8));
27
+ }
28
+
22
29
  // Create event stream
23
- CFStringRef pathToWatch = CFStringCreateWithCString(kCFAllocatorDefault, argv[1], kCFStringEncodingUTF8);
24
- CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)&pathToWatch, 1, NULL);
25
30
  void *callbackInfo = NULL;
26
31
  FSEventStreamRef stream;
27
32
  CFAbsoluteTime latency = 0.5;
@@ -34,11 +39,11 @@ int main (int argc, const char * argv[]) {
34
39
  latency,
35
40
  kFSEventStreamCreateFlagNone
36
41
  );
37
-
42
+
38
43
  // Add stream to run loop
39
44
  FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
40
45
  FSEventStreamStart(stream);
41
46
  CFRunLoopRun();
42
-
47
+
43
48
  return 2;
44
- }
49
+ }
@@ -1,16 +1,16 @@
1
1
  class FSEvent
2
- attr_reader :path, :callback, :pipe
3
-
4
- def watch(path, &callback)
5
- @path = path
2
+ attr_reader :paths, :callback, :pipe
3
+
4
+ def watch(paths, &callback)
5
+ @paths = paths.kind_of?(Enumerable) ? paths : [paths]
6
6
  @callback = callback
7
7
  end
8
-
8
+
9
9
  def run
10
10
  launch_bin
11
11
  listen
12
12
  end
13
-
13
+
14
14
  def stop
15
15
  if pipe
16
16
  Process.kill("KILL", pipe.pid)
@@ -18,17 +18,17 @@ class FSEvent
18
18
  end
19
19
  rescue IOError
20
20
  end
21
-
21
+
22
22
  private
23
-
23
+
24
24
  def bin_path
25
25
  File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin'))
26
26
  end
27
-
27
+
28
28
  def launch_bin
29
- @pipe = IO.popen("#{bin_path}/fsevent_watch #{shellescape(path)}")
29
+ @pipe = IO.popen("#{bin_path}/fsevent_watch #{shellescaped_paths}")
30
30
  end
31
-
31
+
32
32
  def listen
33
33
  while !pipe.eof?
34
34
  if line = pipe.readline
@@ -39,23 +39,27 @@ private
39
39
  rescue Interrupt, IOError
40
40
  stop
41
41
  end
42
-
42
+
43
+ def shellescaped_paths
44
+ @paths.map {|path| shellescape(path)}.join(' ')
45
+ end
46
+
43
47
  # for Ruby 1.8.6 support
44
48
  def shellescape(str)
45
49
  # An empty argument will be skipped, so return empty quotes.
46
50
  return "''" if str.empty?
47
-
51
+
48
52
  str = str.dup
49
-
53
+
50
54
  # Process as a single byte sequence because not all shell
51
55
  # implementations are multibyte aware.
52
56
  str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1")
53
-
57
+
54
58
  # A LF cannot be escaped with a backslash because a backslash + LF
55
59
  # combo is regarded as line continuation and simply ignored.
56
60
  str.gsub!(/\n/, "'\n'")
57
-
61
+
58
62
  return str
59
63
  end
60
-
64
+
61
65
  end
@@ -1,3 +1,3 @@
1
1
  class FSEvent
2
- VERSION = "0.3.9"
2
+ VERSION = "0.3.10"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb-fsevent
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
5
- prerelease: false
4
+ hash: 7
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 9
10
- version: 0.3.9
9
+ - 10
10
+ version: 0.3.10
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-11-11 00:00:00 +01:00
18
+ date: 2011-02-07 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 17
29
+ hash: 3
30
30
  segments:
31
31
  - 1
32
32
  - 0
33
- - 3
34
- version: 1.0.3
33
+ - 10
34
+ version: 1.0.10
35
35
  type: :development
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -42,12 +42,12 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 13
45
+ hash: 27
46
46
  segments:
47
47
  - 2
48
+ - 5
48
49
  - 0
49
- - 1
50
- version: 2.0.1
50
+ version: 2.5.0
51
51
  type: :development
52
52
  version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
@@ -58,12 +58,12 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- hash: 19
61
+ hash: 9
62
62
  segments:
63
63
  - 0
64
64
  - 1
65
- - 4
66
- version: 0.1.4
65
+ - 9
66
+ version: 0.1.9
67
67
  type: :development
68
68
  version_requirements: *id003
69
69
  description: FSEvents API with Signals catching (without RubyCocoa)
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  requirements: []
114
114
 
115
115
  rubyforge_project: rb-fsevent
116
- rubygems_version: 1.3.7
116
+ rubygems_version: 1.5.0
117
117
  signing_key:
118
118
  specification_version: 3
119
119
  summary: Very simple & usable FSEvents API