broom 0.1.1 → 0.3.0
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.
- data/README.markdown +2 -2
- data/lib/broom.rb +6 -4
- metadata +4 -4
data/README.markdown
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
Broom
|
2
2
|
=====
|
3
|
-
|
3
|
+
A simple module to help monitor a directory for new files and perform an action
|
4
4
|
on each new file. Broom periodically sweeps a directory, caching each file and its
|
5
5
|
last modification time. After each sweep, Broom iterates through the cache and
|
6
6
|
yields only the files that have a current modification time that matches the cached
|
7
7
|
modification time. In the event of an error, Broom gracefully sweeps
|
8
8
|
the file to a failure dustpan. Else, the file is swept to a success dustpan.
|
9
9
|
|
10
|
-
|
10
|
+
Broom depends on the following directory structure, which can be modified
|
11
11
|
using the 'success_dir' and 'failure_dir' options.
|
12
12
|
|
13
13
|
/path/to/directory
|
data/lib/broom.rb
CHANGED
@@ -7,7 +7,7 @@ end
|
|
7
7
|
|
8
8
|
module Broom
|
9
9
|
|
10
|
-
VERSION = '0.
|
10
|
+
VERSION = '0.3.0'
|
11
11
|
|
12
12
|
class Directory
|
13
13
|
|
@@ -23,7 +23,7 @@ module Broom
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def entries
|
27
27
|
files = {}
|
28
28
|
Dir.glob(File.join(@path, @pattern)).each { |file|
|
29
29
|
next if file == @success_dir || file == @failure_dir
|
@@ -39,7 +39,10 @@ module Broom
|
|
39
39
|
def sweep(path, options={}, &block)
|
40
40
|
dir = Directory.new(path, options)
|
41
41
|
loop do
|
42
|
-
|
42
|
+
cache = dir.entries
|
43
|
+
sleep options[:sleep] || 1
|
44
|
+
|
45
|
+
cache.each do |file, modified_at|
|
43
46
|
next if modified_at != File.mtime(file)
|
44
47
|
begin
|
45
48
|
yield(file)
|
@@ -49,7 +52,6 @@ module Broom
|
|
49
52
|
FileUtils.mv(file, dir.success_dir)
|
50
53
|
end
|
51
54
|
end
|
52
|
-
sleep options[:sleep] || 1
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel Johnston
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-14 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|