carrierwave-mimetype-fu 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: c6e5e6752a68e3ef4f472f7f446672108455aacb
4
- data.tar.gz: dea660a2a5b36a4a57b3a349b52d3ff5a57eb8e7
3
+ metadata.gz: 52f231eaad6b4683e917538711254064ec8b0909
4
+ data.tar.gz: b9dba256eb51acf510230014e1cf1fc3401af03e
5
5
  SHA512:
6
- metadata.gz: b61c5576863443451b2c6ed45225a0aa633217d3e87225d7cdaedf7f21525cbd904d091827f11fa94db6196422e0c54d6fc2d12143273011ea16f4f0d2dd4355
7
- data.tar.gz: b803bd3bfdeec0e0624967c0f3c771126b06615778eb1ee504a9fd75a9b17ec484ccb8446e1204066e17d4c83346121b358fb7b8068efb253a0fbcf28d713b56
6
+ metadata.gz: aebe42202438818bbf42c214dc30e562baa8dbff1feee3257ac31065f4f40969884fcff161f0d20b12ec12f311ffb3ec82f19cd898c88ff2313770643730179f
7
+ data.tar.gz: 79dc60a5ca7dbcfba54588727167ff505d8dfc63699d20cd00ead8e17fa482c585e94379fe9d9bac6d3d24d3d4a2136c4b338e14339798e0fa09e617a1787f7b
@@ -0,0 +1,10 @@
1
+ # carrierwave-mimetype-fu changelog
2
+
3
+
4
+ ## `0.0.2`
5
+
6
+ * Also engage when given a remote file (CarrierWave::Uploader::Download::RemoteFile)
7
+
8
+ ## `0.0.1`
9
+
10
+ * Added initial functionality. Only engages on direct file upload (ActionDispatch::Http::UploadedFile)
@@ -17,16 +17,23 @@ module CarrierWave
17
17
 
18
18
  def cache_with_mimetype_fu_magic!(new_file = sanitized_file)
19
19
  # Only step in on the initial file upload
20
- return cache_without_mimetype_fu_magic!(new_file) unless new_file.is_a?(ActionDispatch::Http::UploadedFile)
20
+ opened_file = case new_file
21
+ when CarrierWave::Uploader::Download::RemoteFile then new_file.send(:file)
22
+ when ActionDispatch::Http::UploadedFile then File.open(new_file.path)
23
+ else nil
24
+ end
25
+
26
+ return cache_without_mimetype_fu_magic!(new_file) unless opened_file
27
+
21
28
 
22
29
  begin
23
30
  # Collect information about the real content type
24
- real_content_type = File.mime_type?( File.open(new_file.path) ).split(';').first
31
+ real_content_type = File.mime_type?(opened_file).split(';').first
25
32
  valid_extensions = Array(MIME::Types[real_content_type].try(:first).try(:extensions))
26
33
 
27
34
  # Set proper content type, and update filename if current name doesn't match reach content type
28
- new_file.content_type = real_content_type
29
35
  new_file = CarrierWave::SanitizedFile.new(new_file)
36
+ new_file.content_type = real_content_type
30
37
  base, ext = new_file.send(:split_extension, new_file.original_filename)
31
38
  ext = valid_extensions.first unless valid_extensions.include?(ext)
32
39
 
@@ -1,5 +1,5 @@
1
1
  module CarrierWave
2
2
  module MimetypeFu
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-mimetype-fu
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
  - Kali Donovan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-01 00:00:00.000000000 Z
11
+ date: 2013-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mimetype-fu
@@ -46,6 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - .gitignore
49
+ - CHANGELOG.md
49
50
  - Gemfile
50
51
  - LICENSE.txt
51
52
  - README.md