carrierwave-base64 2.9.0 → 2.10.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
  SHA256:
3
- metadata.gz: 3af16036cb1f1a6f3ae6ffce52db973a32c09c76287cde31036bed14b9989d3f
4
- data.tar.gz: 62500de72742bb64cae9f3839124892f33463044c554f245b256868262c64e5d
3
+ metadata.gz: dcc0254f7258899a78ff178e32c60221aea32cf3551a1dc0702ff1675645024b
4
+ data.tar.gz: dc0f4f9de01fe428086ac3a3289ae808e53c2a0f80713cee51b8ef177ad542d4
5
5
  SHA512:
6
- metadata.gz: f7e8b717582744821f8bd91437ced8f9fe7e794c6c9821e613a3b1c4eb4f33f5e4774b15428a74ddf8e1080143a9444b958776e7c8c156c2004bb97767e84e60
7
- data.tar.gz: aad329e8d107294400e2ea177cd6d7ef4e40751b6bf57fa4987782705d4c9f30ba0f013df1e24e73f96af27ec98a90189f4207f1fbc6eec79726012bc7a19bad
6
+ metadata.gz: 7e9df88c09c107a39403c969dedd523e7bcd9a152bdcb548ee3250ea63b4e8498b80a33a52903f66530f4ba95bc61c3b63081de7c08e64f62779613cc9ff486c
7
+ data.tar.gz: d104d6d00b5ee4b3772dd696f9136c0d3335aa460d3fd8543fa484050c22817a1189b21d731a748960f14fbf550c5b060f8e353c137017cda5377be19811a215
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # carrierwave-base64 changelog
2
2
 
3
+ ## 2.10.0
4
+
5
+ - Allow `mount_base64_uploader` to take a block as an argument (#83, @shuuuuun)
6
+
3
7
  ## 2.9.0
4
8
 
5
9
  - Mimemagic gem is replaced with Marcel (#87, @oakbow)
@@ -17,9 +17,16 @@ module Carrierwave
17
17
  # mount_base64_uploader :image, ImageUploader,
18
18
  # file_name: -> (u) { u.username }
19
19
  #
20
+ # @example Mount the uploader with a block, overriding the store_dir
21
+ # mount_base64_uploader :image, ImageUploader do
22
+ # def store_dir
23
+ # 'images'
24
+ # end
25
+ # end
26
+ #
20
27
  # @return [Symbol] the defined writer method name
21
- def mount_base64_uploader(attribute, uploader_class, options = {})
22
- mount_uploader attribute, uploader_class, options
28
+ def mount_base64_uploader(attribute, uploader_class, options = {}, &block)
29
+ mount_uploader attribute, uploader_class, options, &block
23
30
  options[:file_name] ||= proc { attribute }
24
31
 
25
32
  Carrierwave::Base64::MountingHelper.check_for_deprecations(options)
@@ -1,5 +1,5 @@
1
1
  module Carrierwave
2
2
  module Base64
3
- VERSION = '2.9.0'.freeze
3
+ VERSION = '2.10.0'.freeze
4
4
  end
5
5
  end
data/spec/adapter_spec.rb CHANGED
@@ -170,5 +170,24 @@ RSpec.describe Carrierwave::Base64::Adapter do
170
170
  expect { subject.update!(username: 'new-username') }.not_to raise_error
171
171
  end
172
172
  end
173
+
174
+ context 'models with a block for the uploader' do
175
+ subject do
176
+ User.mount_base64_uploader(:image, uploader) do
177
+ def monkey
178
+ 'blah'
179
+ end
180
+ end
181
+ User.new
182
+ end
183
+
184
+ it 'should return an instance of a subclass of CarrierWave::Uploader::Base' do
185
+ expect(subject.image).to be_a(CarrierWave::Uploader::Base)
186
+ end
187
+
188
+ it 'should apply any custom modifications' do
189
+ expect(subject.image.monkey).to eq('blah')
190
+ end
191
+ end
173
192
  end
174
193
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-base64
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Lebedev