broom 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +21 -2
- data/lib/broom.rb +10 -11
- metadata +5 -3
data/README.markdown
CHANGED
@@ -18,8 +18,27 @@ using the 'success_dir' and 'failure_dir' options.
|
|
18
18
|
|
19
19
|
gem install broom
|
20
20
|
|
21
|
-
##
|
21
|
+
## Examples
|
22
22
|
|
23
23
|
Broom.sweep('/dropbox') do |f|
|
24
24
|
Resque.enqueue(Job, "#{File.dirname(f)}/_success/#{File.basename(f)}")
|
25
|
-
end
|
25
|
+
end
|
26
|
+
|
27
|
+
---
|
28
|
+
|
29
|
+
threads = []
|
30
|
+
|
31
|
+
threads << Thread.new do
|
32
|
+
Broom.sweep('/foo') do |f|
|
33
|
+
# do something
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
threads << Thread.new do
|
38
|
+
Broom.sweep('/bar') do |f|
|
39
|
+
# do something
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
threads.each { |x| x.join }
|
44
|
+
|
data/lib/broom.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
|
-
Signal.trap('INT') do
|
4
|
-
$stdout.puts "throwing in the towel..."
|
5
|
-
exit
|
6
|
-
end
|
7
|
-
|
8
3
|
module Broom
|
9
|
-
|
10
|
-
VERSION = '0.3.2'
|
4
|
+
VERSION = '0.3.3'
|
11
5
|
|
12
6
|
class Directory
|
13
7
|
|
@@ -31,7 +25,7 @@ module Broom
|
|
31
25
|
}
|
32
26
|
files
|
33
27
|
end
|
34
|
-
|
28
|
+
|
35
29
|
end
|
36
30
|
|
37
31
|
extend self
|
@@ -44,14 +38,19 @@ module Broom
|
|
44
38
|
puts "#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}: #{msg}" if options[:log]
|
45
39
|
end
|
46
40
|
|
47
|
-
|
41
|
+
Signal.trap('INT') do
|
42
|
+
log.call("stopping...")
|
43
|
+
@do_work = false
|
44
|
+
end
|
45
|
+
|
46
|
+
begin
|
48
47
|
cache = dir.entries
|
49
48
|
sleep(options[:sleep] || 1)
|
50
49
|
|
51
50
|
cache.each do |file, modified_at|
|
52
51
|
next if modified_at != File.mtime(file)
|
53
52
|
begin
|
54
|
-
yield(file)
|
53
|
+
yield(file, File.dirname(file), File.basename(file), File.extname(file))
|
55
54
|
rescue Object => boom
|
56
55
|
log.call("failure: #{File.basename(file)} [#{boom.message}]")
|
57
56
|
FileUtils.mv(file, dir.failure_dir)
|
@@ -60,7 +59,7 @@ module Broom
|
|
60
59
|
FileUtils.mv(file, dir.success_dir)
|
61
60
|
end
|
62
61
|
end
|
63
|
-
end
|
62
|
+
end while @do_work
|
64
63
|
end
|
65
64
|
|
66
65
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: broom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Daniel Johnston
|
@@ -10,7 +10,8 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-08-14 00:00:00 -05:00
|
14
|
+
default_executable:
|
14
15
|
dependencies: []
|
15
16
|
|
16
17
|
description: " A small module for watching a directory for new files.\n"
|
@@ -26,6 +27,7 @@ files:
|
|
26
27
|
- LICENSE
|
27
28
|
- Rakefile
|
28
29
|
- lib/broom.rb
|
30
|
+
has_rdoc: true
|
29
31
|
homepage: https://github.com/drfeelngood/broom
|
30
32
|
licenses: []
|
31
33
|
|
@@ -49,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
51
|
requirements: []
|
50
52
|
|
51
53
|
rubyforge_project:
|
52
|
-
rubygems_version: 1.
|
54
|
+
rubygems_version: 1.6.2
|
53
55
|
signing_key:
|
54
56
|
specification_version: 3
|
55
57
|
summary: Simple file picker-upper
|