fssm 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +9 -0
- data/ext/rakefile.rb +14 -0
- data/fssm.gemspec +3 -0
- data/lib/fssm.rb +57 -20
- data/lib/fssm/support.rb +20 -25
- data/lib/fssm/version.rb +1 -1
- metadata +46 -55
data/.travis.yml
ADDED
data/ext/rakefile.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'rubygems/dependency_installer'
|
5
|
+
require 'fssm'
|
6
|
+
|
7
|
+
# semi-elegant solution or hack? *shrug*
|
8
|
+
task :default do
|
9
|
+
name, version = FSSM::Support.optimal_backend_dependency
|
10
|
+
if name and version
|
11
|
+
installer = Gem::DependencyInstaller.new({:domain => :both, :env_shebang => true})
|
12
|
+
installer.install name, version
|
13
|
+
end
|
14
|
+
end
|
data/fssm.gemspec
CHANGED
@@ -19,6 +19,9 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
21
21
|
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
s.extensions = 'ext/rakefile.rb'
|
22
24
|
|
25
|
+
s.add_development_dependency "rake"
|
23
26
|
s.add_development_dependency "rspec", ">= 2.4.0"
|
24
27
|
end
|
data/lib/fssm.rb
CHANGED
@@ -1,12 +1,62 @@
|
|
1
|
-
dir = File.dirname(__FILE__)
|
1
|
+
dir = File.expand_path(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
3
3
|
|
4
|
-
|
5
|
-
module FSSM
|
6
|
-
FileNotFoundError = Class.new(StandardError)
|
7
|
-
FileNotRealError = Class.new(StandardError)
|
8
|
-
CallbackError = Class.new(StandardError)
|
4
|
+
require 'thread'
|
9
5
|
|
6
|
+
module FSSM
|
7
|
+
|
8
|
+
FSSMError = Class.new(StandardError)
|
9
|
+
FileNotFoundError = Class.new(FSSMError)
|
10
|
+
FileNotRealError = Class.new(FSSMError)
|
11
|
+
CallbackError = Class.new(FSSMError)
|
12
|
+
|
13
|
+
autoload :VERSION, 'fssm/version'
|
14
|
+
autoload :Pathname, 'fssm/pathname'
|
15
|
+
autoload :Support, 'fssm/support'
|
16
|
+
autoload :Tree, 'fssm/tree'
|
17
|
+
autoload :Path, 'fssm/path'
|
18
|
+
autoload :Monitor, 'fssm/monitor'
|
19
|
+
|
20
|
+
module State
|
21
|
+
autoload :Directory, 'fssm/state/directory'
|
22
|
+
autoload :File, 'fssm/state/file'
|
23
|
+
end
|
24
|
+
|
25
|
+
module Backends
|
26
|
+
autoload :Polling, 'fssm/backends/polling'
|
27
|
+
autoload :FSEvents, 'fssm/backends/fsevents'
|
28
|
+
autoload :RBFSEvent, 'fssm/backends/rbfsevent'
|
29
|
+
autoload :Inotify, 'fssm/backends/inotify'
|
30
|
+
|
31
|
+
class << self
|
32
|
+
def set_backend(const_symbol=nil, value=nil)
|
33
|
+
const_symbol ||= :Default
|
34
|
+
value ||= ::FSSM::Support.backend
|
35
|
+
|
36
|
+
if (value.is_a?(Symbol) || value.is_a?(String))
|
37
|
+
unless const_defined?(value)
|
38
|
+
raise NameError,
|
39
|
+
"uninitialized constant FSSM::Backends::#{value}"
|
40
|
+
end
|
41
|
+
value = const_get(value)
|
42
|
+
end
|
43
|
+
|
44
|
+
unless value.is_a?(Class)
|
45
|
+
raise ArgumentError,
|
46
|
+
"value must be a class or the symbol of an existing backend"
|
47
|
+
end
|
48
|
+
|
49
|
+
remove_const(const_symbol) if const_defined?(const_symbol)
|
50
|
+
const_set(const_symbol, value)
|
51
|
+
end
|
52
|
+
|
53
|
+
def const_missing(symbol)
|
54
|
+
symbol == :Default ? set_backend(symbol, FSSM::Support.backend) : super
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
10
60
|
class << self
|
11
61
|
def dbg(msg=nil)
|
12
62
|
STDERR.puts("FSSM -> #{msg}")
|
@@ -20,18 +70,5 @@ module FSSM
|
|
20
70
|
monitor.run
|
21
71
|
end
|
22
72
|
end
|
73
|
+
|
23
74
|
end
|
24
|
-
|
25
|
-
require 'thread'
|
26
|
-
|
27
|
-
require 'fssm/version'
|
28
|
-
require 'fssm/pathname'
|
29
|
-
require 'fssm/support'
|
30
|
-
require 'fssm/tree'
|
31
|
-
require 'fssm/path'
|
32
|
-
require 'fssm/state/directory'
|
33
|
-
require 'fssm/state/file'
|
34
|
-
require 'fssm/monitor'
|
35
|
-
|
36
|
-
require "fssm/backends/#{FSSM::Support.backend.downcase}"
|
37
|
-
FSSM::Backends::Default = FSSM::Backends.const_get(FSSM::Support.backend)
|
data/lib/fssm/support.rb
CHANGED
@@ -3,29 +3,24 @@ require 'rbconfig'
|
|
3
3
|
module FSSM::Support
|
4
4
|
class << self
|
5
5
|
def usable_backend
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
FSSM.dbg("An optimized backend is available for this platform!")
|
25
|
-
FSSM.dbg(" gem install #{optimal}")
|
6
|
+
case
|
7
|
+
when mac? && !lion? && !jruby? && carbon_core?
|
8
|
+
'FSEvents'
|
9
|
+
when mac? && rb_fsevent?
|
10
|
+
'RBFSEvent'
|
11
|
+
when linux? && rb_inotify?
|
12
|
+
'Inotify'
|
13
|
+
else
|
14
|
+
'Polling'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def optimal_backend_dependency
|
19
|
+
return case
|
20
|
+
when mac? then ['rb-fsevent', '>= 0.4.3.1']
|
21
|
+
when linux? then ['rb-inotify', '>= 0.8.8']
|
22
|
+
else [nil, nil]
|
26
23
|
end
|
27
|
-
|
28
|
-
choice
|
29
24
|
end
|
30
25
|
|
31
26
|
def backend
|
@@ -37,15 +32,15 @@ module FSSM::Support
|
|
37
32
|
end
|
38
33
|
|
39
34
|
def mac?
|
40
|
-
|
35
|
+
RbConfig::CONFIG['target_os'] =~ /darwin/i
|
41
36
|
end
|
42
37
|
|
43
38
|
def lion?
|
44
|
-
|
39
|
+
RbConfig::CONFIG['target_os'] =~ /darwin11/i
|
45
40
|
end
|
46
41
|
|
47
42
|
def linux?
|
48
|
-
|
43
|
+
RbConfig::CONFIG['target_os'] =~ /linux/i
|
49
44
|
end
|
50
45
|
|
51
46
|
def carbon_core?
|
data/lib/fssm/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: fssm
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.8
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 7
|
10
|
-
version: 0.2.7
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Travis Tilley
|
14
9
|
- Nathan Weizenbaum
|
15
10
|
- Chris Eppstein
|
@@ -18,42 +13,48 @@ authors:
|
|
18
13
|
autorequire:
|
19
14
|
bindir: bin
|
20
15
|
cert_chain: []
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
date: 2012-01-04 00:00:00.000000000 Z
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: rake
|
20
|
+
requirement: &70092419422160 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ! '>='
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
26
|
+
type: :development
|
27
27
|
prerelease: false
|
28
|
-
|
28
|
+
version_requirements: *70092419422160
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rspec
|
31
|
+
requirement: &70092419420200 !ruby/object:Gem::Requirement
|
29
32
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
hash: 31
|
34
|
-
segments:
|
35
|
-
- 2
|
36
|
-
- 4
|
37
|
-
- 0
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
38
36
|
version: 2.4.0
|
39
37
|
type: :development
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: *70092419420200
|
40
|
+
description: The File System State Monitor keeps track of the state of any number
|
41
|
+
of paths and will fire events when said state changes (create/update/delete). FSSM
|
42
|
+
supports using FSEvents on MacOS, Inotify on GNU/Linux, and polling anywhere else.
|
43
|
+
email:
|
43
44
|
- ttilley@gmail.com
|
44
45
|
executables: []
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
extensions:
|
47
|
+
- ext/rakefile.rb
|
48
48
|
extra_rdoc_files: []
|
49
|
-
|
50
|
-
files:
|
49
|
+
files:
|
51
50
|
- .gitignore
|
51
|
+
- .travis.yml
|
52
52
|
- Gemfile
|
53
53
|
- LICENSE
|
54
54
|
- README.markdown
|
55
55
|
- Rakefile
|
56
56
|
- example.rb
|
57
|
+
- ext/rakefile.rb
|
57
58
|
- fssm.gemspec
|
58
59
|
- lib/fssm.rb
|
59
60
|
- lib/fssm/backends/fsevents.rb
|
@@ -84,41 +85,31 @@ files:
|
|
84
85
|
- spec/root/file.yml
|
85
86
|
- spec/root/moo/cow.txt
|
86
87
|
- spec/spec_helper.rb
|
87
|
-
has_rdoc: true
|
88
88
|
homepage: https://github.com/ttilley/fssm
|
89
89
|
licenses: []
|
90
|
-
|
91
90
|
post_install_message:
|
92
91
|
rdoc_options: []
|
93
|
-
|
94
|
-
require_paths:
|
92
|
+
require_paths:
|
95
93
|
- lib
|
96
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
95
|
none: false
|
98
|
-
requirements:
|
99
|
-
- -
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
|
103
|
-
- 0
|
104
|
-
version: "0"
|
105
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
101
|
none: false
|
107
|
-
requirements:
|
108
|
-
- -
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
|
111
|
-
segments:
|
112
|
-
- 0
|
113
|
-
version: "0"
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
114
106
|
requirements: []
|
115
|
-
|
116
107
|
rubyforge_project: fssm
|
117
|
-
rubygems_version: 1.
|
108
|
+
rubygems_version: 1.8.13
|
118
109
|
signing_key:
|
119
110
|
specification_version: 3
|
120
111
|
summary: File System State Monitor
|
121
|
-
test_files:
|
112
|
+
test_files:
|
122
113
|
- spec/count_down_latch.rb
|
123
114
|
- spec/monitor_spec.rb
|
124
115
|
- spec/path_spec.rb
|