sass 3.2.0.alpha.102 → 3.2.0.alpha.103
Sign up to get free protection for your applications and to get access to all the features.
- data/REVISION +1 -1
- data/VERSION +1 -1
- metadata +5 -41
- data/vendor/fssm/Gemfile +0 -3
- data/vendor/fssm/LICENSE +0 -20
- data/vendor/fssm/README.markdown +0 -83
- data/vendor/fssm/Rakefile +0 -11
- data/vendor/fssm/example.rb +0 -12
- data/vendor/fssm/ext/rakefile.rb +0 -14
- data/vendor/fssm/fssm.gemspec +0 -27
- data/vendor/fssm/lib/fssm.rb +0 -74
- data/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
- data/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
- data/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
- data/vendor/fssm/lib/fssm/backends/rbfsevent.rb +0 -42
- data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
- data/vendor/fssm/lib/fssm/monitor.rb +0 -36
- data/vendor/fssm/lib/fssm/path.rb +0 -94
- data/vendor/fssm/lib/fssm/pathname.rb +0 -36
- data/vendor/fssm/lib/fssm/state/directory.rb +0 -75
- data/vendor/fssm/lib/fssm/state/file.rb +0 -24
- data/vendor/fssm/lib/fssm/support.rb +0 -87
- data/vendor/fssm/lib/fssm/tree.rb +0 -176
- data/vendor/fssm/lib/fssm/version.rb +0 -3
- data/vendor/fssm/profile/prof-cache.rb +0 -40
- data/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
- data/vendor/fssm/profile/prof-pathname-rubinius.rb +0 -35
- data/vendor/fssm/profile/prof-pathname.rb +0 -68
- data/vendor/fssm/profile/prof-plain-pathname.html +0 -988
- data/vendor/fssm/profile/prof.html +0 -2379
- data/vendor/fssm/spec/count_down_latch.rb +0 -151
- data/vendor/fssm/spec/monitor_spec.rb +0 -202
- data/vendor/fssm/spec/path_spec.rb +0 -96
- data/vendor/fssm/spec/root/duck/quack.txt +0 -0
- data/vendor/fssm/spec/root/file.css +0 -0
- data/vendor/fssm/spec/root/file.rb +0 -0
- data/vendor/fssm/spec/root/file.yml +0 -0
- data/vendor/fssm/spec/root/moo/cow.txt +0 -0
- data/vendor/fssm/spec/spec_helper.rb +0 -14
@@ -1,42 +0,0 @@
|
|
1
|
-
module FSSM::Backends
|
2
|
-
class RBFSEvent
|
3
|
-
def initialize
|
4
|
-
@handlers = []
|
5
|
-
end
|
6
|
-
|
7
|
-
def add_handler(handler, preload=true)
|
8
|
-
@handlers << handler
|
9
|
-
handler.refresh(nil, true) if preload
|
10
|
-
end
|
11
|
-
|
12
|
-
def run
|
13
|
-
begin
|
14
|
-
@fsevent = FSEvent.new
|
15
|
-
@fsevent.watch(temporary_multipath_hack) do |paths|
|
16
|
-
paths.each do |path|
|
17
|
-
temporary_multipath_handler(path)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
@fsevent.run
|
21
|
-
rescue Interrupt
|
22
|
-
@fsevent.stop
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def temporary_multipath_handler(path)
|
27
|
-
@handlers.each do |handler|
|
28
|
-
handler_path = File.join(handler.path.to_s, "")
|
29
|
-
if path.start_with?(handler_path)
|
30
|
-
handler.refresh(path)
|
31
|
-
break
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def temporary_multipath_hack
|
37
|
-
@handlers = @handlers.sort {|x,y| y.path.to_pathname.segments.length <=> x.path.to_pathname.segments.length}
|
38
|
-
return @handlers.map {|handler| handler.path.to_s}
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
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
|
@@ -1,36 +0,0 @@
|
|
1
|
-
class FSSM::Monitor
|
2
|
-
def initialize(options={})
|
3
|
-
@options = options
|
4
|
-
@backend = FSSM::Backends::Default.new
|
5
|
-
end
|
6
|
-
|
7
|
-
def path(path=nil, glob=nil, &block)
|
8
|
-
path = create_path(path, glob, &block)
|
9
|
-
@backend.add_handler(FSSM::State::Directory.new(path, @options))
|
10
|
-
path
|
11
|
-
rescue FSSM::FileNotRealError => e
|
12
|
-
FSSM.dbg("#{e}")
|
13
|
-
nil
|
14
|
-
end
|
15
|
-
|
16
|
-
def file(path=nil, glob=nil, &block)
|
17
|
-
path = create_path(path, glob, &block)
|
18
|
-
@backend.add_handler(FSSM::State::File.new(path))
|
19
|
-
path
|
20
|
-
rescue FSSM::FileNotRealError => e
|
21
|
-
FSSM.dbg("#{e}")
|
22
|
-
nil
|
23
|
-
end
|
24
|
-
|
25
|
-
def run
|
26
|
-
@backend.run
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def create_path(path, glob, &block)
|
32
|
-
path = FSSM::Path.new(path, glob, @options)
|
33
|
-
FSSM::Support.use_block(path, block)
|
34
|
-
path
|
35
|
-
end
|
36
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
class FSSM::Path
|
2
|
-
def initialize(path=nil, glob=nil, options={}, &block)
|
3
|
-
@options = options
|
4
|
-
set_path(path || '.')
|
5
|
-
set_glob(glob || '**/*')
|
6
|
-
init_callbacks
|
7
|
-
|
8
|
-
if block_given?
|
9
|
-
if block.arity == 1
|
10
|
-
block.call(self)
|
11
|
-
else
|
12
|
-
self.instance_eval(&block)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def to_s
|
18
|
-
@path.to_s
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_pathname
|
22
|
-
@path
|
23
|
-
end
|
24
|
-
|
25
|
-
def glob(value=nil)
|
26
|
-
return @glob if value.nil?
|
27
|
-
set_glob(value)
|
28
|
-
end
|
29
|
-
|
30
|
-
def create(*args, &block)
|
31
|
-
callback_action(:create, (block_given? ? block : args))
|
32
|
-
end
|
33
|
-
|
34
|
-
def update(*args, &block)
|
35
|
-
callback_action(:update, (block_given? ? block : args))
|
36
|
-
end
|
37
|
-
|
38
|
-
def delete(*args, &block)
|
39
|
-
callback_action(:delete, (block_given? ? block : args))
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def init_callbacks
|
45
|
-
do_nothing = lambda { |base, relative|}
|
46
|
-
@callbacks = Hash.new(do_nothing)
|
47
|
-
end
|
48
|
-
|
49
|
-
def callback_action(type, args=[])
|
50
|
-
if args.is_a?(Proc)
|
51
|
-
set_callback(type, args)
|
52
|
-
elsif args.empty?
|
53
|
-
get_callback(type)
|
54
|
-
else
|
55
|
-
run_callback(type, args)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def set_callback(type, arg)
|
60
|
-
raise ArgumentError, "Proc expected" unless arg.is_a?(Proc)
|
61
|
-
@callbacks[type] = arg
|
62
|
-
end
|
63
|
-
|
64
|
-
def get_callback(type)
|
65
|
-
@callbacks[type]
|
66
|
-
end
|
67
|
-
|
68
|
-
def run_callback(type, args)
|
69
|
-
callback_args = split_path(args[0])
|
70
|
-
callback_args << args[1] if @options[:directories]
|
71
|
-
|
72
|
-
begin
|
73
|
-
@callbacks[type].call(*callback_args)
|
74
|
-
rescue Exception => e
|
75
|
-
raise FSSM::CallbackError, "#{type} - #{args[0]}: #{e.message}", e.backtrace
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def split_path(path)
|
80
|
-
path = FSSM::Pathname.for(path)
|
81
|
-
[@path.to_s, (path.relative? ? path : path.relative_path_from(@path)).to_s]
|
82
|
-
end
|
83
|
-
|
84
|
-
def set_path(path)
|
85
|
-
@path = FSSM::Pathname.for(path).expand_path
|
86
|
-
raise FSSM::FileNotFoundError, "No such file or directory - #{@path}" unless @path.exist?
|
87
|
-
raise FSSM::FileNotRealError, "Path is virtual - #{@path}" if @path.is_virtual?
|
88
|
-
@path = @path.realpath
|
89
|
-
end
|
90
|
-
|
91
|
-
def set_glob(glob)
|
92
|
-
@glob = glob.is_a?(Array) ? glob : [glob]
|
93
|
-
end
|
94
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'find'
|
3
|
-
require 'pathname'
|
4
|
-
|
5
|
-
module FSSM
|
6
|
-
class Pathname < ::Pathname
|
7
|
-
VIRTUAL_REGEX = /^file:([^!]*)!/
|
8
|
-
|
9
|
-
class << self
|
10
|
-
def for(path)
|
11
|
-
path.is_a?(::FSSM::Pathname) ? path : new(path)
|
12
|
-
end
|
13
|
-
|
14
|
-
alias :[] :glob
|
15
|
-
end
|
16
|
-
|
17
|
-
def is_virtual?
|
18
|
-
!!(VIRTUAL_REGEX =~ to_s)
|
19
|
-
end
|
20
|
-
|
21
|
-
def segments
|
22
|
-
path = to_s
|
23
|
-
array = path.split(File::SEPARATOR)
|
24
|
-
array.delete('')
|
25
|
-
array.insert(0, File::SEPARATOR) if path[0, 1] == File::SEPARATOR
|
26
|
-
array[0] += File::SEPARATOR if path[0, 3] =~ SEPARATOR_PAT
|
27
|
-
array
|
28
|
-
end
|
29
|
-
|
30
|
-
def glob(pattern, flags = 0, &block)
|
31
|
-
patterns = [pattern].flatten
|
32
|
-
patterns.map! { |p| self.class.glob(to_s + p, flags, &block) }
|
33
|
-
patterns.flatten
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
module FSSM::State
|
2
|
-
class Directory
|
3
|
-
attr_reader :path
|
4
|
-
|
5
|
-
def initialize(path, options={})
|
6
|
-
@path = path
|
7
|
-
@options = options
|
8
|
-
@cache = FSSM::Tree::Cache.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def refresh(base=nil, skip_callbacks=false)
|
12
|
-
base_path = FSSM::Pathname.for(base || @path.to_pathname).expand_path
|
13
|
-
previous, current = recache(base_path)
|
14
|
-
|
15
|
-
unless skip_callbacks
|
16
|
-
deleted(previous, current)
|
17
|
-
created(previous, current)
|
18
|
-
modified(previous, current)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def created(previous, current)
|
25
|
-
(current.keys - previous.keys).sort.each do |file|
|
26
|
-
@path.create(file, current[file][1])
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def deleted(previous, current)
|
31
|
-
(previous.keys - current.keys).sort.reverse.each do |file|
|
32
|
-
@path.delete(file, previous[file][1])
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def modified(previous, current)
|
37
|
-
(current.keys & previous.keys).each do |file|
|
38
|
-
current_data = current[file]
|
39
|
-
@path.update(file, current_data[1]) if (current_data[0] <=> previous[file][0]) != 0
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def recache(base)
|
44
|
-
base = FSSM::Pathname.for(base)
|
45
|
-
previous = cache_entries
|
46
|
-
snapshot(base)
|
47
|
-
current = cache_entries
|
48
|
-
[previous, current]
|
49
|
-
end
|
50
|
-
|
51
|
-
def snapshot(base)
|
52
|
-
base = FSSM::Pathname.for(base)
|
53
|
-
@cache.unset(base)
|
54
|
-
@path.glob.each { |glob| add_glob(base, glob) }
|
55
|
-
end
|
56
|
-
|
57
|
-
def add_glob(base, glob)
|
58
|
-
FSSM::Pathname.glob(base.join(glob).to_s).each do |fn|
|
59
|
-
@cache.set(fn)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def cache_entries
|
64
|
-
entries = tag_entries(@cache.files, :file)
|
65
|
-
entries.merge! tag_entries(@cache.directories, :directory) if @options[:directories]
|
66
|
-
entries
|
67
|
-
end
|
68
|
-
|
69
|
-
def tag_entries(entries, tag)
|
70
|
-
tagged_entries = {}
|
71
|
-
entries.each_pair { |fname, mtime| tagged_entries[fname] = [mtime, tag] }
|
72
|
-
tagged_entries
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module FSSM::State
|
2
|
-
class File
|
3
|
-
attr_reader :path
|
4
|
-
|
5
|
-
def initialize(path)
|
6
|
-
@path = path
|
7
|
-
end
|
8
|
-
|
9
|
-
def refresh(base=nil, skip_callbacks=false)
|
10
|
-
base ||= @path.to_pathname
|
11
|
-
used_to_exist, @exists = @exists, base.exist?
|
12
|
-
# this handles bad symlinks without failing. why handle bad symlinks at
|
13
|
-
# all? well, we could still be interested in their creation and deletion.
|
14
|
-
old_mtime, @mtime = @mtime, base.symlink? ? Time.at(0) : base.mtime if @exists
|
15
|
-
|
16
|
-
unless skip_callbacks
|
17
|
-
@path.delete(@path.to_s) if used_to_exist && !@exists
|
18
|
-
@path.create(@path.to_s) if !used_to_exist && @exists
|
19
|
-
@path.update(@path.to_s) if used_to_exist && @exists && old_mtime != @mtime
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|