paperclip-deflater 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 936994b83a0f58ce48c80d843df09abd36dd8a16
|
4
|
+
data.tar.gz: fd5e0814a4e0d5e760dc8fe6febffcfc9762e6a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd26871ffed60ec9eea0c37f904cb07cfd3488bb6bc22e142a29e79620722f20484b4ba40397b3af04d6594ee8f55a3b63677ae26746fe5fcf456d9516721cf8
|
7
|
+
data.tar.gz: ab704c08c39eef4572b9064ff217043b21630a6a5b7335c1076d9280c9e695e88dc34d465620c9b302df3f6fc4125b32782bc61a07b1dd96df055bf85fa03428
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -2,16 +2,16 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Paperclip::Processors::DeflaterBase do
|
4
4
|
let(:attachment) { double }
|
5
|
-
let(:
|
5
|
+
let(:no_deflate) { nil }
|
6
6
|
let(:options) { {} }
|
7
7
|
let(:file) { test_file }
|
8
8
|
subject { Paperclip::Processors::DeflaterBase.new(file, options, attachment) }
|
9
9
|
before do
|
10
|
-
allow(attachment).to receive(:instance_read).with(:
|
10
|
+
allow(attachment).to receive(:instance_read).with(:no_deflate).and_return(no_deflate)
|
11
11
|
end
|
12
12
|
describe "#make" do
|
13
|
-
context "
|
14
|
-
let(:
|
13
|
+
context "no_deflate setting is true" do
|
14
|
+
let(:no_deflate) { true }
|
15
15
|
it "returns original" do
|
16
16
|
expect(subject.make).to eq(file)
|
17
17
|
end
|
@@ -3,19 +3,27 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe Paperclip::Processors::Deflater do
|
5
5
|
let(:attachment) { double }
|
6
|
-
let(:should_deflate) { true }
|
7
6
|
let(:options) { {} }
|
8
7
|
let(:file) { test_file }
|
9
8
|
subject { Paperclip::Processors::Deflater.new(file, options, attachment) }
|
10
9
|
before do
|
11
|
-
allow(attachment).to receive(:instance_read).with(:
|
10
|
+
allow(attachment).to receive(:instance_read).with(:no_deflate)
|
12
11
|
end
|
13
12
|
describe "private methods" do
|
14
13
|
describe "#make_impl" do
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
shared_examples "deflate" do
|
15
|
+
it "deflates the file" do
|
16
|
+
dst = subject.make
|
17
|
+
data = dst.read
|
18
|
+
expect(data.unpack('H*').first).to eq(result.unpack('H*').first)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
let(:result) { "x\x9C" }
|
22
|
+
include_examples "deflate"
|
23
|
+
context "level gzip_options" do
|
24
|
+
let(:result) { "x\xDA" }
|
25
|
+
let(:options) { {deflate_options: {level: Zlib::BEST_COMPRESSION}} }
|
26
|
+
include_examples "deflate"
|
19
27
|
end
|
20
28
|
end
|
21
29
|
end
|
@@ -3,24 +3,30 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe Paperclip::Processors::Gzip do
|
5
5
|
let(:attachment) { double }
|
6
|
-
let(:should_deflate) { true }
|
7
6
|
let(:options) { {} }
|
8
7
|
let(:file) { test_file }
|
9
8
|
subject { Paperclip::Processors::Gzip.new(file, options, attachment) }
|
10
9
|
before do
|
11
|
-
allow(attachment).to receive(:instance_read).with(:
|
10
|
+
allow(attachment).to receive(:instance_read).with(:no_deflate)
|
12
11
|
end
|
13
12
|
describe "private methods" do
|
14
13
|
describe "#make_impl" do
|
15
|
-
|
16
|
-
|
14
|
+
shared_examples "deflate" do
|
15
|
+
it "deflates the file" do
|
16
|
+
dst = subject.make
|
17
|
+
data = dst.read
|
18
|
+
expect(data[0..3]).to eq(result1)
|
19
|
+
# data[4..7] is modified time and it changes
|
20
|
+
expect(data[8..-1]).to eq(result2)
|
21
|
+
end
|
17
22
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
let(:result1) { "\u001F\x8B\b\u0000" }
|
24
|
+
let(:result2) { "\u0000\u0003+I-.\xE1\u0002\u0000\xC65\xB9;\u0005\u0000\u0000\u0000" }
|
25
|
+
include_examples "deflate"
|
26
|
+
context "level gzip_options" do
|
27
|
+
let(:result2) { "\u0002\u0003+I-.\xE1\u0002\u0000\xC65\xB9;\u0005\u0000\u0000\u0000" }
|
28
|
+
let(:options) { {gzip_options: {level: Zlib::BEST_COMPRESSION}} }
|
29
|
+
include_examples "deflate"
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|