guard 1.0.0 → 1.0.1
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.md +17 -0
- data/README.md +50 -30
- data/bin/fsevent_watch_guard_guard +0 -0
- data/lib/guard.rb +44 -26
- data/lib/guard/cli.rb +23 -6
- data/lib/guard/dsl.rb +33 -15
- data/lib/guard/listener.rb +1 -1
- data/lib/guard/listeners/darwin.rb +1 -1
- data/lib/guard/notifier.rb +3 -1
- data/lib/guard/notifiers/notifysend.rb +81 -0
- data/lib/guard/version.rb +1 -1
- data/lib/guard/version.rbc +180 -0
- data/lib/vendor/darwin/README.rdoc +3 -2
- data/lib/vendor/darwin/bin/fsevent_watch +0 -0
- data/lib/vendor/darwin/ext/fsevent_watch/Info.plist +38 -0
- data/lib/vendor/darwin/ext/fsevent_watch/LICENSE +21 -0
- data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch.xcodeproj/project.pbxproj +254 -0
- data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/TSICTString.c +394 -0
- data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/TSICTString.h +74 -0
- data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/cli.c +160 -0
- data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/cli.h +45 -0
- data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/common.h +34 -0
- data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/compat.c +20 -0
- data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/compat.h +40 -0
- data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/main.c +509 -0
- data/lib/vendor/darwin/ext/fsevent_watch/xcconfig/Common.xcconfig +82 -0
- data/lib/vendor/darwin/ext/fsevent_watch/xcconfig/Debug.xcconfig +19 -0
- data/lib/vendor/darwin/ext/fsevent_watch/xcconfig/Release.xcconfig +23 -0
- data/lib/vendor/darwin/ext/fsevent_watch/xcconfig/fsevent_watch.xcconfig +17 -0
- data/lib/vendor/darwin/ext/rakefile.rb +47 -0
- data/lib/vendor/darwin/ext/rb-fsevent.xcconfig +33 -0
- data/lib/vendor/darwin/lib/rb-fsevent/version.rb +1 -1
- data/lib/vendor/darwin/rb-fsevent.gemspec +3 -2
- data/lib/vendor/darwin/spec/spec_helper.rb +1 -2
- metadata +40 -25
- data/lib/vendor/darwin/ext/extconf.rb +0 -64
- data/lib/vendor/darwin/ext/fsevent/fsevent_watch.c +0 -226
@@ -1,64 +0,0 @@
|
|
1
|
-
# Workaround to make Rubygems believe it builds a native gem
|
2
|
-
require 'mkmf'
|
3
|
-
create_makefile('none')
|
4
|
-
|
5
|
-
# TODO: determine whether we really need to be working around instead of with mkmf
|
6
|
-
|
7
|
-
if `uname -s`.chomp != 'Darwin'
|
8
|
-
puts "Warning! Only Darwin (Mac OS X) systems are supported, nothing will be compiled"
|
9
|
-
else
|
10
|
-
begin
|
11
|
-
xcode_path = %x[xcode-select -print-path].to_s.strip!
|
12
|
-
rescue Errno::ENOENT
|
13
|
-
end
|
14
|
-
|
15
|
-
raise "Could not find a suitable Xcode installation" unless xcode_path
|
16
|
-
|
17
|
-
gem_root = File.expand_path(File.join('..'))
|
18
|
-
darwin_version = `uname -r`.to_i
|
19
|
-
sdk_version = { 9 => '10.5', 10 => '10.6', 11 => '10.7' }[darwin_version]
|
20
|
-
|
21
|
-
raise "Only Darwin systems greater than 8 (Mac OS X 10.5+) are supported" unless sdk_version
|
22
|
-
|
23
|
-
core_flags = %W{
|
24
|
-
-isysroot "#{xcode_path}/SDKs/MacOSX#{sdk_version}.sdk"
|
25
|
-
-mmacosx-version-min=#{sdk_version} -mdynamic-no-pic -std=gnu99
|
26
|
-
}
|
27
|
-
|
28
|
-
cflags = core_flags + %w{-Os -pipe}
|
29
|
-
|
30
|
-
arch_sig = `uname -m`
|
31
|
-
cflags << '-arch i386' if arch_sig =~ /i386$/i
|
32
|
-
|
33
|
-
wflags = %w{
|
34
|
-
-Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch
|
35
|
-
-Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable
|
36
|
-
-Wunused-value -Wuninitialized -Wunknown-pragmas -Wshadow
|
37
|
-
-Wfour-char-constants -Wsign-compare -Wnewline-eof -Wconversion
|
38
|
-
-Wshorten-64-to-32 -Wglobal-constructors -pedantic
|
39
|
-
}
|
40
|
-
|
41
|
-
ldflags = %w{
|
42
|
-
-dead_strip -framework CoreServices
|
43
|
-
}
|
44
|
-
|
45
|
-
cc_opts = core_flags + ldflags
|
46
|
-
|
47
|
-
cc_opts += %w{
|
48
|
-
-D DEBUG=true
|
49
|
-
} if ENV['FWDEBUG'] == "true"
|
50
|
-
|
51
|
-
cc_bin = `which clang || which gcc`.to_s.strip!
|
52
|
-
|
53
|
-
compile_command = "CFLAGS='#{cflags.join(' ')} #{wflags.join(' ')}' #{cc_bin} #{cc_opts.join(' ')} -o '#{gem_root}/bin/fsevent_watch' fsevent/fsevent_watch.c"
|
54
|
-
|
55
|
-
STDERR.puts(compile_command)
|
56
|
-
|
57
|
-
# Compile the actual fsevent_watch binary
|
58
|
-
system "mkdir -p #{File.join(gem_root, 'bin')}"
|
59
|
-
system compile_command
|
60
|
-
|
61
|
-
unless File.executable?("#{gem_root}/bin/fsevent_watch")
|
62
|
-
raise "Compilation of fsevent_watch failed (see README)"
|
63
|
-
end
|
64
|
-
end
|
@@ -1,226 +0,0 @@
|
|
1
|
-
#include <stdio.h>
|
2
|
-
#include <stdlib.h>
|
3
|
-
#include <unistd.h>
|
4
|
-
|
5
|
-
#include <CoreServices/CoreServices.h>
|
6
|
-
|
7
|
-
|
8
|
-
// Structure for storing metadata parsed from the commandline
|
9
|
-
static struct {
|
10
|
-
FSEventStreamEventId sinceWhen;
|
11
|
-
CFTimeInterval latency;
|
12
|
-
FSEventStreamCreateFlags flags;
|
13
|
-
CFMutableArrayRef paths;
|
14
|
-
} config = {
|
15
|
-
(UInt64) kFSEventStreamEventIdSinceNow,
|
16
|
-
(double) 0.3,
|
17
|
-
(UInt32) kFSEventStreamCreateFlagNone,
|
18
|
-
NULL
|
19
|
-
};
|
20
|
-
|
21
|
-
// Prototypes
|
22
|
-
static void append_path(const char *path);
|
23
|
-
static inline void parse_cli_settings(int argc, const char *argv[]);
|
24
|
-
static void callback(FSEventStreamRef streamRef,
|
25
|
-
void *clientCallBackInfo,
|
26
|
-
size_t numEvents,
|
27
|
-
void *eventPaths,
|
28
|
-
const FSEventStreamEventFlags eventFlags[],
|
29
|
-
const FSEventStreamEventId eventIds[]);
|
30
|
-
|
31
|
-
|
32
|
-
// Resolve a path and append it to the CLI settings structure
|
33
|
-
// The FSEvents API will, internally, resolve paths using a similar scheme.
|
34
|
-
// Performing this ahead of time makes things less confusing, IMHO.
|
35
|
-
static void append_path(const char *path)
|
36
|
-
{
|
37
|
-
#ifdef DEBUG
|
38
|
-
fprintf(stderr, "\n");
|
39
|
-
fprintf(stderr, "append_path called for: %s\n", path);
|
40
|
-
#endif
|
41
|
-
|
42
|
-
char fullPath[PATH_MAX];
|
43
|
-
|
44
|
-
if (realpath(path, fullPath) == NULL) {
|
45
|
-
#ifdef DEBUG
|
46
|
-
fprintf(stderr, " realpath not directly resolvable from path\n");
|
47
|
-
#endif
|
48
|
-
|
49
|
-
if (path[0] != '/') {
|
50
|
-
#ifdef DEBUG
|
51
|
-
fprintf(stderr, " passed path is not absolute\n");
|
52
|
-
#endif
|
53
|
-
size_t len;
|
54
|
-
getcwd(fullPath, sizeof(fullPath));
|
55
|
-
#ifdef DEBUG
|
56
|
-
fprintf(stderr, " result of getcwd: %s\n", fullPath);
|
57
|
-
#endif
|
58
|
-
len = strlen(fullPath);
|
59
|
-
fullPath[len] = '/';
|
60
|
-
strlcpy(&fullPath[len + 1], path, sizeof(fullPath) - (len + 1));
|
61
|
-
} else {
|
62
|
-
#ifdef DEBUG
|
63
|
-
fprintf(stderr, " assuming path does not YET exist\n");
|
64
|
-
#endif
|
65
|
-
strlcpy(fullPath, path, sizeof(fullPath));
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
#ifdef DEBUG
|
70
|
-
fprintf(stderr, " resolved path to: %s\n", fullPath);
|
71
|
-
fprintf(stderr, "\n");
|
72
|
-
fflush(stderr);
|
73
|
-
#endif
|
74
|
-
|
75
|
-
CFStringRef pathRef = CFStringCreateWithCString(kCFAllocatorDefault,
|
76
|
-
fullPath,
|
77
|
-
kCFStringEncodingUTF8);
|
78
|
-
CFArrayAppendValue(config.paths, pathRef);
|
79
|
-
CFRelease(pathRef);
|
80
|
-
}
|
81
|
-
|
82
|
-
// Parse commandline settings
|
83
|
-
static inline void parse_cli_settings(int argc, const char *argv[])
|
84
|
-
{
|
85
|
-
config.paths = CFArrayCreateMutable(NULL,
|
86
|
-
(CFIndex)0,
|
87
|
-
&kCFTypeArrayCallBacks);
|
88
|
-
|
89
|
-
for (int i = 1; i < argc; i++) {
|
90
|
-
if (strcmp(argv[i], "--since-when") == 0) {
|
91
|
-
config.sinceWhen = strtoull(argv[++i], NULL, 0);
|
92
|
-
} else if (strcmp(argv[i], "--latency") == 0) {
|
93
|
-
config.latency = strtod(argv[++i], NULL);
|
94
|
-
} else if (strcmp(argv[i], "--no-defer") == 0) {
|
95
|
-
config.flags |= kFSEventStreamCreateFlagNoDefer;
|
96
|
-
} else if (strcmp(argv[i], "--watch-root") == 0) {
|
97
|
-
config.flags |= kFSEventStreamCreateFlagWatchRoot;
|
98
|
-
} else if (strcmp(argv[i], "--ignore-self") == 0) {
|
99
|
-
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
100
|
-
config.flags |= kFSEventStreamCreateFlagIgnoreSelf;
|
101
|
-
#else
|
102
|
-
fprintf(stderr, "MacOSX10.6.sdk is required for --ignore-self\n");
|
103
|
-
#endif
|
104
|
-
} else {
|
105
|
-
append_path(argv[i]);
|
106
|
-
}
|
107
|
-
}
|
108
|
-
|
109
|
-
if (CFArrayGetCount(config.paths) == 0) {
|
110
|
-
append_path(".");
|
111
|
-
}
|
112
|
-
|
113
|
-
#ifdef DEBUG
|
114
|
-
fprintf(stderr, "config.sinceWhen %llu\n", config.sinceWhen);
|
115
|
-
fprintf(stderr, "config.latency %f\n", config.latency);
|
116
|
-
fprintf(stderr, "config.flags %#.8x\n", config.flags);
|
117
|
-
fprintf(stderr, "config.paths\n");
|
118
|
-
|
119
|
-
long numpaths = CFArrayGetCount(config.paths);
|
120
|
-
|
121
|
-
for (long i = 0; i < numpaths; i++) {
|
122
|
-
char path[PATH_MAX];
|
123
|
-
CFStringGetCString(CFArrayGetValueAtIndex(config.paths, i),
|
124
|
-
path,
|
125
|
-
PATH_MAX,
|
126
|
-
kCFStringEncodingUTF8);
|
127
|
-
fprintf(stderr, " %s\n", path);
|
128
|
-
}
|
129
|
-
|
130
|
-
fprintf(stderr, "\n");
|
131
|
-
fflush(stderr);
|
132
|
-
#endif
|
133
|
-
}
|
134
|
-
|
135
|
-
static void callback(FSEventStreamRef streamRef,
|
136
|
-
void *clientCallBackInfo,
|
137
|
-
size_t numEvents,
|
138
|
-
void *eventPaths,
|
139
|
-
const FSEventStreamEventFlags eventFlags[],
|
140
|
-
const FSEventStreamEventId eventIds[])
|
141
|
-
{
|
142
|
-
char **paths = eventPaths;
|
143
|
-
|
144
|
-
#ifdef DEBUG
|
145
|
-
fprintf(stderr, "\n");
|
146
|
-
fprintf(stderr, "FSEventStreamCallback fired!\n");
|
147
|
-
fprintf(stderr, " numEvents: %lu\n", numEvents);
|
148
|
-
|
149
|
-
for (size_t i = 0; i < numEvents; i++) {
|
150
|
-
fprintf(stderr, " event path: %s\n", paths[i]);
|
151
|
-
fprintf(stderr, " event flags: %#.8x\n", eventFlags[i]);
|
152
|
-
fprintf(stderr, " event ID: %llu\n", eventIds[i]);
|
153
|
-
}
|
154
|
-
|
155
|
-
fprintf(stderr, "\n");
|
156
|
-
fflush(stderr);
|
157
|
-
#endif
|
158
|
-
|
159
|
-
for (size_t i = 0; i < numEvents; i++) {
|
160
|
-
fprintf(stdout, "%s", paths[i]);
|
161
|
-
fprintf(stdout, ":");
|
162
|
-
}
|
163
|
-
|
164
|
-
fprintf(stdout, "\n");
|
165
|
-
fflush(stdout);
|
166
|
-
}
|
167
|
-
|
168
|
-
int main(int argc, const char *argv[])
|
169
|
-
{
|
170
|
-
/*
|
171
|
-
* a subprocess will initially inherit the process group of its parent. the
|
172
|
-
* process group may have a control terminal associated with it, which would
|
173
|
-
* be the first tty device opened by the group leader. typically the group
|
174
|
-
* leader is your shell and the control terminal is your login device. a
|
175
|
-
* subset of signals triggered on the control terminal are sent to all members
|
176
|
-
* of the process group, in large part to facilitate sane and consistent
|
177
|
-
* cleanup (ex: control terminal was closed).
|
178
|
-
*
|
179
|
-
* so why the overly descriptive lecture style comment?
|
180
|
-
* 1. SIGINT and SIGQUIT are among the signals with this behavior
|
181
|
-
* 2. a number of applications gank the above for their own use
|
182
|
-
* 3. ruby's insanely useful "guard" is one of these applications
|
183
|
-
* 4. despite having some level of understanding of POSIX signals and a few
|
184
|
-
* of the scenarios that might cause problems, i learned this one only
|
185
|
-
* after reading ruby 1.9's process.c
|
186
|
-
* 5. if left completely undocumented, even slightly obscure bugfixes
|
187
|
-
* may be removed as cruft by a future maintainer
|
188
|
-
*
|
189
|
-
* hindsight is 20/20 addition: if you're single-threaded and blocking on IO
|
190
|
-
* with a subprocess, then handlers for deferrable signals might not get run
|
191
|
-
* when you expect them to. In the case of Ruby 1.8, that means making use of
|
192
|
-
* IO::select, which will preserve correct signal handling behavior.
|
193
|
-
*/
|
194
|
-
if (setpgid(0,0) < 0) {
|
195
|
-
fprintf(stderr, "Unable to set new process group.\n");
|
196
|
-
return 1;
|
197
|
-
}
|
198
|
-
|
199
|
-
parse_cli_settings(argc, argv);
|
200
|
-
|
201
|
-
FSEventStreamContext context = {0, NULL, NULL, NULL, NULL};
|
202
|
-
FSEventStreamRef stream;
|
203
|
-
stream = FSEventStreamCreate(kCFAllocatorDefault,
|
204
|
-
(FSEventStreamCallback)&callback,
|
205
|
-
&context,
|
206
|
-
config.paths,
|
207
|
-
config.sinceWhen,
|
208
|
-
config.latency,
|
209
|
-
config.flags);
|
210
|
-
|
211
|
-
#ifdef DEBUG
|
212
|
-
FSEventStreamShow(stream);
|
213
|
-
fprintf(stderr, "\n");
|
214
|
-
fflush(stderr);
|
215
|
-
#endif
|
216
|
-
|
217
|
-
FSEventStreamScheduleWithRunLoop(stream,
|
218
|
-
CFRunLoopGetCurrent(),
|
219
|
-
kCFRunLoopDefaultMode);
|
220
|
-
FSEventStreamStart(stream);
|
221
|
-
CFRunLoopRun();
|
222
|
-
FSEventStreamFlushSync(stream);
|
223
|
-
FSEventStreamStop(stream);
|
224
|
-
|
225
|
-
return 0;
|
226
|
-
}
|