paperclip-google-drive 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d485865dd71ce11f5d063479d008aa4d74139663
4
- data.tar.gz: fd200560af8eced312efbbb333491014850fe923
3
+ metadata.gz: 1b74ffa08b048d2007804f535d7140e8dad3cf2b
4
+ data.tar.gz: f3d3f431d990e0a52fa812d1f6acc400695b7192
5
5
  SHA512:
6
- metadata.gz: 2c3cd032542c05a0b14fd562a49ad06a019f0f4fdb6c792cdf417463ba646864216c3c58d558ac5ec351f5a581838e3e9855842c70360bec3697be24e1609662
7
- data.tar.gz: ea829ce3a22b96546a2aafab8f33963e086e614a6a6766f0797602a3d4a50b32dbdf303d86040fe02ce8e3ca3924bd0ed92423a14776fae5a970f207894e350c
6
+ metadata.gz: 7af735b0d18245973e71350aec1cbeb67324e29086487eeafada81f692706ba34956a80a79f5781748739c9468e42d0c70cb386d52eff8427c8ec000a8dfa613
7
+ data.tar.gz: c1daa97b8e09031b706322f010147038c883152a895d5c11fcb493936e4e314e76e3fb82df6a16a1107341d9ad48e57b601fecccbcfbddbeeed80f3b0d1e512d
data/README.md CHANGED
@@ -55,7 +55,7 @@ end
55
55
  ```
56
56
  The `:google_drive_client_secret_path` option
57
57
 
58
- This is the path of the file which was obtained from your Google Drive app settings and the authorization Rake task.
58
+ This is the path of the file downloaded from your Google Drive app settings by the authorization Rake task.
59
59
 
60
60
  Example of the overridden `path/to/client_secret.json` file:
61
61
  ```json
@@ -78,7 +78,7 @@ This is a hash containing any of the following options:
78
78
  - `:default_image` - an image in Public folder that used for attachments if attachment is not present
79
79
  - `:application_name` - is the name that you set for the application credentials on Google console.
80
80
 
81
- The :path option should be a block that returns a path that the uploaded file should be saved to. The block yields the attachment style and is executed in the scope of the model instance. For example:
81
+ The :path option should be a block which returns a path that the uploaded file should be saved to. The block yields the attachment style and is executed in the scope of the model instance. For example:
82
82
 
83
83
  ```ruby
84
84
  class Product < ActiveRecord::Base
@@ -107,11 +107,15 @@ Also, you can use the resize feature provided by GDrive API, you only have to pa
107
107
  some_product.photo.url(:custom_thumb, width: 500)
108
108
  ```
109
109
 
110
+ ## Example App
111
+
112
+ You can find an example of how to config a Rails project [here](https://github.com/degzcs/rails-paperclip-gdrive-example)
113
+
110
114
  ## Issues
111
115
 
112
- ### No images Issues (PDF, CSV, etc)
116
+ ### Non image files Issues (PDF, CSV, etc)
113
117
 
114
- I still working on retrieve the raw files, I would like to get the files as `thumbnail_link` file attribute does, but it is not that easy, because Google Drive API has some retrictions. Therefore, all non images files are shown in Google Drive viwer.
118
+ I still working on retrieve the raw files, I would like to get the file urls as `thumbnail_link` attribute does, but it is not that easy, because Google Drive API has some retrictions. So, all non image files are shown in Google Drive viewer.
115
119
 
116
120
  ## Useful links
117
121
 
@@ -109,7 +109,7 @@ module Paperclip
109
109
  if present?
110
110
  style = args.first.is_a?(Symbol) ? args.first : default_style
111
111
  options = args.last.is_a?(Hash) ? args.last : {}
112
- if style == :custom_thumb
112
+ if style == :custom_thumb && is_valid_for_custom_thumb?
113
113
  custom_width = options[:width] || 220
114
114
  file_name = filename_from(default_style)
115
115
  public_url_custom_thumbnail_from(file_name, custom_width)
@@ -122,6 +122,10 @@ module Paperclip
122
122
  end
123
123
  end
124
124
 
125
+ def is_valid_for_custom_thumb?
126
+ content_type =~ /image/ || content_type =~ /pdf/
127
+ end
128
+
125
129
  # Gets full title/name
126
130
  # @param style [ String ]
127
131
  # @return [ String ]
@@ -228,7 +232,6 @@ module Paperclip
228
232
  def validate_metadata(metadata)
229
233
  raise 'the file id was not retrieved' if metadata.id.nil?
230
234
  raise 'the file name was not retrieved' if metadata.name.nil?
231
- raise 'the file thumbnail_link was not retrieved' if metadata.thumbnail_link.nil?
232
235
  raise 'the file web_content_link was not retrieved' if metadata.web_content_link.nil?
233
236
  raise 'the file web_view_link was not retrieved' if metadata.web_view_link.nil?
234
237
  raise 'the file trashed was not retrieved' if metadata.trashed.nil?
@@ -1,3 +1,3 @@
1
1
  module PaperclipGoogleDrive
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-google-drive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Gomez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-26 00:00:00.000000000 Z
11
+ date: 2017-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paperclip