rb-fsevent 0.9.3 → 0.9.4

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.
@@ -18,3 +18,8 @@ FSEventStreamEventFlags kFSEventStreamEventFlagItemIsFile = 0x00010000
18
18
  FSEventStreamEventFlags kFSEventStreamEventFlagItemIsDir = 0x00020000;
19
19
  FSEventStreamEventFlags kFSEventStreamEventFlagItemIsSymlink = 0x00040000;
20
20
  #endif
21
+
22
+ #if MAC_OS_X_VERSION_MAX_ALLOWED < 1090
23
+ FSEventStreamCreateFlags kFSEventStreamCreateFlagMarkSelf = 0x00000020;
24
+ FSEventStreamEventFlags kFSEventStreamEventFlagOwnEvent = 0x00080000;
25
+ #endif
@@ -37,4 +37,11 @@ extern FSEventStreamEventFlags kFSEventStreamEventFlagItemCreated,
37
37
  kFSEventStreamEventFlagItemIsSymlink;
38
38
  #endif
39
39
 
40
+ #if MAC_OS_X_VERSION_MAX_ALLOWED < 1090
41
+ // marking, rather than ignoring, events originating from the current process introduced in 10.9
42
+ extern FSEventStreamCreateFlags kFSEventStreamCreateFlagMarkSelf;
43
+ extern FSEventStreamEventFlags kFSEventStreamEventFlagOwnEvent;
44
+ #endif
45
+
46
+
40
47
  #endif // fsevent_watch_compat_h
@@ -234,6 +234,15 @@ static inline void parse_cli_settings(int argc, const char* argv[])
234
234
  }
235
235
  }
236
236
 
237
+ if (args_info.mark_self_flag) {
238
+ if ((osMajorVersion == 10) & (osMinorVersion >= 9)) {
239
+ config.flags |= kFSEventStreamCreateFlagMarkSelf;
240
+ } else {
241
+ fprintf(stderr, "MacOSX 10.9 or later required for --mark-self\n");
242
+ exit(EXIT_FAILURE);
243
+ }
244
+ }
245
+
237
246
  if (args_info.inputs_num == 0) {
238
247
  append_path(".");
239
248
  } else {
@@ -451,35 +460,6 @@ static void callback(__attribute__((unused)) FSEventStreamRef streamRef,
451
460
 
452
461
  int main(int argc, const char* argv[])
453
462
  {
454
- /*
455
- * a subprocess will initially inherit the process group of its parent. the
456
- * process group may have a control terminal associated with it, which would
457
- * be the first tty device opened by the group leader. typically the group
458
- * leader is your shell and the control terminal is your login device. a
459
- * subset of signals triggered on the control terminal are sent to all members
460
- * of the process group, in large part to facilitate sane and consistent
461
- * cleanup (ex: control terminal was closed).
462
- *
463
- * so why the overly descriptive lecture style comment?
464
- * 1. SIGINT and SIGQUIT are among the signals with this behavior
465
- * 2. a number of applications gank the above for their own use
466
- * 3. ruby's insanely useful "guard" is one of these applications
467
- * 4. despite having some level of understanding of POSIX signals and a few
468
- * of the scenarios that might cause problems, i learned this one only
469
- * after reading ruby 1.9's process.c
470
- * 5. if left completely undocumented, even slightly obscure bugfixes
471
- * may be removed as cruft by a future maintainer
472
- *
473
- * hindsight is 20/20 addition: if you're single-threaded and blocking on IO
474
- * with a subprocess, then handlers for deferrable signals might not get run
475
- * when you expect them to. In the case of Ruby 1.8, that means making use of
476
- * IO::select, which will preserve correct signal handling behavior.
477
- */
478
- if (setpgid(0,0) < 0) {
479
- fprintf(stderr, "Unable to set new process group.\n");
480
- return 1;
481
- }
482
-
483
463
  parse_cli_settings(argc, argv);
484
464
 
485
465
  FSEventStreamContext context = {0, NULL, NULL, NULL, NULL};
@@ -1,13 +1,14 @@
1
+ # -*- encoding: utf-8 -*-
1
2
  require 'rubygems' unless defined?(Gem)
2
3
  require 'pathname'
3
4
  require 'date'
4
5
  require 'time'
5
-
6
+ require 'rake/clean'
6
7
 
7
8
  raise "unable to find xcodebuild" unless system('which', 'xcodebuild')
8
9
 
9
- FSEVENT_WATCH_EXE_VERSION = '0.1.3'
10
10
 
11
+ FSEVENT_WATCH_EXE_VERSION = '0.1.3'
11
12
 
12
13
  $this_dir = Pathname.new(__FILE__).dirname.expand_path
13
14
  $final_exe = $this_dir.parent.join('bin/fsevent_watch')
@@ -18,21 +19,30 @@ $obj_dir = $this_dir.join('build')
18
19
  SRC = Pathname.glob("#{$src_dir}/*.c")
19
20
  OBJ = SRC.map {|s| $obj_dir.join("#{s.basename('.c')}.o")}
20
21
 
21
-
22
22
  $now = DateTime.now.xmlschema rescue Time.now.xmlschema
23
23
 
24
24
  $CC = ENV['CC'] || `which clang || which gcc`.strip
25
- $CFLAGS = ENV['CFLAGS'] || '-fconstant-cfstrings -fstrict-aliasing -funroll-loops'
25
+ $CFLAGS = ENV['CFLAGS'] || '-fconstant-cfstrings -fno-strict-aliasing -Wall'
26
26
  $ARCHFLAGS = ENV['ARCHFLAGS'] || '-arch x86_64 -arch i386'
27
27
  $DEFINES = "-DNS_BUILD_32_LIKE_64 -DNS_BLOCK_ASSERTIONS -DOS_OBJECT_USE_OBJC=0 -DPROJECT_VERSION=#{FSEVENT_WATCH_EXE_VERSION}"
28
28
 
29
- $GCC_C_LANGUAGE_STANDARD = 'gnu99'
29
+ $GCC_C_LANGUAGE_STANDARD = ENV['GCC_C_LANGUAGE_STANDARD'] || 'gnu99'
30
+
31
+ # generic developer id name so it'll match correctly for anyone who has only
32
+ # one developer id in their keychain (not that I expect anyone else to bother)
30
33
  $CODE_SIGN_IDENTITY = 'Developer ID Application'
31
34
 
32
35
  $arch = `uname -m`.strip
33
36
  $os_release = `uname -r`.strip
34
37
  $BUILD_TRIPLE = "#{$arch}-apple-darwin#{$os_release}"
35
38
 
39
+ $CCVersion = `#{$CC} --version | head -n 1`.strip
40
+
41
+
42
+ CLEAN.include OBJ.map(&:to_s)
43
+ CLEAN.include $obj_dir.join('Info.plist').to_s
44
+ CLEAN.include $obj_dir.join('fsevent_watch').to_s
45
+ CLOBBER.include $final_exe.to_s
36
46
 
37
47
 
38
48
  task :sw_vers do
@@ -112,49 +122,73 @@ SRC.zip(OBJ).each do |source, object|
112
122
  end
113
123
  end
114
124
 
115
- desc 'generate an Info.plist used for code signing as well as embedding build settings into the resulting binary'
116
125
  file $obj_dir.join('Info.plist').to_s => [$obj_dir.to_s, :setup_env] do
117
126
  File.open($obj_dir.join('Info.plist').to_s, 'w+') do |file|
118
- file << '<?xml version="1.0" encoding="UTF-8"?>'
119
- file << '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">'
120
- file << '<plist version="1.0">'
121
- file << '<dict>'
122
-
123
- file << '<key>CFBundleExecutable</key>'
124
- file << '<string>fsevent_watch</string>'
125
- file << '<key>CFBundleIdentifier</key>'
126
- file << '<string>com.teaspoonofinsanity.fsevent_watch</string>'
127
- file << '<key>CFBundleName</key>'
128
- file << '<string>fsevent_watch</string>'
129
-
130
- file << '<key>CFBundleVersion</key>'
131
- file << "<string>#{FSEVENT_WATCH_EXE_VERSION}</string>"
132
- file << '<key>LSMinimumSystemVersion</key>'
133
- file << "<string>#{$MACOSX_DEPLOYMENT_TARGET}</string>"
134
- file << '<key>DTSDKBuild</key>'
135
- file << "<string>#{$SDK_INFO['ProductBuildVersion']}</string>"
136
- file << '<key>DTSDKName</key>'
137
- file << "<string>macosx#{$SDK_INFO['SDKVersion']}</string>"
138
- file << '<key>BuildMachineOSBuild</key>'
139
- file << "<string>#{$mac_build_version}</string>"
140
- file << '<key>BuildMachineOSVersion</key>'
141
- file << "<string>#{$mac_product_version}</string>"
142
- file << '<key>FSEWCompiledAt</key>'
143
- file << "<string>#{$now}</string>"
144
- file << '<key>FSEWVersionInfoBuilder</key>'
145
- file << "<string>#{`whoami`.strip}</string>"
146
- file << '<key>FSEWBuildTriple</key>'
147
- file << "<string>#{$BUILD_TRIPLE}</string>"
148
- file << '<key>FSEWCC</key>'
149
- file << "<string>#{$CC}</string>"
150
- file << '<key>FSEWCFLAGS</key>'
151
- file << "<string>#{$CFLAGS}</string>"
152
-
153
- file << '</dict>'
154
- file << '</plist>'
127
+ indentation = ''
128
+ indent = lambda {|num| indentation = ' ' * num }
129
+ add = lambda {|str| file << "#{indentation}#{str}\n" }
130
+ key = lambda {|str| add["<key>#{str}</key>"] }
131
+ string = lambda {|str| add["<string>#{str}</string>"] }
132
+
133
+
134
+ add['<?xml version="1.0" encoding="UTF-8"?>']
135
+ add['<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">']
136
+ add['<plist version="1.0">']
137
+
138
+ indent[2]
139
+ add['<dict>']
140
+ indent[4]
141
+
142
+ key['CFBundleExecutable']
143
+ string['fsevent_watch']
144
+ key['CFBundleIdentifier']
145
+ string['com.teaspoonofinsanity.fsevent_watch']
146
+ key['CFBundleName']
147
+ string['fsevent_watch']
148
+ key['CFBundleDisplayName']
149
+ string['FSEvent Watch CLI']
150
+ key['NSHumanReadableCopyright']
151
+ string['Copyright (C) 2011-2013 Travis Tilley']
152
+
153
+ key['CFBundleVersion']
154
+ string["#{FSEVENT_WATCH_EXE_VERSION}"]
155
+ key['LSMinimumSystemVersion']
156
+ string["#{$MACOSX_DEPLOYMENT_TARGET}"]
157
+ key['DTSDKBuild']
158
+ string["#{$SDK_INFO['ProductBuildVersion']}"]
159
+ key['DTSDKName']
160
+ string["macosx#{$SDK_INFO['SDKVersion']}"]
161
+ key['DTSDKPath']
162
+ string["#{$SDK_INFO['Path']}"]
163
+ key['BuildMachineOSBuild']
164
+ string["#{$mac_build_version}"]
165
+ key['BuildMachineOSVersion']
166
+ string["#{$mac_product_version}"]
167
+ key['FSEWCompiledAt']
168
+ string["#{$now}"]
169
+ key['FSEWVersionInfoBuilder']
170
+ string["#{`whoami`.strip}"]
171
+ key['FSEWBuildTriple']
172
+ string["#{$BUILD_TRIPLE}"]
173
+ key['FSEWCC']
174
+ string["#{$CC}"]
175
+ key['FSEWCCVersion']
176
+ string["#{$CCVersion}"]
177
+ key['FSEWCFLAGS']
178
+ string["#{$CFLAGS}"]
179
+
180
+ indent[2]
181
+ add['</dict>']
182
+ indent[0]
183
+
184
+ add['</plist>']
155
185
  end
156
186
  end
157
187
 
188
+ desc 'generate an Info.plist used for code signing as well as embedding build settings into the resulting binary'
189
+ task :plist => $obj_dir.join('Info.plist').to_s
190
+
191
+
158
192
  file $obj_dir.join('fsevent_watch').to_s => [$obj_dir.to_s, $obj_dir.join('Info.plist').to_s] + OBJ.map(&:to_s) do
159
193
  cmd = [
160
194
  $CC,
@@ -187,5 +221,5 @@ task :replace_exe => :build do
187
221
  sh "mv #{$obj_dir.join('fsevent_watch')} #{$final_exe}"
188
222
  end
189
223
 
190
- task :default => :replace_exe
224
+ task :default => [:replace_exe, :clean]
191
225
 
@@ -1,2 +1,3 @@
1
+ # -*- encoding: utf-8 -*-
1
2
  require 'rb-fsevent/fsevent'
2
- require 'rb-fsevent/version'
3
+ require 'rb-fsevent/version'
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  class FSEvent
2
4
  class << self
3
5
  class_eval <<-END
@@ -104,6 +106,7 @@ class FSEvent
104
106
  opts.concat(['--latency', options[:latency]]) if options[:latency]
105
107
  opts.push('--no-defer') if options[:no_defer]
106
108
  opts.push('--watch-root') if options[:watch_root]
109
+ opts.push('--file-events') if options[:file_events]
107
110
  # ruby 1.9's IO.popen(array-of-stuff) syntax requires all items to be strings
108
111
  opts.map {|opt| "#{opt}"}
109
112
  end
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  class FSEvent
2
- VERSION = "0.9.3"
4
+ VERSION = '0.9.4'
3
5
  end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "rb-fsevent/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'rb-fsevent'
8
+ s.version = FSEvent::VERSION
9
+ s.authors = ['Thibaud Guillaume-Gentil', 'Travis Tilley']
10
+ s.email = ['thibaud@thibaud.gg', 'ttilley@gmail.com']
11
+ s.homepage = 'http://rubygems.org/gems/rb-fsevent'
12
+ s.summary = 'Very simple & usable FSEvents API'
13
+ s.description = 'FSEvents API with Signals catching (without RubyCocoa)'
14
+ s.license = 'MIT'
15
+
16
+ s.files = `git ls-files`.split($/)
17
+ s.test_files = s.files.grep(%r{^spec/})
18
+ s.require_path = 'lib'
19
+
20
+ s.add_development_dependency 'bundler', '~> 1.0'
21
+ s.add_development_dependency 'rspec', '~> 2.11'
22
+ s.add_development_dependency 'guard-rspec', '~> 4.2'
23
+ end
24
+
File without changes
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe FSEvent do
4
+
5
+ before(:each) do
6
+ @results = []
7
+ @fsevent = FSEvent.new
8
+ @fsevent.watch @fixture_path.to_s, {:latency => 0.5} do |paths|
9
+ @results += paths
10
+ end
11
+ end
12
+
13
+ it "shouldn't pass anything to watch when instantiated without a path" do
14
+ fsevent = FSEvent.new
15
+ fsevent.paths.should be_nil
16
+ fsevent.callback.should be_nil
17
+ end
18
+
19
+ it "should pass path and block to watch when instantiated with them" do
20
+ blk = proc { }
21
+ fsevent = FSEvent.new(@fixture_path, &blk)
22
+ fsevent.paths.should == [@fixture_path]
23
+ fsevent.callback.should == blk
24
+ end
25
+
26
+ it "should have a watcher_path that resolves to an executable file" do
27
+ File.exists?(FSEvent.watcher_path).should be_true
28
+ File.executable?(FSEvent.watcher_path).should be_true
29
+ end
30
+
31
+ it "should work with path with an apostrophe" do
32
+ custom_path = @fixture_path.join("custom 'path")
33
+ file = custom_path.join("newfile.rb").to_s
34
+ File.delete file if File.exists? file
35
+ @fsevent.watch custom_path.to_s do |paths|
36
+ @results += paths
37
+ end
38
+ @fsevent.paths.should == ["#{custom_path}"]
39
+ run
40
+ FileUtils.touch file
41
+ stop
42
+ File.delete file
43
+ @results.should == [custom_path.to_s + '/']
44
+ end
45
+
46
+ it "should catch new file" do
47
+ file = @fixture_path.join("newfile.rb")
48
+ File.delete file if File.exists? file
49
+ run
50
+ FileUtils.touch file
51
+ stop
52
+ File.delete file
53
+ @results.should == [@fixture_path.to_s + '/']
54
+ end
55
+
56
+ it "should catch file update" do
57
+ file = @fixture_path.join("folder1/file1.txt")
58
+ File.exists?(file).should be_true
59
+ run
60
+ FileUtils.touch file
61
+ stop
62
+ @results.should == [@fixture_path.join("folder1/").to_s]
63
+ end
64
+
65
+ it "should catch files update" do
66
+ file1 = @fixture_path.join("folder1/file1.txt")
67
+ file2 = @fixture_path.join("folder1/folder2/file2.txt")
68
+ File.exists?(file1).should be_true
69
+ File.exists?(file2).should be_true
70
+ run
71
+ FileUtils.touch file1
72
+ FileUtils.touch file2
73
+ stop
74
+ @results.should == [@fixture_path.join("folder1/").to_s, @fixture_path.join("folder1/folder2/").to_s]
75
+ end
76
+
77
+ def run
78
+ sleep 1
79
+ Thread.new { @fsevent.run }
80
+ sleep 1
81
+ end
82
+
83
+ def stop
84
+ sleep 1
85
+ @fsevent.stop
86
+ end
87
+
88
+ end
@@ -0,0 +1,23 @@
1
+ require 'rspec'
2
+ require 'rb-fsevent'
3
+
4
+ RSpec.configure do |config|
5
+ config.color_enabled = true
6
+ config.filter_run :focus => true
7
+ config.run_all_when_everything_filtered = true
8
+
9
+ config.before(:each) do
10
+ @fixture_path = Pathname.new(File.expand_path('../fixtures/', __FILE__))
11
+ end
12
+
13
+ config.before(:all) do
14
+ system "cd ext; rake"
15
+ puts "fsevent_watch compiled"
16
+ end
17
+
18
+ config.after(:all) do
19
+ gem_root = Pathname.new(File.expand_path('../../', __FILE__))
20
+ system "rm -rf #{gem_root.join('bin')}"
21
+ end
22
+
23
+ end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb-fsevent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
5
- prerelease:
4
+ version: 0.9.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Thibaud Guillaume-Gentil
@@ -10,68 +9,66 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2012-12-31 00:00:00.000000000 Z
12
+ date: 2013-12-30 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
- prerelease: false
15
+ name: bundler
17
16
  requirement: !ruby/object:Gem::Requirement
18
17
  requirements:
19
- - - ~>
18
+ - - "~>"
20
19
  - !ruby/object:Gem::Version
21
20
  version: '1.0'
22
- none: false
23
21
  type: :development
22
+ prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
24
  requirements:
26
- - - ~>
25
+ - - "~>"
27
26
  - !ruby/object:Gem::Version
28
27
  version: '1.0'
29
- none: false
30
- name: bundler
31
28
  - !ruby/object:Gem::Dependency
32
- prerelease: false
29
+ name: rspec
33
30
  requirement: !ruby/object:Gem::Requirement
34
31
  requirements:
35
- - - ~>
32
+ - - "~>"
36
33
  - !ruby/object:Gem::Version
37
34
  version: '2.11'
38
- none: false
39
35
  type: :development
36
+ prerelease: false
40
37
  version_requirements: !ruby/object:Gem::Requirement
41
38
  requirements:
42
- - - ~>
39
+ - - "~>"
43
40
  - !ruby/object:Gem::Version
44
41
  version: '2.11'
45
- none: false
46
- name: rspec
47
42
  - !ruby/object:Gem::Dependency
48
- prerelease: false
43
+ name: guard-rspec
49
44
  requirement: !ruby/object:Gem::Requirement
50
45
  requirements:
51
- - - ~>
46
+ - - "~>"
52
47
  - !ruby/object:Gem::Version
53
- version: '1.2'
54
- none: false
48
+ version: '4.2'
55
49
  type: :development
50
+ prerelease: false
56
51
  version_requirements: !ruby/object:Gem::Requirement
57
52
  requirements:
58
- - - ~>
53
+ - - "~>"
59
54
  - !ruby/object:Gem::Version
60
- version: '1.2'
61
- none: false
62
- name: guard-rspec
55
+ version: '4.2'
63
56
  description: FSEvents API with Signals catching (without RubyCocoa)
64
57
  email:
65
- - thibaud@thibaud.me
58
+ - thibaud@thibaud.gg
66
59
  - ttilley@gmail.com
67
60
  executables: []
68
61
  extensions: []
69
62
  extra_rdoc_files: []
70
63
  files:
64
+ - ".gitignore"
65
+ - Gemfile
66
+ - Guardfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
71
70
  - bin/fsevent_watch
72
- - lib/rb-fsevent/fsevent.rb
73
- - lib/rb-fsevent/version.rb
74
- - lib/rb-fsevent.rb
71
+ - bin/fsevent_watch_10_5
75
72
  - ext/LICENSE
76
73
  - ext/fsevent_watch/TSICTString.c
77
74
  - ext/fsevent_watch/TSICTString.h
@@ -83,31 +80,42 @@ files:
83
80
  - ext/fsevent_watch/defines.h
84
81
  - ext/fsevent_watch/main.c
85
82
  - ext/rakefile.rb
86
- - LICENSE
87
- - README.rdoc
83
+ - lib/rb-fsevent.rb
84
+ - lib/rb-fsevent/fsevent.rb
85
+ - lib/rb-fsevent/version.rb
86
+ - rb-fsevent.gemspec
87
+ - spec/fixtures/custom 'path/.gitignore
88
+ - spec/fixtures/folder1/file1.txt
89
+ - spec/fixtures/folder1/folder2/file2.txt
90
+ - spec/rb-fsevent/fsevent_spec.rb
91
+ - spec/spec_helper.rb
88
92
  homepage: http://rubygems.org/gems/rb-fsevent
89
- licenses: []
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
90
96
  post_install_message:
91
97
  rdoc_options: []
92
98
  require_paths:
93
99
  - lib
94
100
  required_ruby_version: !ruby/object:Gem::Requirement
95
101
  requirements:
96
- - - ! '>='
102
+ - - ">="
97
103
  - !ruby/object:Gem::Version
98
104
  version: '0'
99
- none: false
100
105
  required_rubygems_version: !ruby/object:Gem::Requirement
101
106
  requirements:
102
- - - ! '>='
107
+ - - ">="
103
108
  - !ruby/object:Gem::Version
104
109
  version: '0'
105
- none: false
106
110
  requirements: []
107
- rubyforge_project: rb-fsevent
108
- rubygems_version: 1.8.24
111
+ rubyforge_project:
112
+ rubygems_version: 2.2.0
109
113
  signing_key:
110
- specification_version: 3
114
+ specification_version: 4
111
115
  summary: Very simple & usable FSEvents API
112
- test_files: []
113
- has_rdoc:
116
+ test_files:
117
+ - spec/fixtures/custom 'path/.gitignore
118
+ - spec/fixtures/folder1/file1.txt
119
+ - spec/fixtures/folder1/folder2/file2.txt
120
+ - spec/rb-fsevent/fsevent_spec.rb
121
+ - spec/spec_helper.rb