ruby-fsevent 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.md CHANGED
@@ -1,12 +1,18 @@
1
1
  History
2
2
  =======
3
+ 0.2.1 2009-01-21
4
+ ----------------
5
+
6
+ **enhancements**
7
+
8
+ - Ruby 1.9.1 compatibility thanks to troyk
3
9
 
4
10
  0.2.0 2009-10-23
5
11
  ----------------
6
12
 
7
13
  **enhancements**
8
14
 
9
- - No More Forking! The event loop used to fork to ensure signal handlers would be observed.
15
+ - No More Kernel Forking! The event loop used to fork to ensure signal handlers would be observed.
10
16
  A custom signal handling solution has replaced the need to fork.
11
17
  - The Event listener can now be stopped and restarted using FSEvent#stop and FSEvent#restart
12
18
 
data/README.md CHANGED
@@ -2,25 +2,33 @@ ruby-fsevent
2
2
  ============
3
3
 
4
4
  A native extension exposing the OS X FSEvent API.
5
- Register directories you want to watch and a callback will fire whenever a
6
- change occurs in the registered directories.
7
5
 
8
- I got tired of reinstalling RubyCocoa every time I installed a new version of
9
- Ruby just to rspactor working. Watchr has changed the game by allowing generic
10
- file handlers but I started waiting 4-5 seconds for an event to fire. With a
11
- generic, native interface to the FSEvent API we can harness the speed of
12
- FSEvents without depending on RubyCocoa.
6
+ Register the directories you want to watch, create a custom callback, and your
7
+ callback will fire everytime a change occurs in the registered directories.
8
+
9
+ I'm tired of recompiling RubyCocoa just get Rspactor working whenever I switch Ruby versions. Hopefully, this gem will break that dependency.
10
+
11
+ Watchr and Kicker have recently grabbed my attention. They allow you to watch
12
+ directories for changes and create custom event handlers. Unfortunately, Watchr
13
+ has a 4-5 second delay when using it with Rev (recommended) before your
14
+ callback is fires. Without Rev, Watchr degrades to a 0.5 second Ruby loop
15
+ which we all know is not resource-friendly. Now, Watchr could easily add native
16
+ FSEvents as a new backend for Mac users.
17
+
18
+ Kicker already uses the FSEvents API but it requires RubyCocoa just like
19
+ Rspactor. They could easily switch their dependency to this native extension
20
+ and remove the need for RubyCocoa.
21
+
22
+ With a generic, native interface to the FSEvent API we, as Rubyists can harness
23
+ the power of OSX FSEvents without depending on RubyCocoa.
13
24
 
14
25
  Demo
15
26
  ----
16
27
 
17
- 1. cd ext/
18
- 2. ruby extconf.rb
19
- 3. make
20
- 4. cd ../
21
- 5. ruby examples/print_changes.rb
22
- 6. Notice that the examples directory and the /tmp directories are being monitored
23
- 7. Make a change to either directory and watch the callback fire
28
+ 1. rake make
29
+ 2. ruby examples/print_changes.rb
30
+ 3. Notice that the examples directory and the /tmp directory are being monitored
31
+ 4. Make a change to either directory and watch the callback fire
24
32
 
25
33
  TODO
26
34
  ----
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ begin
12
12
  gem.email = "sandro.turriate@gmail.com"
13
13
  gem.homepage = "http://github.com/sandro/ruby-fsevent"
14
14
  gem.authors = ["Sandro Turriate"]
15
- gem.add_development_dependency "rspec", '>=1.2.8'
15
+ gem.add_development_dependency "rspec", '1.2.9'
16
16
  gem.require_paths = %w(lib ext)
17
17
  gem.extensions << 'ext/extconf.rb'
18
18
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -6,10 +6,9 @@ class Restart < FSEvent
6
6
  def on_change(directories)
7
7
  puts "Detected change in: #{directories.inspect}"
8
8
  unless @restarted
9
- self.stop
10
9
  @restarted = true
11
10
  self.watch_directories "#{Dir.pwd}/spec"
12
- self.start
11
+ self.restart
13
12
  end
14
13
  end
15
14
 
@@ -35,12 +35,12 @@ void callback(
35
35
  void watch_directory(VALUE self) {
36
36
  VALUE rb_registered_directories = rb_iv_get(self, "@registered_directories");
37
37
  int i, dir_size;
38
- dir_size = RARRAY(rb_registered_directories)->len;
38
+ dir_size = RARRAY_LEN(rb_registered_directories);
39
39
 
40
- VALUE *rb_dir_names = RARRAY(rb_registered_directories)->ptr;
40
+ VALUE *rb_dir_names = RARRAY_PTR(rb_registered_directories);
41
41
  CFStringRef dir_names[dir_size];
42
42
  for (i = 0; i < dir_size; i++) {
43
- dir_names[i] = CFStringCreateWithCString(NULL, (char *)RSTRING(rb_dir_names[i])->ptr, kCFStringEncodingUTF8);
43
+ dir_names[i] = CFStringCreateWithCString(NULL, (char *)RSTRING_PTR(rb_dir_names[i]), kCFStringEncodingUTF8);
44
44
  }
45
45
 
46
46
  CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)&dir_names, dir_size, NULL);
@@ -76,12 +76,13 @@ static VALUE t_init(VALUE self) {
76
76
  }
77
77
 
78
78
  static VALUE t_on_change(VALUE self, VALUE original_directory_name) {
79
- return Qnil;
79
+ rb_raise(rb_eNotImpError, "You must define #on_change in your subclass");
80
+ return self;
80
81
  }
81
82
 
82
83
  static VALUE t_watch_directories(VALUE self, VALUE directories) {
83
84
  if (TYPE(directories) == T_ARRAY) {
84
- rb_iv_set(self, "@registered_directories", rb_ary_new4(RARRAY(directories)->len, RARRAY(directories)->ptr));
85
+ rb_iv_set(self, "@registered_directories", rb_ary_new4(RARRAY_LEN(directories), RARRAY_PTR(directories)));
85
86
  }
86
87
  else {
87
88
  rb_iv_set(self, "@registered_directories", rb_ary_new3(1, directories));
@@ -1,20 +1,20 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruby-fsevent}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sandro Turriate"]
12
- s.date = %q{2009-10-24}
12
+ s.date = %q{2010-01-21}
13
13
  s.description = %q{
14
14
  A native extension exposing the OS X FSEvent API. Register directories you want to watch and a callback will fire whenever a change occurs in the registered directories.
15
15
  }
16
16
  s.email = %q{sandro.turriate@gmail.com}
17
- s.extensions = ["ext/extconf.rb"]
17
+ s.extensions = ["ext/extconf.rb", "ext/extconf.rb"]
18
18
  s.extra_rdoc_files = [
19
19
  "LICENSE",
20
20
  "README.md"
@@ -54,11 +54,12 @@ Gem::Specification.new do |s|
54
54
  s.specification_version = 3
55
55
 
56
56
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
57
- s.add_development_dependency(%q<rspec>, [">= 1.2.8"])
57
+ s.add_development_dependency(%q<rspec>, ["= 1.2.9"])
58
58
  else
59
- s.add_dependency(%q<rspec>, [">= 1.2.8"])
59
+ s.add_dependency(%q<rspec>, ["= 1.2.9"])
60
60
  end
61
61
  else
62
- s.add_dependency(%q<rspec>, [">= 1.2.8"])
62
+ s.add_dependency(%q<rspec>, ["= 1.2.9"])
63
63
  end
64
64
  end
65
+
@@ -24,6 +24,14 @@ describe FSEvent do
24
24
  end
25
25
  end
26
26
 
27
+ describe "#on_change" do
28
+ it "raises NotImplementedError" do
29
+ expect do
30
+ subject.on_change(nil)
31
+ end.to raise_error(NotImplementedError)
32
+ end
33
+ end
34
+
27
35
  describe "API" do
28
36
  it { should respond_to(:on_change) }
29
37
  it { should respond_to(:start) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-fsevent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Turriate
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-24 00:00:00 -04:00
12
+ date: 2010-01-21 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -18,9 +18,9 @@ dependencies:
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ">="
21
+ - - "="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.2.8
23
+ version: 1.2.9
24
24
  version:
25
25
  description: "\n A native extension exposing the OS X FSEvent API. Register directories you want to watch and a callback will fire whenever a change occurs in the registered directories.\n "
26
26
  email: sandro.turriate@gmail.com
@@ -28,6 +28,7 @@ executables: []
28
28
 
29
29
  extensions:
30
30
  - ext/extconf.rb
31
+ - ext/extconf.rb
31
32
  extra_rdoc_files:
32
33
  - LICENSE
33
34
  - README.md