fssm 0.2.8.1 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -72,3 +72,9 @@ module FSSM
72
72
  end
73
73
 
74
74
  end
75
+
76
+ STDERR.puts "\nDear developers making use of FSSM in your projects,\n"
77
+ STDERR.puts "FSSM is essentially dead at this point. Further development will"
78
+ STDERR.puts "be taking place in the new shared guard/listen project. Please"
79
+ STDERR.puts "let us know if you need help transitioning! ^_^b\n"
80
+ STDERR.puts "- Travis Tilley\n\n"
@@ -4,8 +4,6 @@ module FSSM::Support
4
4
  class << self
5
5
  def usable_backend
6
6
  case
7
- when mac? && !lion? && !jruby? && carbon_core?
8
- 'FSEvents'
9
7
  when mac? && rb_fsevent?
10
8
  'RBFSEvent'
11
9
  when linux? && rb_inotify?
@@ -43,16 +41,6 @@ module FSSM::Support
43
41
  RbConfig::CONFIG['target_os'] =~ /linux/i
44
42
  end
45
43
 
46
- def carbon_core?
47
- begin
48
- require 'osx/foundation'
49
- OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
50
- true
51
- rescue LoadError
52
- false
53
- end
54
- end
55
-
56
44
  def rb_fsevent?
57
45
  begin
58
46
  require 'rb-fsevent'
@@ -1,3 +1,3 @@
1
1
  module FSSM
2
- VERSION = "0.2.8.1"
2
+ VERSION = "0.2.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fssm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8.1
4
+ version: 0.2.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,11 +13,11 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2012-01-06 00:00:00.000000000 Z
16
+ date: 2012-04-09 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rake
20
- requirement: &70354471147620 !ruby/object:Gem::Requirement
20
+ requirement: &70185814188200 !ruby/object:Gem::Requirement
21
21
  none: false
22
22
  requirements:
23
23
  - - ! '>='
@@ -25,10 +25,10 @@ dependencies:
25
25
  version: '0'
26
26
  type: :development
27
27
  prerelease: false
28
- version_requirements: *70354471147620
28
+ version_requirements: *70185814188200
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rspec
31
- requirement: &70354471145720 !ruby/object:Gem::Requirement
31
+ requirement: &70185814186380 !ruby/object:Gem::Requirement
32
32
  none: false
33
33
  requirements:
34
34
  - - ! '>='
@@ -36,7 +36,7 @@ dependencies:
36
36
  version: 2.4.0
37
37
  type: :development
38
38
  prerelease: false
39
- version_requirements: *70354471145720
39
+ version_requirements: *70185814186380
40
40
  description: The File System State Monitor keeps track of the state of any number
41
41
  of paths and will fire events when said state changes (create/update/delete). FSSM
42
42
  supports using FSEvents on MacOS, Inotify on GNU/Linux, and polling anywhere else.
@@ -56,11 +56,9 @@ files:
56
56
  - ext/rakefile.rb
57
57
  - fssm.gemspec
58
58
  - lib/fssm.rb
59
- - lib/fssm/backends/fsevents.rb
60
59
  - lib/fssm/backends/inotify.rb
61
60
  - lib/fssm/backends/polling.rb
62
61
  - lib/fssm/backends/rbfsevent.rb
63
- - lib/fssm/backends/rubycocoa/fsevents.rb
64
62
  - lib/fssm/monitor.rb
65
63
  - lib/fssm/path.rb
66
64
  - lib/fssm/pathname.rb
@@ -96,15 +94,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
94
  - - ! '>='
97
95
  - !ruby/object:Gem::Version
98
96
  version: '0'
97
+ segments:
98
+ - 0
99
+ hash: 2015168303275544276
99
100
  required_rubygems_version: !ruby/object:Gem::Requirement
100
101
  none: false
101
102
  requirements:
102
103
  - - ! '>='
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
106
+ segments:
107
+ - 0
108
+ hash: 2015168303275544276
105
109
  requirements: []
106
110
  rubyforge_project: fssm
107
- rubygems_version: 1.8.13
111
+ rubygems_version: 1.8.11
108
112
  signing_key:
109
113
  specification_version: 3
110
114
  summary: File System State Monitor
@@ -1,36 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'rubycocoa/fsevents')
2
-
3
- module FSSM::Backends
4
- class FSEvents
5
- def initialize
6
- @handlers = {}
7
- @fsevents = []
8
- end
9
-
10
- def add_handler(handler, preload=true)
11
- @handlers[handler.path.to_s] = handler
12
-
13
- fsevent = Rucola::FSEvents.new(handler.path.to_s, {:latency => 0.5}) do |events|
14
- events.each do |event|
15
- handler.refresh(event.path)
16
- end
17
- end
18
-
19
- fsevent.create_stream
20
- handler.refresh(nil, true) if preload
21
- fsevent.start
22
- @fsevents << fsevent
23
- end
24
-
25
- def run
26
- begin
27
- OSX.CFRunLoopRun
28
- rescue Interrupt
29
- @fsevents.each do |fsev|
30
- fsev.stop
31
- end
32
- end
33
- end
34
-
35
- end
36
- end
@@ -1,131 +0,0 @@
1
- OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
2
-
3
- module Rucola
4
- class FSEvents
5
- class FSEvent
6
- attr_reader :fsevents_object
7
- attr_reader :id
8
- attr_reader :path
9
-
10
- def initialize(fsevents_object, id, path)
11
- @fsevents_object, @id, @path = fsevents_object, id, path
12
- end
13
-
14
- # Returns an array of the files/dirs in the path that the event occurred in.
15
- # The files are sorted by the modification time, the first entry is the last modified file.
16
- def files
17
- Dir.glob("#{File.expand_path(path)}/*").sort_by { |f| File.mtime(f) }.reverse
18
- end
19
-
20
- # Returns the last modified file in the path that the event occurred in.
21
- def last_modified_file
22
- files.first
23
- end
24
- end
25
-
26
- class StreamError < StandardError;
27
- end
28
-
29
- attr_reader :paths
30
- attr_reader :stream
31
-
32
- attr_accessor :allocator
33
- attr_accessor :context
34
- attr_accessor :since
35
- attr_accessor :latency
36
- attr_accessor :flags
37
-
38
- # Initializes a new FSEvents `watchdog` object and starts watching the directories you specify for events. The
39
- # block is used as a handler for events, which are passed as the block's argument. This method is the easiest
40
- # way to start watching some directories if you don't care about the details of setting up the event stream.
41
- #
42
- # Rucola::FSEvents.start_watching('/tmp') do |events|
43
- # events.each { |event| log.debug("#{event.files.inspect} were changed.") }
44
- # end
45
- #
46
- # Rucola::FSEvents.start_watching('/var/log/system.log', '/var/log/secure.log', :since => last_id, :latency => 5) do
47
- # Growl.notify("Something was added to your log files!")
48
- # end
49
- #
50
- # Note that the method also returns the FSEvents object. This enables you to control the event stream if you want to.
51
- #
52
- # fsevents = Rucola::FSEvents.start_watching('/Volumes') do |events|
53
- # events.each { |event| Growl.notify("Volume changes: #{event.files.to_sentence}") }
54
- # end
55
- # fsevents.stop
56
- def self.start_watching(*params, &block)
57
- fsevents = new(*params, &block)
58
- fsevents.create_stream
59
- fsevents.start
60
- fsevents
61
- end
62
-
63
- # Creates a new FSEvents `watchdog` object. You can specify a list of paths to watch and options to control the
64
- # behaviour of the watchdog. The block you pass serves as a callback when an event is generated on one of the
65
- # specified paths.
66
- #
67
- # fsevents = FSEvents.new('/etc/passwd') { Mailer.send_mail("Someone touched the password file!") }
68
- # fsevents.create_stream
69
- # fsevents.start
70
- #
71
- # fsevents = FSEvents.new('/home/upload', :since => UploadWatcher.last_event_id) do |events|
72
- # events.each do |event|
73
- # UploadWatcher.last_event_id = event.id
74
- # event.files.each do |file|
75
- # UploadWatcher.logfile.append("#{file} was changed")
76
- # end
77
- # end
78
- # end
79
- #
80
- # *:since: The service will report events that have happened after the supplied event ID. Never use 0 because that
81
- # will cause every fsevent since the "beginning of time" to be reported. Use OSX::KFSEventStreamEventIdSinceNow
82
- # if you want to receive events that have happened after this call. (Default: OSX::KFSEventStreamEventIdSinceNow).
83
- # You can find the ID's passed with :since in the events passed to your block.
84
- # *:latency: Number of seconds to wait until an FSEvent is reported, this allows the service to bundle events. (Default: 0.0)
85
- #
86
- # Please refer to the Cocoa documentation for the rest of the options.
87
- def initialize(*params, &block)
88
- raise ArgumentError, 'No callback block was specified.' unless block_given?
89
-
90
- options = params.last.kind_of?(Hash) ? params.pop : {}
91
- @paths = params.flatten
92
-
93
- paths.each { |path| raise ArgumentError, "The specified path (#{path}) does not exist." unless File.exist?(path) }
94
-
95
- @allocator = options[:allocator] || OSX::KCFAllocatorDefault
96
- @context = options[:context] || nil
97
- @since = options[:since] || OSX::KFSEventStreamEventIdSinceNow
98
- @latency = options[:latency] || 0.0
99
- @flags = options[:flags] || 0
100
- @stream = options[:stream] || nil
101
-
102
- @user_callback = block
103
- @callback = Proc.new do |stream, client_callback_info, number_of_events, paths_pointer, event_flags, event_ids|
104
- paths_pointer.regard_as('*')
105
- events = []
106
- number_of_events.times { |i| events << Rucola::FSEvents::FSEvent.new(self, event_ids[i], paths_pointer[i]) }
107
- @user_callback.call(events)
108
- end
109
- end
110
-
111
- # Create the stream.
112
- # Raises a Rucola::FSEvents::StreamError if the stream could not be created.
113
- def create_stream
114
- @stream = OSX.FSEventStreamCreate(@allocator, @callback, @context, @paths, @since, @latency, @flags)
115
- raise(StreamError, 'Unable to create FSEvents stream.') unless @stream
116
- OSX.FSEventStreamScheduleWithRunLoop(@stream, OSX.CFRunLoopGetCurrent, OSX::KCFRunLoopDefaultMode)
117
- end
118
-
119
- # Start the stream.
120
- # Raises a Rucola::FSEvents::StreamError if the stream could not be started.
121
- def start
122
- raise(StreamError, 'Unable to start FSEvents stream.') unless OSX.FSEventStreamStart(@stream)
123
- end
124
-
125
- # Stop the stream.
126
- # You can resume it by calling `start` again.
127
- def stop
128
- OSX.FSEventStreamStop(@stream)
129
- end
130
- end
131
- end