carrierwave-base64 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +4 -2
- data/lib/carrierwave/base64/adapter.rb +4 -0
- data/lib/carrierwave/base64/version.rb +1 -1
- data/spec/adapter_spec.rb +6 -0
- data/spec/spec_helper.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55f67ddadc62c0a941377c122f982964d08008a6
|
4
|
+
data.tar.gz: eff00b8df379f7571f9cdb431dd70716afc44137
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0659cc1714eed37c8206b4272f4d735b40946f5b0880de3db1474655f6a8bc40eff6db7202ebecb218a2eff1167125832385f051595dddc30e0c511f7c05976
|
7
|
+
data.tar.gz: c467c8953100fa9ad18dbbca235045098b753eff940d9870f783b72821a8626fbb502c3277319d319a998b9315ed7574f77babfbf902c6461fdd59676aeb09e8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# carrierwave-base64 changelog
|
2
2
|
|
3
|
+
## 2.5.0
|
4
|
+
|
5
|
+
- The uploaded file is not deleted, when the attribute is set to the existing file name (@lebedev-yury, bug-report #51 by @jmuheim)
|
6
|
+
|
3
7
|
## 2.4.0
|
4
8
|
|
5
9
|
- The `:file_name` option accepts a lambda with an argument, to which the model instance would be passed. This allows you to set the filename based on some model attribute (@lebedev-yury).
|
data/README.md
CHANGED
@@ -60,10 +60,12 @@ mount_base64_uploader :image, ImageUploader, file_name: -> { 'userpic' }
|
|
60
60
|
|
61
61
|
## Data format
|
62
62
|
|
63
|
-
The string with the encoded data, should be prefixed with Data URI scheme format
|
63
|
+
The string with the encoded data, should be prefixed with Data URI scheme format.
|
64
|
+
|
65
|
+
Keep in mind, that the content type specified in this string, would be used to identified the file extension. So if you have some custom content type uploaded, don't forget to register a Mime Type for it.
|
64
66
|
|
65
67
|
```
|
66
|
-
data:image/
|
68
|
+
data:image/jpeg;base64,(base64 encoded data)
|
67
69
|
```
|
68
70
|
|
69
71
|
## Contributing
|
@@ -3,10 +3,13 @@ module Carrierwave
|
|
3
3
|
module Adapter
|
4
4
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
5
5
|
# rubocop:disable Metrics/CyclomaticComplexity
|
6
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
6
7
|
def mount_base64_uploader(attribute, uploader_class, options = {})
|
7
8
|
mount_uploader attribute, uploader_class, options
|
8
9
|
|
9
10
|
define_method "#{attribute}=" do |data|
|
11
|
+
return if data == send(attribute).to_s
|
12
|
+
|
10
13
|
if respond_to?("#{attribute}_will_change!") && data.present?
|
11
14
|
send "#{attribute}_will_change!"
|
12
15
|
end
|
@@ -24,6 +27,7 @@ module Carrierwave
|
|
24
27
|
end
|
25
28
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
26
29
|
# rubocop:enable Metrics/CyclomaticComplexity
|
30
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
data/spec/adapter_spec.rb
CHANGED
@@ -77,6 +77,12 @@ RSpec.describe Carrierwave::Base64::Adapter do
|
|
77
77
|
subject.reload
|
78
78
|
end
|
79
79
|
|
80
|
+
it 'keeps the file when setting the attribute to existing value' do
|
81
|
+
expect(File.exist?(subject.reload.image.file.file)).to be_truthy
|
82
|
+
subject.update!(image: subject.image.to_s)
|
83
|
+
expect(File.exist?(subject.reload.image.file.file)).to be_truthy
|
84
|
+
end
|
85
|
+
|
80
86
|
it 'removes files when remove_* is set to true' do
|
81
87
|
subject.remove_image = true
|
82
88
|
subject.save!
|
data/spec/spec_helper.rb
CHANGED
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yury Lebedev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
227
|
version: '0'
|
228
228
|
requirements: []
|
229
229
|
rubyforge_project:
|
230
|
-
rubygems_version: 2.
|
230
|
+
rubygems_version: 2.5.1
|
231
231
|
signing_key:
|
232
232
|
specification_version: 4
|
233
233
|
summary: Upload images encoded as base64 to carrierwave.
|