bunch 1.0.0pre2 → 1.0.0pre3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bunch/file_cache.rb +11 -6
- data/lib/bunch/simple_cache.rb +12 -5
- data/lib/bunch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a37d91d1930ff1ac34b123a971d142fa3d55bb52
|
4
|
+
data.tar.gz: 58e981014d925670a9cfba1bea8e724166e8cb2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e54d84f5412f4487384e0bfa433df0b60320b64b499812db97fdd56936d15013ad30d6ba775b5f970735a36f1941420befc2baf196eae0c986ce283e86ef4e93
|
7
|
+
data.tar.gz: 848abb8159a204f5b3467a2c64069d18d2fbf7427e413ce45e4ac4a6966e284c66e6e5718f210a933949b449ff9f7759299c332d40ab3f5d641bf01119e7072e
|
data/lib/bunch/file_cache.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "digest/md5"
|
4
4
|
require "fileutils"
|
5
|
+
require "thread"
|
5
6
|
require "yaml"
|
6
7
|
|
7
8
|
module Bunch
|
@@ -15,18 +16,22 @@ module Bunch
|
|
15
16
|
def initialize(processor_class, input_dir, *args)
|
16
17
|
@processor_class, @args = processor_class, args
|
17
18
|
@cache_name = "#{processor_class}-#{input_dir}"
|
19
|
+
@mutex = Mutex.new
|
18
20
|
end
|
19
21
|
|
20
22
|
def new(tree)
|
21
|
-
|
22
|
-
|
23
|
+
result = nil
|
24
|
+
@mutex.synchronize do
|
25
|
+
cache = load_cache
|
26
|
+
partition = Partition.new(tree, cache)
|
23
27
|
|
24
|
-
|
28
|
+
partition.process!
|
25
29
|
|
26
|
-
|
27
|
-
|
30
|
+
processor = @processor_class.new(partition.pending, *@args)
|
31
|
+
result = TreeMerge.new(partition.cached, processor.result).result
|
28
32
|
|
29
|
-
|
33
|
+
save_cache tree, result
|
34
|
+
end
|
30
35
|
Result.new(result)
|
31
36
|
end
|
32
37
|
|
data/lib/bunch/simple_cache.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require "thread"
|
4
|
+
|
3
5
|
module Bunch
|
4
6
|
def self.SimpleCache(*args)
|
5
7
|
SimpleCache.new(*args)
|
@@ -12,15 +14,20 @@ module Bunch
|
|
12
14
|
@processor_class, @args = processor_class, args
|
13
15
|
@cache = nil
|
14
16
|
@hache = nil
|
17
|
+
@mutex = Mutex.new
|
15
18
|
end
|
16
19
|
|
17
20
|
def new(tree)
|
18
|
-
|
19
|
-
@
|
20
|
-
|
21
|
-
|
21
|
+
result = nil
|
22
|
+
@mutex.synchronize do
|
23
|
+
check_cache!(tree)
|
24
|
+
@cache ||= begin
|
25
|
+
processor = @processor_class.new(tree, *@args)
|
26
|
+
processor.result
|
27
|
+
end
|
28
|
+
result = @cache.dup
|
22
29
|
end
|
23
|
-
Result.new(
|
30
|
+
Result.new(result)
|
24
31
|
end
|
25
32
|
|
26
33
|
private
|
data/lib/bunch/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bunch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.0pre3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Fitzgerald
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|