paperdragon 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paperdragon/task.rb +4 -4
- data/lib/paperdragon/version.rb +1 -1
- data/test/task_test.rb +19 -7
- 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: 36e7122d614e09b22cecbf83c3698e9d6e9343cb
|
4
|
+
data.tar.gz: cede5637f600b6c1121c4c7239af3a7367ed5c35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a60d0ed2a91ae998f46fa602d389fb881c384fd43735a5727c26a07539f3db76fc93cca01c3872c335b7a917054e5ef868e1f44a1596acafa0ef709918cd4b9
|
7
|
+
data.tar.gz: fd032e73607fb56b7e11c90b968c84f502858a465c6f6e1ea018b4901757fef14c557e4144d64a896bfa1b517c7722c86e1d9ecc7329c5f4c8e497ce2d0dcd18
|
data/lib/paperdragon/task.rb
CHANGED
@@ -25,11 +25,11 @@ module Paperdragon
|
|
25
25
|
# fingerprint optional => filename is gonna remain the same
|
26
26
|
# original nil => use [:original]
|
27
27
|
def reprocess!(style, fingerprint=nil, original=nil, &block)
|
28
|
-
original ||= file(:original)
|
29
|
-
version
|
30
|
-
new_uid
|
28
|
+
@original ||= file(:original) # this is cached per task instance.
|
29
|
+
version = file(style)
|
30
|
+
new_uid = @attachment.rebuild_uid(version, fingerprint)
|
31
31
|
|
32
|
-
@metadata.merge!(style => version.reprocess!(new_uid, original, &block))
|
32
|
+
@metadata.merge!(style => version.reprocess!(new_uid, @original, &block))
|
33
33
|
end
|
34
34
|
|
35
35
|
def rename!(style, fingerprint, &block)
|
data/lib/paperdragon/version.rb
CHANGED
data/test/task_test.rb
CHANGED
@@ -48,7 +48,7 @@ class TaskSpec < MiniTest::Spec
|
|
48
48
|
end
|
49
49
|
|
50
50
|
subject { Attachment.new({
|
51
|
-
:original=>{:uid=>"original/pic.jpg"}, :thumb=>{:uid=>"original/thumb.jpg"}}).task
|
51
|
+
:original=>{:uid=>"original/pic.jpg"}, :thumb=>{:uid=>"original/thumb.jpg"}, :bigger=>{:uid=>"original/bigger.jpg"}}).task
|
52
52
|
}
|
53
53
|
|
54
54
|
it do
|
@@ -56,7 +56,7 @@ class TaskSpec < MiniTest::Spec
|
|
56
56
|
subject.reprocess!(:thumb, "1", original) { |j| j.thumb!("16x16") }
|
57
57
|
|
58
58
|
# FIXME: fingerprint should be added before .png suffix.
|
59
|
-
subject.metadata_hash.must_equal({:original=>{:width=>216, :height=>63, :uid=>"original/pic-1.jpg"}, :thumb=>{:width=>16, :height=>5, :uid=>"original/thumb-1.jpg"}})
|
59
|
+
subject.metadata_hash.must_equal({:original=>{:width=>216, :height=>63, :uid=>"original/pic-1.jpg"}, :thumb=>{:width=>16, :height=>5, :uid=>"original/thumb-1.jpg"}, :bigger=>{:uid=>"original/bigger.jpg"}})
|
60
60
|
|
61
61
|
# exists?(original.uri).must_equal false # deleted
|
62
62
|
# exists?(new_uid).must_equal true
|
@@ -65,13 +65,25 @@ class TaskSpec < MiniTest::Spec
|
|
65
65
|
# don't pass in fingerprint+original.
|
66
66
|
it do
|
67
67
|
subject.reprocess!(:thumb) { |j| j.thumb!("24x24") }
|
68
|
-
subject.
|
68
|
+
subject.reprocess!(:bigger) { |j| j.thumb!("48x48") }
|
69
|
+
|
70
|
+
subject.metadata_hash.must_equal({:original=>{:uid=>"original/pic.jpg"}, :thumb=>{:width=>24, :height=>7, :uid=>"original/thumb-.jpg"}, :bigger=>{:uid=>"original/bigger-.jpg", :width=>48, :height=>14}})
|
71
|
+
end
|
72
|
+
|
73
|
+
# don't pass in original, this must NOT reload the original file more than once!
|
74
|
+
it do
|
75
|
+
subject.reprocess!(:thumb, 1) { |j| j.thumb!("24x24") }
|
76
|
+
File.unlink("public/paperdragon/#{original.uid}") # removing means the original MUST be cached for next step.
|
77
|
+
subject.reprocess!(:bigger, 1) { |j| j.thumb!("48x48") }
|
78
|
+
|
79
|
+
subject.metadata_hash.must_equal(
|
80
|
+
{:original=>{:uid=>"original/pic.jpg"}, :thumb=>{:width=>24, :height=>7, :uid=>"original/thumb-1.jpg"}, :bigger=>{:uid=>"original/bigger-1.jpg", :width=>48, :height=>14}})
|
69
81
|
end
|
70
82
|
|
71
83
|
# only process one, should return entire metadata hash
|
72
84
|
it do
|
73
85
|
subject.reprocess!(:thumb, "new") { |j| j.thumb!("24x24") }
|
74
|
-
subject.metadata_hash.must_equal({:original=>{:uid=>"original/pic.jpg"}, :thumb=>{:width=>24, :height=>7, :uid=>"original/thumb-new.jpg"}})
|
86
|
+
subject.metadata_hash.must_equal({:original=>{:uid=>"original/pic.jpg"}, :thumb=>{:width=>24, :height=>7, :uid=>"original/thumb-new.jpg"}, :bigger=>{:uid=>"original/bigger.jpg"}})
|
75
87
|
|
76
88
|
# original must be unchanged
|
77
89
|
exists?(Attachment.new(subject.metadata_hash)[:original].uid).must_equal true
|
@@ -81,16 +93,16 @@ class TaskSpec < MiniTest::Spec
|
|
81
93
|
it do
|
82
94
|
subject.reprocess!(:thumb, "1234567890") { |j| j.thumb!("24x24") }
|
83
95
|
metadata = subject.metadata_hash
|
84
|
-
metadata.must_equal({:original=>{:uid=>"original/pic.jpg"}, :thumb=>{:width=>24, :height=>7, :uid=>"original/thumb-1234567890.jpg"}})
|
96
|
+
metadata.must_equal({:original=>{:uid=>"original/pic.jpg"}, :thumb=>{:width=>24, :height=>7, :uid=>"original/thumb-1234567890.jpg"}, :bigger=>{:uid=>"original/bigger.jpg"}})
|
85
97
|
|
86
98
|
# this might happen in the next request.
|
87
99
|
subject = Attachment.new(metadata).task
|
88
100
|
subject.reprocess!(:thumb, "0987654321") { |j| j.thumb!("24x24") }
|
89
|
-
subject.metadata_hash.must_equal({:original=>{:uid=>"original/pic.jpg"}, :thumb=>{:width=>24, :height=>7, :uid=>"original/thumb-0987654321.jpg"}})
|
101
|
+
subject.metadata_hash.must_equal({:original=>{:uid=>"original/pic.jpg"}, :thumb=>{:width=>24, :height=>7, :uid=>"original/thumb-0987654321.jpg"}, :bigger=>{:uid=>"original/bigger.jpg"}})
|
90
102
|
end
|
91
103
|
|
92
104
|
# #rebuild_uid eats integers.
|
93
|
-
it { subject.reprocess!(:thumb, 1234081599) { |j| j.thumb!("24x24") }.must_equal({:original=>{:uid=>"original/pic.jpg"}, :thumb=>{:width=>24, :height=>7, :uid=>"original/thumb-1234081599.jpg"}}) }
|
105
|
+
it { subject.reprocess!(:thumb, 1234081599) { |j| j.thumb!("24x24") }.must_equal({:original=>{:uid=>"original/pic.jpg"}, :thumb=>{:width=>24, :height=>7, :uid=>"original/thumb-1234081599.jpg"}, :bigger=>{:uid=>"original/bigger.jpg"}}) }
|
94
106
|
end
|
95
107
|
|
96
108
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperdragon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dragonfly
|