carrierwave-base64 2.0 → 2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/carrierwave/base64/adapter.rb +4 -1
- data/lib/carrierwave/base64/version.rb +1 -1
- data/spec/adapter_spec.rb +1 -0
- data/spec/fixtures/base64_image.fixture +1 -1
- data/spec/fixtures/test.jpg +0 -0
- 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: bd170fa5ae07d088cbe54f9553c9497db056d54a
|
4
|
+
data.tar.gz: a6edda1a04bc09277a61832ed170e4ea0bcc41d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff0a8c13748d7aaabec2cdb064a082653bde2bcd17be7aa4ab3f027ef2b5235cdc69dd2f66f5b8249f3e8e711694b3b85d46020967c70ec368e25f8eff691b80
|
7
|
+
data.tar.gz: e7e46931cc24bebfa3b5d1984e24fe58ee9c374634026445bed2176d245f2f1556c771a20bcbbcd1f2c48f16a4def054fee262385451072d653dd02527785a94
|
@@ -5,9 +5,12 @@ module Carrierwave
|
|
5
5
|
mount_uploader attribute, uploader_class, options
|
6
6
|
|
7
7
|
define_method "#{attribute}=" do |data|
|
8
|
+
if data.present? && send("#{attribute}").blank?
|
9
|
+
send "#{attribute}_will_change!"
|
10
|
+
end
|
11
|
+
|
8
12
|
if data.present? && data.is_a?(String) && data.strip.start_with?("data")
|
9
13
|
super(Carrierwave::Base64::Base64StringIO.new(data.strip))
|
10
|
-
send "#{attribute}_will_change!"
|
11
14
|
else
|
12
15
|
super(data)
|
13
16
|
end
|
data/spec/adapter_spec.rb
CHANGED
@@ -17,6 +17,7 @@ RSpec.describe Carrierwave::Base64::Adapter do
|
|
17
17
|
sham_rack_app = ShamRack.at('www.example.com').stub
|
18
18
|
sham_rack_app.register_resource("/test.jpg", file_path("fixtures", "test.jpg"), "images/jpg")
|
19
19
|
subject[:image] = "test.jpg"
|
20
|
+
expect(subject.changed?).to be_truthy
|
20
21
|
subject.save!
|
21
22
|
subject.reload
|
22
23
|
expect(subject.image.current_path).to eq file_path("../uploads", "test.jpg")
|
@@ -1 +1 @@
|
|
1
|
-
data:image/jpg;base64
|
1
|
+
data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==
|
data/spec/fixtures/test.jpg
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-base64
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yury Lebedev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|