adrian 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/adrian/queue.rb +3 -1
- data/lib/adrian/queue_item.rb +1 -0
- data/lib/adrian/version.rb +1 -1
- data/test/composite_queue_test.rb +8 -0
- data/test/queue_test.rb +18 -0
- data/test/rotating_directory_queue_test.rb +17 -19
- data/test/test_helper.rb +1 -0
- metadata +2 -2
data/lib/adrian/queue.rb
CHANGED
data/lib/adrian/queue_item.rb
CHANGED
data/lib/adrian/version.rb
CHANGED
@@ -26,6 +26,14 @@ describe Adrian::CompositeQueue do
|
|
26
26
|
@q1.pop.must_be_nil
|
27
27
|
@q2.pop.must_be_nil
|
28
28
|
end
|
29
|
+
|
30
|
+
it 'sets the original queue on the item' do
|
31
|
+
@q1.push(1)
|
32
|
+
@q2.push(2)
|
33
|
+
|
34
|
+
@q.pop.queue.must_equal @q1
|
35
|
+
@q.pop.queue.must_equal @q2
|
36
|
+
end
|
29
37
|
end
|
30
38
|
|
31
39
|
describe "pushing" do
|
data/test/queue_test.rb
CHANGED
@@ -25,6 +25,24 @@ describe Adrian::Queue do
|
|
25
25
|
@q.push(item)
|
26
26
|
lambda { @q.pop }.must_raise(Adrian::Queue::ItemTooOldError)
|
27
27
|
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'sets the queue on the items' do
|
32
|
+
q = TestQueue.new
|
33
|
+
|
34
|
+
item = Adrian::QueueItem.new('value', Time.now)
|
35
|
+
|
36
|
+
item.queue.must_be_nil
|
37
|
+
|
38
|
+
q.push(item)
|
39
|
+
|
40
|
+
item.queue.must_be_nil
|
41
|
+
|
42
|
+
popped_item = q.pop
|
43
|
+
|
44
|
+
popped_item.must_equal item
|
45
|
+
item.queue.must_equal q
|
28
46
|
end
|
29
47
|
|
30
48
|
end
|
@@ -7,10 +7,12 @@ describe Adrian::RotatingDirectoryQueue do
|
|
7
7
|
before do
|
8
8
|
@root_path = Dir.mktmpdir('dir_queue_test')
|
9
9
|
@q = Adrian::RotatingDirectoryQueue.create(:path => @root_path)
|
10
|
+
Timecop.freeze
|
10
11
|
end
|
11
12
|
|
12
13
|
after do
|
13
|
-
|
14
|
+
Timecop.return
|
15
|
+
FileUtils.rm_r(@root_path, :force => true)
|
14
16
|
end
|
15
17
|
|
16
18
|
describe 'pop' do
|
@@ -19,20 +21,18 @@ describe Adrian::RotatingDirectoryQueue do
|
|
19
21
|
@item2 = Adrian::FileItem.new(Tempfile.new('item2').path)
|
20
22
|
@item3 = Adrian::FileItem.new(Tempfile.new('item3').path)
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
tomorrows_directory = File.join(@root_path, (Time.now + 60 * 60 * 24).strftime('%Y-%m-%d'))
|
24
|
+
todays_directory = File.join(@root_path, Time.now.strftime('%Y-%m-%d'))
|
25
|
+
tomorrows_directory = File.join(@root_path, (Time.now + 60 * 60 * 24).strftime('%Y-%m-%d'))
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
FileUtils.mkdir_p(todays_directory)
|
28
|
+
FileUtils.mkdir_p(tomorrows_directory)
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
@item1.move(todays_directory)
|
31
|
+
@item2.move(tomorrows_directory)
|
32
|
+
@item3.move(@root_path)
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
end
|
34
|
+
@q.pop.must_equal @item1
|
35
|
+
@q.pop.must_be_nil
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -42,15 +42,13 @@ describe Adrian::RotatingDirectoryQueue do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'moves the file to the time-stamped available directory' do
|
45
|
-
|
46
|
-
|
47
|
-
@q.push(@item)
|
45
|
+
original_path = @item.path
|
46
|
+
@q.push(@item)
|
48
47
|
|
49
|
-
|
50
|
-
|
48
|
+
assert_equal false, File.exist?(original_path)
|
49
|
+
assert_equal true, File.exist?(File.join(@q.available_path, @item.name))
|
51
50
|
|
52
|
-
|
53
|
-
end
|
51
|
+
@item.path.must_equal File.join(@root_path, Time.now.strftime('%Y-%m-%d'), @item.name)
|
54
52
|
end
|
55
53
|
end
|
56
54
|
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adrian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-01-
|
13
|
+
date: 2013-01-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|