autotest-fsevent 0.2.1 → 0.2.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.
data/CHANGELOG.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.2.2
2
+
3
+ * 1 major improvement
4
+ * Build binary at install time (inspired by Michael Hale)
5
+
1
6
  == 0.2.1 2010-02-08
2
7
 
3
8
  * 2 minor improvements
data/README.rdoc CHANGED
@@ -17,15 +17,25 @@ to use FSEvent and therefore be nice to your Mac.
17
17
  Unlike other test runners for the Mac, autotest-mac does not replace but
18
18
  extend autotest and does *not* require RubyCocoa to be installed.
19
19
 
20
+ If you are on Linux, you should take a look at the autotest-inotify gem instead:
21
+
22
+ http://github.com/ewollesen/autotest-inotify
23
+
20
24
  == REQUIREMENTS:
21
25
 
22
26
  * Mac OS X >= 10.5
27
+ * Xcode
23
28
  * autotest >= 4.2.4
24
29
  * sys-uname
25
30
 
26
31
  == INSTALL:
27
32
 
28
- First install the gem:
33
+ In order to compile the fsevent binary at install time, Xcode (Mac OS X
34
+ Development Suite) must be installed. You can download it for free from:
35
+
36
+ http://developer.apple.com
37
+
38
+ Now install the gem:
29
39
 
30
40
  sudo gem install autotest-fsevent
31
41
 
@@ -47,12 +57,26 @@ the lighter and improved autotest gem. To update do the following:
47
57
  sudo gem uninstall ZenTest
48
58
  sudo gem update autotest-fsevent
49
59
 
50
- And only if you need all the functionality of ZenTest:
60
+ To use autotest with Rails, install the autotest-rails-pure gem instead of
61
+ the famous autotest-rails gem which requires ZenTest:
62
+
63
+ sudo gem uninstall autotest-rails
64
+ sudo gem install autotest-rails-pure
65
+
66
+ And in case one day you need the more advanced features of ZenTest, install
67
+ the zentest-without-autotest gem alongside autotest:
51
68
 
52
69
  sudo gem install zentest-without-autotest
53
70
 
54
71
  == TROUBLESHOOTING:
55
72
 
73
+ === Compilation of fsevent_sleep Failed
74
+
75
+ Make sure you have Xcode (Mac OS X Development Suite) installed. You can
76
+ download it for free from:
77
+
78
+ http://developer.apple.com
79
+
56
80
  === Loading the Plugin Seems to Fail
57
81
 
58
82
  The reason may be ZenTest which must not be installed. See "Update from
@@ -0,0 +1,30 @@
1
+ # Workaround to make Rubygems believe it builds a native gem
2
+
3
+ def emulate_extension_install(extension_name)
4
+ File.open('Makefile', 'w') { |f| f.write "all:\n\ninstall:\n\n" }
5
+ File.open('make', 'w') do |f|
6
+ f.write '#!/bin/sh'
7
+ f.chmod f.stat.mode | 0111
8
+ end
9
+ File.open(extension_name + '.so', 'w') {}
10
+ File.open(extension_name + '.dll', 'w') {}
11
+ File.open('nmake.bat', 'w') { |f| }
12
+ end
13
+
14
+ emulate_extension_install('fsevent')
15
+
16
+
17
+ # Compile the actual fsevent_sleep binary
18
+
19
+ raise "Only Darwin (Mac OS X) systems are supported" unless `uname -s`.chomp == 'Darwin'
20
+
21
+ GEM_ROOT = File.expand_path(File.join('..', '..'))
22
+ DARWIN_VERSION = `uname -r`.to_i
23
+ SDK_VERSION = { 9 => '10.5', 10 => '10.6', 11 => '10.7' }[DARWIN_VERSION]
24
+
25
+ raise "Darwin #{DARWIN_VERSION} is not (yet) supported" unless SDK_VERSION
26
+
27
+ `mkdir -p #{File.join(GEM_ROOT, 'bin')}`
28
+ `CFLAGS='-isysroot /Developer/SDKs/MacOSX#{SDK_VERSION}.sdk -mmacosx-version-min=#{SDK_VERSION}' /usr/bin/gcc -framework CoreServices -o "#{GEM_ROOT}/bin/fsevent_sleep" fsevent_sleep.c`
29
+
30
+ raise "Compilation of fsevent_sleep failed (see README)" unless File.executable?("#{GEM_ROOT}/bin/fsevent_sleep")
@@ -0,0 +1,43 @@
1
+ #include <CoreServices/CoreServices.h>
2
+
3
+ static void callback(ConstFSEventStreamRef streamRef,
4
+ void *clientCallBackInfo,
5
+ size_t numEvents,
6
+ void *eventPaths,
7
+ const FSEventStreamEventFlags eventFlags[],
8
+ const FSEventStreamEventId eventIds[]) {
9
+ exit(0);
10
+ }
11
+
12
+ int main (int argc, const char * argv[]) {
13
+ // Show help
14
+ if (argc != 2 || strncmp(argv[1], "-h", 2) == 0) {
15
+ printf("Sleep until a file in or below the watchdir is modified.\n");
16
+ printf("Usage: fsevent_sleep /path/to/watchdir\n");
17
+ exit(1);
18
+ }
19
+
20
+ // Create event stream
21
+ CFStringRef pathToWatch = CFStringCreateWithCString(kCFAllocatorDefault, argv[1], kCFStringEncodingUTF8);
22
+ CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)&pathToWatch, 1, NULL);
23
+ void *callbackInfo = NULL;
24
+ FSEventStreamRef stream;
25
+ CFAbsoluteTime latency = 1.0;
26
+ stream = FSEventStreamCreate(
27
+ kCFAllocatorDefault,
28
+ callback,
29
+ callbackInfo,
30
+ pathsToWatch,
31
+ kFSEventStreamEventIdSinceNow,
32
+ latency,
33
+ kFSEventStreamCreateFlagNone
34
+ );
35
+
36
+ // Add stream to run loop
37
+ FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
38
+ FSEventStreamStart(stream);
39
+ CFRunLoopRun();
40
+
41
+ // Exit
42
+ return 2;
43
+ }
@@ -21,14 +21,13 @@ module Autotest::FSEvent
21
21
  # Use FSEvent if possible
22
22
  # Add waiting hook to prevent fallback to polling after ignored files have changed
23
23
  Autotest.add_hook :initialize do
24
- if (Uname.sysname == 'Darwin' && Uname.release.to_i >= 9) || %w(Linux).include?(Uname.sysname)
24
+ if Uname.sysname == 'Darwin' && Uname.release.to_i >= 9
25
25
  class ::Autotest
26
26
  remove_method :wait_for_changes
27
27
  def wait_for_changes
28
28
  hook :waiting
29
29
  begin
30
- # `#{File.join(GEM_PATH, 'fsevent', Uname.sysname.downcase, 'fsevent_sleep')} '#{Dir.pwd}' 2>&1`
31
- `cd '#{Dir.pwd}'; #{File.join(GEM_PATH, 'fsevent', Uname.sysname.downcase, 'fsevent_sleep')} . 2>&1`
30
+ `cd '#{Dir.pwd}'; #{File.join(GEM_PATH, 'bin', 'fsevent_sleep')} . 2>&1`
32
31
  Kernel.sleep self.sleep
33
32
  end until find_files_to_test
34
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autotest-fsevent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Schwyn
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-08 00:00:00 +01:00
12
+ date: 2010-03-10 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -46,14 +46,14 @@ description: Autotest relies on filesystem polling to detect modifications in so
46
46
  email: ruby@bitcetera.com
47
47
  executables: []
48
48
 
49
- extensions: []
50
-
49
+ extensions:
50
+ - ext/fsevent/extconf.rb
51
51
  extra_rdoc_files:
52
52
  - LICENSE
53
53
  - README.rdoc
54
54
  files:
55
55
  - CHANGELOG.txt
56
- - fsevent/darwin/fsevent_sleep
56
+ - ext/fsevent/fsevent_sleep.c
57
57
  - lib/autotest/fsevent.rb
58
58
  - LICENSE
59
59
  - README.rdoc
@@ -71,10 +71,8 @@ post_install_message: "\n\
71
71
  Rails, thank you!\n\n\
72
72
  http://workingwithrails.com/recommendation/new/person/11706-sven-schwyn\n\n\
73
73
  +-------------------------------------------------------------------------+\n\
74
- | READ THIS IF YOU ARE UPGRADING FROM 0.1.X |\n\
75
- | As of 0.2.0 this gem no longer depends on the rather heavy ZenTest gem |\n\
76
- | but the more lightweight autotest gem. You MUST uninstall ZenTest now! |\n\
77
- | Please refer to the README in case you need more ZenTest functionality. |\n\
74
+ | UPGRADING USERS please take a look at the README now for important news |\n\
75
+ | related to modified dependencies since 0.1.x and Rails compatibility. |\n\
78
76
  +-------------------------------------------------------------------------+\n\
79
77
  \e[0m\n"
80
78
  rdoc_options:
Binary file