fssm 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +26 -0
- data/VERSION.yml +3 -3
- data/example.rb +3 -0
- data/fssm.gemspec +4 -4
- data/lib/fssm.rb +1 -0
- data/lib/fssm/backends/rbfsevent.rb +26 -0
- data/lib/fssm/path.rb +1 -0
- data/lib/fssm/pathname.rb +5 -0
- data/lib/fssm/support.rb +31 -6
- metadata +65 -74
data/README.markdown
CHANGED
@@ -53,3 +53,29 @@ This form doesn't enter the run loop automatically.
|
|
53
53
|
end
|
54
54
|
|
55
55
|
monitor.run
|
56
|
+
|
57
|
+
Monitoring directories
|
58
|
+
----------------------
|
59
|
+
|
60
|
+
By default, FSSM monitors changes in files only. To enable monitoring of files and directories, pass option `directories => true` in a hash to the monitor. For example:
|
61
|
+
|
62
|
+
FSSM::Monitor.new(:directories => true)
|
63
|
+
FSSM.monitor(dir, file_glob, :directories => true)
|
64
|
+
|
65
|
+
When directories are monitored, there's an additional third argument to the callbacks. Instead of
|
66
|
+
|
67
|
+
FSSM.monitor('/some/directory/', '**/*') do
|
68
|
+
update {|base, relative|}
|
69
|
+
delete {|base, relative|}
|
70
|
+
create {|base, relative|}
|
71
|
+
end
|
72
|
+
|
73
|
+
you get this:
|
74
|
+
|
75
|
+
FSSM.monitor('/some/directory/', '**/*', :directories => true) do
|
76
|
+
update {|base, relative, type|}
|
77
|
+
delete {|base, relative, type|}
|
78
|
+
create {|base, relative, type|}
|
79
|
+
end
|
80
|
+
|
81
|
+
The value of `type` argument is either `:file` or `:directory`.
|
data/VERSION.yml
CHANGED
data/example.rb
CHANGED
data/fssm.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fssm}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Travis Tilley"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-15}
|
13
13
|
s.description = %q{file system state monitor}
|
14
14
|
s.email = %q{ttilley@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/fssm/backends/fsevents.rb",
|
29
29
|
"lib/fssm/backends/inotify.rb",
|
30
30
|
"lib/fssm/backends/polling.rb",
|
31
|
+
"lib/fssm/backends/rbfsevent.rb",
|
31
32
|
"lib/fssm/backends/rubycocoa/fsevents.rb",
|
32
33
|
"lib/fssm/monitor.rb",
|
33
34
|
"lib/fssm/path.rb",
|
@@ -54,7 +55,7 @@ Gem::Specification.new do |s|
|
|
54
55
|
]
|
55
56
|
s.homepage = %q{http://github.com/ttilley/fssm}
|
56
57
|
s.require_paths = ["lib"]
|
57
|
-
s.rubygems_version = %q{1.
|
58
|
+
s.rubygems_version = %q{1.4.2}
|
58
59
|
s.summary = %q{file system state monitor}
|
59
60
|
s.test_files = [
|
60
61
|
"spec/count_down_latch.rb",
|
@@ -65,7 +66,6 @@ Gem::Specification.new do |s|
|
|
65
66
|
]
|
66
67
|
|
67
68
|
if s.respond_to? :specification_version then
|
68
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
69
69
|
s.specification_version = 3
|
70
70
|
|
71
71
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
data/lib/fssm.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
module FSSM::Backends
|
2
|
+
class RBFSEvent
|
3
|
+
def initialize
|
4
|
+
@fsevent = FSEvent.new
|
5
|
+
end
|
6
|
+
|
7
|
+
def add_handler(handler, preload=true)
|
8
|
+
@fsevent.watch handler.path.to_s do |paths|
|
9
|
+
paths.each do |path|
|
10
|
+
handler.refresh(path)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
handler.refresh(nil, true) if preload
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
begin
|
19
|
+
@fsevent.run
|
20
|
+
rescue Interrupt
|
21
|
+
@fsevent.stop
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/fssm/path.rb
CHANGED
@@ -84,6 +84,7 @@ class FSSM::Path
|
|
84
84
|
def set_path(path)
|
85
85
|
path = FSSM::Pathname.for(path)
|
86
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?
|
87
88
|
@path = path.expand_path
|
88
89
|
end
|
89
90
|
|
data/lib/fssm/pathname.rb
CHANGED
@@ -5,6 +5,7 @@ require 'pathname'
|
|
5
5
|
module FSSM
|
6
6
|
class Pathname < ::Pathname
|
7
7
|
ROOT = '/'.freeze
|
8
|
+
VIRTUAL_REGEX = /^file:([^!]*)!/
|
8
9
|
|
9
10
|
class << self
|
10
11
|
def for(path)
|
@@ -13,6 +14,10 @@ module FSSM
|
|
13
14
|
|
14
15
|
alias :[] :glob
|
15
16
|
end
|
17
|
+
|
18
|
+
def is_virtual?
|
19
|
+
!!(VIRTUAL_REGEX =~ to_s)
|
20
|
+
end
|
16
21
|
|
17
22
|
def segments
|
18
23
|
path = to_s
|
data/lib/fssm/support.rb
CHANGED
@@ -2,15 +2,34 @@ require 'rbconfig'
|
|
2
2
|
|
3
3
|
module FSSM::Support
|
4
4
|
class << self
|
5
|
-
def
|
6
|
-
|
5
|
+
def usable_backend
|
6
|
+
choice = case
|
7
7
|
when mac? && !jruby? && carbon_core?
|
8
8
|
'FSEvents'
|
9
|
+
when mac? && rb_fsevent?
|
10
|
+
'RBFSEvent'
|
9
11
|
when linux? && rb_inotify?
|
10
12
|
'Inotify'
|
11
13
|
else
|
12
14
|
'Polling'
|
15
|
+
end
|
16
|
+
|
17
|
+
if (mac? || linux?) && choice == 'Polling'
|
18
|
+
optimal = case
|
19
|
+
when mac?
|
20
|
+
'rb-fsevent'
|
21
|
+
when linux?
|
22
|
+
'rb-inotify'
|
23
|
+
end
|
24
|
+
STDERR.puts("FSSM: An optimized backend is available for this platform!")
|
25
|
+
STDERR.puts(" gem install #{optimal}")
|
13
26
|
end
|
27
|
+
|
28
|
+
choice
|
29
|
+
end
|
30
|
+
|
31
|
+
def backend
|
32
|
+
@@backend ||= usable_backend
|
14
33
|
end
|
15
34
|
|
16
35
|
def jruby?
|
@@ -31,13 +50,21 @@ module FSSM::Support
|
|
31
50
|
OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
|
32
51
|
true
|
33
52
|
rescue LoadError
|
34
|
-
|
53
|
+
false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def rb_fsevent?
|
58
|
+
begin
|
59
|
+
require 'rb-fsevent'
|
60
|
+
true
|
61
|
+
rescue LoadError
|
35
62
|
false
|
36
63
|
end
|
37
64
|
end
|
38
65
|
|
39
66
|
def rb_inotify?
|
40
|
-
|
67
|
+
begin
|
41
68
|
require 'rb-inotify'
|
42
69
|
if defined?(INotify::VERSION)
|
43
70
|
version = INotify::VERSION
|
@@ -46,8 +73,6 @@ module FSSM::Support
|
|
46
73
|
rescue LoadError
|
47
74
|
false
|
48
75
|
end
|
49
|
-
STDERR.puts("Warning: Unable to load rb-inotify >= 0.5.1. Inotify will be unavailable.") unless found
|
50
|
-
found
|
51
76
|
end
|
52
77
|
|
53
78
|
def use_block(context, block)
|
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fssm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 3
|
9
|
-
version: 0.2.3
|
4
|
+
prerelease:
|
5
|
+
version: 0.2.4
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
|
-
- Travis Tilley
|
8
|
+
- Travis Tilley
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
13
|
+
date: 2011-01-15 00:00:00 -05:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
type: :development
|
32
|
-
version_requirements: *id001
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :development
|
26
|
+
version_requirements: *id001
|
33
27
|
description: file system state monitor
|
34
28
|
email: ttilley@gmail.com
|
35
29
|
executables: []
|
@@ -37,43 +31,44 @@ executables: []
|
|
37
31
|
extensions: []
|
38
32
|
|
39
33
|
extra_rdoc_files:
|
40
|
-
- LICENSE
|
41
|
-
- README.markdown
|
34
|
+
- LICENSE
|
35
|
+
- README.markdown
|
42
36
|
files:
|
43
|
-
- .document
|
44
|
-
- LICENSE
|
45
|
-
- README.markdown
|
46
|
-
- Rakefile
|
47
|
-
- VERSION.yml
|
48
|
-
- example.rb
|
49
|
-
- fssm.gemspec
|
50
|
-
- lib/fssm.rb
|
51
|
-
- lib/fssm/backends/fsevents.rb
|
52
|
-
- lib/fssm/backends/inotify.rb
|
53
|
-
- lib/fssm/backends/polling.rb
|
54
|
-
- lib/fssm/backends/
|
55
|
-
- lib/fssm/
|
56
|
-
- lib/fssm/
|
57
|
-
- lib/fssm/
|
58
|
-
- lib/fssm/
|
59
|
-
- lib/fssm/state/
|
60
|
-
- lib/fssm/
|
61
|
-
- lib/fssm/
|
62
|
-
-
|
63
|
-
- profile/prof-
|
64
|
-
- profile/prof-pathname
|
65
|
-
- profile/prof-pathname.rb
|
66
|
-
- profile/prof-
|
67
|
-
- profile/prof.html
|
68
|
-
-
|
69
|
-
- spec/
|
70
|
-
- spec/
|
71
|
-
- spec/
|
72
|
-
- spec/root/
|
73
|
-
- spec/root/file.
|
74
|
-
- spec/root/file.
|
75
|
-
- spec/root/
|
76
|
-
- spec/
|
37
|
+
- .document
|
38
|
+
- LICENSE
|
39
|
+
- README.markdown
|
40
|
+
- Rakefile
|
41
|
+
- VERSION.yml
|
42
|
+
- example.rb
|
43
|
+
- fssm.gemspec
|
44
|
+
- lib/fssm.rb
|
45
|
+
- lib/fssm/backends/fsevents.rb
|
46
|
+
- lib/fssm/backends/inotify.rb
|
47
|
+
- lib/fssm/backends/polling.rb
|
48
|
+
- lib/fssm/backends/rbfsevent.rb
|
49
|
+
- lib/fssm/backends/rubycocoa/fsevents.rb
|
50
|
+
- lib/fssm/monitor.rb
|
51
|
+
- lib/fssm/path.rb
|
52
|
+
- lib/fssm/pathname.rb
|
53
|
+
- lib/fssm/state/directory.rb
|
54
|
+
- lib/fssm/state/file.rb
|
55
|
+
- lib/fssm/support.rb
|
56
|
+
- lib/fssm/tree.rb
|
57
|
+
- profile/prof-cache.rb
|
58
|
+
- profile/prof-fssm-pathname.html
|
59
|
+
- profile/prof-pathname-rubinius.rb
|
60
|
+
- profile/prof-pathname.rb
|
61
|
+
- profile/prof-plain-pathname.html
|
62
|
+
- profile/prof.html
|
63
|
+
- spec/count_down_latch.rb
|
64
|
+
- spec/monitor_spec.rb
|
65
|
+
- spec/path_spec.rb
|
66
|
+
- spec/root/duck/quack.txt
|
67
|
+
- spec/root/file.css
|
68
|
+
- spec/root/file.rb
|
69
|
+
- spec/root/file.yml
|
70
|
+
- spec/root/moo/cow.txt
|
71
|
+
- spec/spec_helper.rb
|
77
72
|
has_rdoc: true
|
78
73
|
homepage: http://github.com/ttilley/fssm
|
79
74
|
licenses: []
|
@@ -82,33 +77,29 @@ post_install_message:
|
|
82
77
|
rdoc_options: []
|
83
78
|
|
84
79
|
require_paths:
|
85
|
-
- lib
|
80
|
+
- lib
|
86
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
82
|
none: false
|
88
83
|
requirements:
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
- 0
|
93
|
-
version: "0"
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: "0"
|
94
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
88
|
none: false
|
96
89
|
requirements:
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
- 0
|
101
|
-
version: "0"
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: "0"
|
102
93
|
requirements: []
|
103
94
|
|
104
95
|
rubyforge_project:
|
105
|
-
rubygems_version: 1.
|
96
|
+
rubygems_version: 1.4.2
|
106
97
|
signing_key:
|
107
98
|
specification_version: 3
|
108
99
|
summary: file system state monitor
|
109
100
|
test_files:
|
110
|
-
- spec/count_down_latch.rb
|
111
|
-
- spec/monitor_spec.rb
|
112
|
-
- spec/path_spec.rb
|
113
|
-
- spec/root/file.rb
|
114
|
-
- spec/spec_helper.rb
|
101
|
+
- spec/count_down_latch.rb
|
102
|
+
- spec/monitor_spec.rb
|
103
|
+
- spec/path_spec.rb
|
104
|
+
- spec/root/file.rb
|
105
|
+
- spec/spec_helper.rb
|