paperclip-imgur 0.1.2 → 0.1.3

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: d8877dbb4a1024efedb5aaf05ed464ba3afec1e5
4
- data.tar.gz: e42b2eb47c205eb82c9d11fd94051da3dea856a8
3
+ metadata.gz: 73b0907f207a9bf8e59acdf4fa0ff42a9f8f6f8c
4
+ data.tar.gz: f1db66035938ee61613c3c49f8718410b4db7229
5
5
  SHA512:
6
- metadata.gz: 91805a6e3e48e39cd241229e705ec509858440696459d435cb8d95251c4760b7ee23e1896131e7026c06f013df00192eb6f88af23d22d3f78102d8ae8ab066da
7
- data.tar.gz: 101fc71a146559fb2c6a533ab4b6b7bcd83fdc151bcf8e20f35c708f2ac7b196df6029fd44a74d91b7607587f558591c9606d2fab9aa7e3dc8b10f461966734c
6
+ metadata.gz: ea2ae272a5fed096079c87c9be56e5382062ec45455ecf8d3cc03c398c9d2730645b40f6e5ff5cc434fead1fdef94a3c91ed187bd6c85c22f49829d0113f2d52
7
+ data.tar.gz: 4e5bb6af2eb41d2f2e838d5f7c37f4220d766076508761d98ae5b19a1a47f5d854816c864bef925c44d0bde5bf7cf9263ad804c846f797605ebca9449d89501b
data/.gitignore CHANGED
@@ -15,4 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- nbproject
18
+ .DS_Store
19
+
data/README.md CHANGED
@@ -22,6 +22,7 @@ Tell your typical model™ to use Imgur as storage:
22
22
  ```ruby
23
23
  class User < ActiveRecord::Base
24
24
  has_attached_file :avatar, storage: :imgur
25
+ validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\z/
25
26
  end
26
27
  ```
27
28
 
@@ -31,6 +32,7 @@ The credentials to upload and delete images from Imgur will be read from `#{Rail
31
32
  ```yml
32
33
  client_id: 'CLIENT_ID'
33
34
  client_secret: 'CLIENT_SECRET'
35
+ access_token: 'ACCESS_TOKEN'
34
36
  refresh_token: 'REFRESH_TOKEN'
35
37
  ```
36
38
 
@@ -38,11 +40,11 @@ Get these keys with:
38
40
  ```bash
39
41
  rake imgur:authorize CLIENT_ID='CLIENT_ID' CLIENT_SECRET='CLIENT_SECRET'
40
42
  ```
41
- Please refer to the [API client gem documentation](https://github.com/dncrht/imgur) for more information on this.
43
+ Please refer to the [API client gem documentation](https://github.com/dncrht/imgur) for more information on this. Create an [application](https://imgur.com/account/settings/apps) if you don't have those client keys yet.
42
44
 
43
45
  You can also specify the credentials per model attribute, using a hash:
44
46
  ```ruby
45
- has_attached_file :avatar, storage: :imgur, imgur_credentials: {client_id: 'CLIENT_ID', client_secret: 'CLIENT_SECRET', refresh_token: 'REFRESH_TOKEN'}
47
+ has_attached_file :avatar, storage: :imgur, imgur_credentials: {client_id: 'CLIENT_ID', client_secret: 'CLIENT_SECRET', access_token: 'ACCESS_TOKEN', refresh_token: 'REFRESH_TOKEN'}
46
48
  ```
47
49
  …or path to a YAML file
48
50
  ```ruby
@@ -31,20 +31,12 @@ module Paperclip
31
31
  end
32
32
 
33
33
  def flush_writes
34
- @queued_for_write.each do |style, file| #style is 'original' etc...
35
-
36
- begin
37
- image = imgur_session.image.image_upload(file)
38
- image_id = image.id
39
- rescue
40
- # Sometimes there are API or network errors.
41
- # In this cases, we don't store anything.
42
- image_id = nil
43
- end
34
+ @queued_for_write.each do |style, file| # 'style' is 'original' etc
35
+ image = imgur_session.image.image_upload(file)
44
36
 
45
37
  # We cannot use update_attribute because it internally calls save, and save calls
46
38
  # flush_writes again, and it will end up in a stack overflow due excessive recursion
47
- instance.update_column :"#{name}_#{:file_name}", image_id
39
+ instance.update_column :"#{name}_#{:file_name}", image.id
48
40
  end
49
41
  after_flush_writes
50
42
  @queued_for_write = {}
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = 'paperclip-imgur'
7
- gem.version = '0.1.2'
7
+ gem.version = '0.1.3'
8
8
  gem.authors = ['Daniel Cruz Horts']
9
9
  gem.description = %q{Extends Paperclip with Imgur storage}
10
10
  gem.summary = gem.description
@@ -16,7 +16,8 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
17
  gem.require_paths = ['lib']
18
18
 
19
- gem.add_dependency 'imgurapi', '~> 3.0.0'
20
- gem.add_development_dependency 'byebug'
19
+ gem.add_dependency 'imgurapi', '>= 3.0.2'
21
20
  gem.add_development_dependency 'rspec'
21
+ gem.add_dependency 'pry'
22
+ gem.add_dependency 'pry-byebug'
22
23
  end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-imgur
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Cruz Horts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-06 00:00:00.000000000 Z
11
+ date: 2017-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: imgurapi
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.0
19
+ version: 3.0.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 3.0.0
26
+ version: 3.0.2
27
27
  - !ruby/object:Gem::Dependency
28
- name: byebug
28
+ name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,13 +39,27 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- type: :development
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
@@ -90,10 +104,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
104
  version: '0'
91
105
  requirements: []
92
106
  rubyforge_project:
93
- rubygems_version: 2.2.2
107
+ rubygems_version: 2.6.11
94
108
  signing_key:
95
109
  specification_version: 4
96
110
  summary: Extends Paperclip with Imgur storage
97
111
  test_files:
98
112
  - spec/paperclip/storage/imgur_spec.rb
99
- has_rdoc: