carrierwave-data 0.0.1 → 0.0.2

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: 2ed1e109057975aa836d2884949bcd32ef2e2293
4
- data.tar.gz: 3b20c00e2c2f218f34ee328ada9acdf2fe71510d
3
+ metadata.gz: e3a454807c1919b051e33839c8feaf489bd5a78c
4
+ data.tar.gz: 79e77650fa7a1c3d02e02ca7e74dd675f421ea55
5
5
  SHA512:
6
- metadata.gz: 973d34865f9aede5624332f2b33815b78c527653cf52ba69e21e1f244759427b6d501861eef38fe9b17dc0755ccfa2aac3546562d1e89f769240b8418a78c396
7
- data.tar.gz: 084c9b8ab5b3378ce430ebd01f10d7d52b9326283ae68862505217d95b4047fb49537a932a104b61ca16e0cf2861ef7e9a1936d18cd1324bfdb89b0a0d64079d
6
+ metadata.gz: 8ab7c48092c11b5aa91cded89cba56f04b823b71ec18b23a6136066fb5942e649095ed5e7a070ed8d8f4eb14d366f1230f0705847d6e0a3abfb45ec773652366
7
+ data.tar.gz: aa28f8957b295825da961e2f9f00e559e74f44eb1862e4e7b5bdc4a52280d8af43bd724aadac5c1769e700a551189e0a413a5f8502cec9c27a4018ce3ccf75ae
data/README.md CHANGED
@@ -32,11 +32,17 @@ A `User`'s `avatar` can be set using a Base64 encoded string, as follows.
32
32
 
33
33
  ```ruby
34
34
  user = User.new
35
- user.avatar_data = 'iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABuBvAAAABGdBTUE...kJggg=='
35
+ user.avatar_data = {
36
+ data: 'iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABuBvAAAABGdBTUE...kJggg==',
37
+ name: 'avatar',
38
+ ext: 'jpg'
39
+ }
40
+ ## or
41
+ # user.avatar_data = 'iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABuBvAAAABGdBTUE...kJggg=='
36
42
  user.save
37
43
 
38
44
  user.avatar? # => true
39
- user.avatar # => #<UserAvatarUploader:0x007f9575fddc18 @model=#<User id: 1, avatar: "2d45cced04356fcfac278ef06f76d567">, @mounted_as=:avatar, ...>
45
+ user.avatar # => #<UserAvatarUploader:0x007f9575fddc18 @model=#<User id: 1, avatar: "...">, @mounted_as=:avatar, ...>
40
46
  ````
41
47
 
42
48
  ## Customizations
@@ -26,11 +26,20 @@ module CarrierWave
26
26
  private
27
27
 
28
28
  def decode_#{column}_data
29
+ file_filename = decoded_#{column}_filename
30
+ file_extension = decoded_#{column}_extension
31
+
32
+ if @#{column}_data.is_a?(Hash)
33
+ file_filename = @#{column}_data[:name] || file_filename
34
+ file_extension = @#{column}_data[:ext] || file_extension
35
+ @#{column}_data = @#{column}_data[:data]
36
+ end
37
+
29
38
  file = Tempfile.new('carrierwave-data')
30
39
  file.binmode
31
40
  file.write(Base64.decode64(@#{column}_data))
32
41
 
33
- filename = [decoded_#{column}_filename, decoded_#{column}_extension].compact.join('.')
42
+ filename = [file_filename, file_extension].compact.join('.')
34
43
  self.#{column} = ActionDispatch::Http::UploadedFile.new(tempfile: file, filename: filename)
35
44
  end
36
45
  RUBY
@@ -1,5 +1,5 @@
1
1
  module CarrierWave
2
2
  module Data
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramy Aboul Naga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-18 00:00:00.000000000 Z
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carrierwave