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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39e8fd07baef760e5937db3b05ed6ce369369e52
4
- data.tar.gz: ed5d91745c21ac7d8642a0d9ee9edaed2e559466
3
+ metadata.gz: 55f67ddadc62c0a941377c122f982964d08008a6
4
+ data.tar.gz: eff00b8df379f7571f9cdb431dd70716afc44137
5
5
  SHA512:
6
- metadata.gz: 3471e8152f7431832ff5cf1e9e09fd8e4ef3dcc1659532da9702f884be8c32e10201e1a241335d738be8aed6dfcbc017564fa566868a6b1ec9ba9afbfd2eeab3
7
- data.tar.gz: d339ff54885830de362f14a82dd8dc3adf57c83c5ec961d7f731187d67dbf4436d4d2905d403d35fdb281d36d58f998d345da5b558c5aa300d32838d48838f9d
6
+ metadata.gz: c0659cc1714eed37c8206b4272f4d735b40946f5b0880de3db1474655f6a8bc40eff6db7202ebecb218a2eff1167125832385f051595dddc30e0c511f7c05976
7
+ data.tar.gz: c467c8953100fa9ad18dbbca235045098b753eff940d9870f783b72821a8626fbb502c3277319d319a998b9315ed7574f77babfbf902c6461fdd59676aeb09e8
@@ -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/jpg;base64,(base64 encoded data)
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
@@ -1,5 +1,5 @@
1
1
  module Carrierwave
2
2
  module Base64
3
- VERSION = '2.4.0'.freeze
3
+ VERSION = '2.5.0'.freeze
4
4
  end
5
5
  end
@@ -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!
@@ -26,3 +26,5 @@ require 'support/models'
26
26
  def file_path(*paths)
27
27
  File.expand_path(File.join(File.dirname(__FILE__), *paths))
28
28
  end
29
+
30
+ CarrierWave.root = ''
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.0
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-02-03 00:00:00.000000000 Z
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.6.8
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.