tripwire 1.1.0 → 1.2.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/Manifest.txt +1 -0
- data/README.txt +9 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/ext/fsevent/extconf.rb +31 -0
- data/ext/fsevent/fsevent_sleep.c +43 -0
- data/lib/tripwire/cli.rb +34 -14
- data/lib/tripwire/runner.rb +29 -3
- data/temp/.keep +0 -0
- data/tripwire.gemspec +9 -5
- metadata +34 -11
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -28,7 +28,15 @@ Tripwire uses very simple Dir.glob-ing
|
|
28
28
|
|
29
29
|
== INSTALL:
|
30
30
|
|
31
|
-
|
31
|
+
The gem is hosted on gemcutter.org, so you should only have to type:
|
32
|
+
|
33
|
+
sudo gem install tripwire
|
34
|
+
|
35
|
+
== CONTRIBUTORS:
|
36
|
+
|
37
|
+
Brendan Baldwin (author), Matthew Fallshaw (integrate Sven Schwyn's fsevent
|
38
|
+
magic, default FILESPEC, interrupt once to trip), Sven Schwyn (silently had his
|
39
|
+
code pinched)
|
32
40
|
|
33
41
|
== LICENSE:
|
34
42
|
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ begin
|
|
8
8
|
gem.description = "Similar to rstakeout and autotest except more options"
|
9
9
|
gem.email = "brendan@usergenic.com"
|
10
10
|
gem.homepage = "http://github.com/brendan/tripwire"
|
11
|
-
gem.authors = ["Brendan Baldwin"]
|
11
|
+
gem.authors = ["Brendan Baldwin", "Matthew Fallshaw", "Sven Schwyn"]
|
12
12
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
13
13
|
end
|
14
14
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1
|
1
|
+
1.2.1
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Workaround to make Rubygems believe it builds a native gem
|
2
|
+
# from http://github.com/svoop/autotest-fsevent/tree/master/ext/fsevent/
|
3
|
+
|
4
|
+
def emulate_extension_install(extension_name)
|
5
|
+
File.open('Makefile', 'w') { |f| f.write "all:\n\ninstall:\n\n" }
|
6
|
+
File.open('make', 'w') do |f|
|
7
|
+
f.write '#!/bin/sh'
|
8
|
+
f.chmod f.stat.mode | 0111
|
9
|
+
end
|
10
|
+
File.open(extension_name + '.so', 'w') {}
|
11
|
+
File.open(extension_name + '.dll', 'w') {}
|
12
|
+
File.open('nmake.bat', 'w') { |f| }
|
13
|
+
end
|
14
|
+
|
15
|
+
emulate_extension_install('fsevent')
|
16
|
+
|
17
|
+
|
18
|
+
# Compile the actual fsevent_sleep binary
|
19
|
+
|
20
|
+
raise "Only Darwin (Mac OS X) systems are supported" unless `uname -s`.chomp == 'Darwin'
|
21
|
+
|
22
|
+
GEM_ROOT = File.expand_path(File.join('..', '..'))
|
23
|
+
DARWIN_VERSION = `uname -r`.to_i
|
24
|
+
SDK_VERSION = { 9 => '10.5', 10 => '10.6', 11 => '10.7' }[DARWIN_VERSION]
|
25
|
+
|
26
|
+
raise "Darwin #{DARWIN_VERSION} is not (yet) supported" unless SDK_VERSION
|
27
|
+
|
28
|
+
`mkdir -p #{File.join(GEM_ROOT, 'bin')}`
|
29
|
+
`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`
|
30
|
+
|
31
|
+
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
|
+
}
|
data/lib/tripwire/cli.rb
CHANGED
@@ -8,26 +8,25 @@ module Tripwire
|
|
8
8
|
|
9
9
|
def initialize(args)
|
10
10
|
|
11
|
-
trap('INT') do
|
12
|
-
puts "\nQuitting..."
|
13
|
-
exit
|
14
|
-
end
|
15
|
-
|
16
11
|
scanner = Tripwire::Scanner.new
|
17
12
|
recursive = true
|
18
13
|
delay = 1
|
19
14
|
option_parser = OptionParser.new do |opt|
|
20
|
-
opt.banner = "Usage: tripwire [options]
|
21
|
-
opt.on("-e","--exclude
|
15
|
+
opt.banner = "Usage: tripwire [options] COMMAND [FILESPEC]+"
|
16
|
+
opt.on("-e","--exclude PATTERN", String,
|
17
|
+
"a pattern defining files/folders to ignore") do |e|
|
22
18
|
scanner.exclude_patterns << e
|
23
19
|
end
|
24
|
-
opt.on("-d","--delay
|
20
|
+
opt.on("-d","--delay SECONDS", Integer,
|
21
|
+
"number of seconds between each scan (defaults to 1)") do |d|
|
25
22
|
delay = d
|
26
23
|
end
|
27
|
-
opt.on("-q","--quiet",
|
24
|
+
opt.on("-q","--quiet",
|
25
|
+
"suppresses output") do
|
28
26
|
scanner.quiet = true
|
29
27
|
end
|
30
|
-
opt.on("-n","--non-recursive",
|
28
|
+
opt.on("-n","--non-recursive",
|
29
|
+
"tells tripwire *not* to scan folders recursively") do
|
31
30
|
recursive = false
|
32
31
|
end
|
33
32
|
end
|
@@ -35,12 +34,33 @@ module Tripwire
|
|
35
34
|
option_parser.parse!(args)
|
36
35
|
|
37
36
|
command = args.shift
|
38
|
-
|
37
|
+
nothing_to_watch = true
|
38
|
+
args.map! do |arg|
|
39
|
+
if File.exist?(arg)
|
40
|
+
nothing_to_watch = false
|
41
|
+
else
|
42
|
+
STDERR.puts "'#{arg}' doesn't exist."
|
43
|
+
end
|
44
|
+
File.directory?(arg) ? "#{arg}/**/*" : arg
|
45
|
+
end if recursive
|
46
|
+
|
47
|
+
# Enough to run?
|
48
|
+
if command.nil?
|
49
|
+
raise "No command specified. Please specify a command to run."
|
50
|
+
elsif args.empty?
|
51
|
+
args = ["."]
|
52
|
+
puts "Watching default path '.'"
|
53
|
+
elsif nothing_to_watch
|
54
|
+
STDERR.puts "WARNING: Nothing to watch in '#{args.join(", ")}'"
|
55
|
+
# else good to run
|
56
|
+
end
|
57
|
+
|
39
58
|
scanner.scan_patterns.concat(args)
|
40
59
|
runner = Tripwire::Runner.new(scanner, command, :delay => delay)
|
41
|
-
runner.run!
|
42
|
-
|
60
|
+
runner.run!
|
61
|
+
rescue
|
62
|
+
STDERR.puts "#{$!}\n\n#{option_parser}"
|
43
63
|
end
|
44
64
|
|
45
65
|
end
|
46
|
-
end
|
66
|
+
end
|
data/lib/tripwire/runner.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
module Tripwire
|
2
2
|
class Runner
|
3
|
+
|
4
|
+
GEM_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
3
5
|
|
4
6
|
attr_accessor :scanner
|
5
7
|
attr_accessor :command
|
6
8
|
attr_accessor :delay
|
7
9
|
|
10
|
+
attr_accessor :interrupted
|
11
|
+
|
8
12
|
def run!
|
9
13
|
raise "No command specified. Please specify a command to run." if !command
|
10
14
|
raise "No files/folders specified. Please specify files/patterns to scan." if scanner.scan_patterns.empty?
|
@@ -12,8 +16,15 @@ module Tripwire
|
|
12
16
|
scanner.quiet = true
|
13
17
|
scanner.scan # do this because we don't care about the initial updates collection
|
14
18
|
scanner.quiet = original_quiet
|
19
|
+
|
20
|
+
add_sigint_handler
|
21
|
+
|
15
22
|
loop do
|
16
|
-
|
23
|
+
begin
|
24
|
+
`cd '#{Dir.pwd}'; #{File.join(GEM_PATH, 'bin', 'fsevent_sleep')} . 2>&1`
|
25
|
+
rescue
|
26
|
+
sleep delay
|
27
|
+
end
|
17
28
|
system(command) unless scanner.scan.empty?
|
18
29
|
end
|
19
30
|
end
|
@@ -25,6 +36,21 @@ module Tripwire
|
|
25
36
|
self.command = command
|
26
37
|
self.delay = options[:delay] || 1
|
27
38
|
end
|
28
|
-
|
39
|
+
|
40
|
+
def add_sigint_handler
|
41
|
+
trap('INT') do
|
42
|
+
if interrupted then
|
43
|
+
puts "\nQuitting..."
|
44
|
+
exit 0
|
45
|
+
else
|
46
|
+
puts "Interrupt a second time to quit"
|
47
|
+
self.interrupted = true
|
48
|
+
Kernel.sleep 1.5
|
49
|
+
system(command)
|
50
|
+
self.interrupted = false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
29
55
|
end
|
30
|
-
end
|
56
|
+
end
|
data/temp/.keep
ADDED
File without changes
|
data/tripwire.gemspec
CHANGED
@@ -5,15 +5,16 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{tripwire}
|
8
|
-
s.version = "1.1
|
8
|
+
s.version = "1.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Brendan Baldwin"]
|
12
|
-
s.date = %q{2010-
|
11
|
+
s.authors = ["Brendan Baldwin", "Matthew Fallshaw", "Sven Schwyn"]
|
12
|
+
s.date = %q{2010-11-02}
|
13
13
|
s.default_executable = %q{tripwire}
|
14
14
|
s.description = %q{Similar to rstakeout and autotest except more options}
|
15
15
|
s.email = %q{brendan@usergenic.com}
|
16
16
|
s.executables = ["tripwire"]
|
17
|
+
s.extensions = ["ext/fsevent/extconf.rb"]
|
17
18
|
s.extra_rdoc_files = [
|
18
19
|
"README.txt"
|
19
20
|
]
|
@@ -25,6 +26,8 @@ Gem::Specification.new do |s|
|
|
25
26
|
"Rakefile",
|
26
27
|
"VERSION",
|
27
28
|
"bin/tripwire",
|
29
|
+
"ext/fsevent/extconf.rb",
|
30
|
+
"ext/fsevent/fsevent_sleep.c",
|
28
31
|
"lib/tripwire.rb",
|
29
32
|
"lib/tripwire/cli.rb",
|
30
33
|
"lib/tripwire/runner.rb",
|
@@ -32,12 +35,13 @@ Gem::Specification.new do |s|
|
|
32
35
|
"spec/scanner_spec.rb",
|
33
36
|
"spec/spec.opts",
|
34
37
|
"spec/spec_helper.rb",
|
38
|
+
"temp/.keep",
|
35
39
|
"tripwire.gemspec"
|
36
40
|
]
|
37
41
|
s.homepage = %q{http://github.com/brendan/tripwire}
|
38
42
|
s.rdoc_options = ["--charset=UTF-8"]
|
39
43
|
s.require_paths = ["lib"]
|
40
|
-
s.rubygems_version = %q{1.3.
|
44
|
+
s.rubygems_version = %q{1.3.7}
|
41
45
|
s.summary = %q{Executes a shell command every time file/folder changes}
|
42
46
|
s.test_files = [
|
43
47
|
"spec/scanner_spec.rb",
|
@@ -48,7 +52,7 @@ Gem::Specification.new do |s|
|
|
48
52
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
53
|
s.specification_version = 3
|
50
54
|
|
51
|
-
if Gem::Version.new(Gem::
|
55
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
56
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
53
57
|
else
|
54
58
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
metadata
CHANGED
@@ -1,33 +1,47 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tripwire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 2
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Brendan Baldwin
|
14
|
+
- Matthew Fallshaw
|
15
|
+
- Sven Schwyn
|
8
16
|
autorequire:
|
9
17
|
bindir: bin
|
10
18
|
cert_chain: []
|
11
19
|
|
12
|
-
date: 2010-
|
20
|
+
date: 2010-11-02 00:00:00 -07:00
|
13
21
|
default_executable: tripwire
|
14
22
|
dependencies:
|
15
23
|
- !ruby/object:Gem::Dependency
|
16
24
|
name: rspec
|
17
|
-
|
18
|
-
|
19
|
-
|
25
|
+
prerelease: false
|
26
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
20
28
|
requirements:
|
21
29
|
- - ">="
|
22
30
|
- !ruby/object:Gem::Version
|
31
|
+
hash: 13
|
32
|
+
segments:
|
33
|
+
- 1
|
34
|
+
- 2
|
35
|
+
- 9
|
23
36
|
version: 1.2.9
|
24
|
-
|
37
|
+
type: :development
|
38
|
+
version_requirements: *id001
|
25
39
|
description: Similar to rstakeout and autotest except more options
|
26
40
|
email: brendan@usergenic.com
|
27
41
|
executables:
|
28
42
|
- tripwire
|
29
|
-
extensions:
|
30
|
-
|
43
|
+
extensions:
|
44
|
+
- ext/fsevent/extconf.rb
|
31
45
|
extra_rdoc_files:
|
32
46
|
- README.txt
|
33
47
|
files:
|
@@ -38,6 +52,8 @@ files:
|
|
38
52
|
- Rakefile
|
39
53
|
- VERSION
|
40
54
|
- bin/tripwire
|
55
|
+
- ext/fsevent/extconf.rb
|
56
|
+
- ext/fsevent/fsevent_sleep.c
|
41
57
|
- lib/tripwire.rb
|
42
58
|
- lib/tripwire/cli.rb
|
43
59
|
- lib/tripwire/runner.rb
|
@@ -45,6 +61,7 @@ files:
|
|
45
61
|
- spec/scanner_spec.rb
|
46
62
|
- spec/spec.opts
|
47
63
|
- spec/spec_helper.rb
|
64
|
+
- temp/.keep
|
48
65
|
- tripwire.gemspec
|
49
66
|
has_rdoc: true
|
50
67
|
homepage: http://github.com/brendan/tripwire
|
@@ -56,21 +73,27 @@ rdoc_options:
|
|
56
73
|
require_paths:
|
57
74
|
- lib
|
58
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
59
77
|
requirements:
|
60
78
|
- - ">="
|
61
79
|
- !ruby/object:Gem::Version
|
80
|
+
hash: 3
|
81
|
+
segments:
|
82
|
+
- 0
|
62
83
|
version: "0"
|
63
|
-
version:
|
64
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
65
86
|
requirements:
|
66
87
|
- - ">="
|
67
88
|
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 0
|
68
92
|
version: "0"
|
69
|
-
version:
|
70
93
|
requirements: []
|
71
94
|
|
72
95
|
rubyforge_project:
|
73
|
-
rubygems_version: 1.3.
|
96
|
+
rubygems_version: 1.3.7
|
74
97
|
signing_key:
|
75
98
|
specification_version: 3
|
76
99
|
summary: Executes a shell command every time file/folder changes
|