shrine-cloudinary 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/shrine/storage/cloudinary.rb +11 -18
- data/shrine-cloudinary.gemspec +4 -4
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 705e20f18504b9412177cdb7fa61da3460d9f54d
|
4
|
+
data.tar.gz: a3848b2726032c48c48dd0f8430c476100ab14ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac24a2656d36fc87a70473ad498ea7b744a52d4616caf161fc97464bdd7d96b7f0a09493ca5301f5345b1303419b9112788f8189d468f733f1aa8367d5cd35b4
|
7
|
+
data.tar.gz: 07901084386db42a2fe37e1a2090fe730e697097444cb04e5b3f2b8ce78e7950af70dbe88d0be3ee6726ffdec0b6e11549c136f4ae462d35c3c2bb1847efcc49
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Provides [Cloudinary] storage for [Shrine].
|
4
4
|
|
5
5
|
Cloudinary provides storage and advanced processing for images and videos, both
|
6
|
-
on-demand and on upload.
|
6
|
+
on-demand and on upload, and an HTML widget for direct uploads.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
@@ -134,7 +134,7 @@ end
|
|
134
134
|
You can pass transformation options to the URLs:
|
135
135
|
|
136
136
|
```rb
|
137
|
-
user.avatar_url(width: 100, height: 100, crop: :fit) # :crop is mandatory
|
137
|
+
user.avatar_url(width: 100, height: 100, crop: :fit) # :crop is mandatory with :width or :height
|
138
138
|
```
|
139
139
|
|
140
140
|
See [Rails image manipulation] for all URL options you can pass in.
|
@@ -47,7 +47,7 @@ class Shrine
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def open(id)
|
50
|
-
|
50
|
+
Down.open(url(id))
|
51
51
|
end
|
52
52
|
|
53
53
|
def read(id)
|
@@ -114,27 +114,15 @@ class Shrine
|
|
114
114
|
if remote?(io)
|
115
115
|
::Cloudinary::Uploader.upload(io.url, **options)
|
116
116
|
else
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
end
|
117
|
+
make_rest_client_recognize_as_file!(io)
|
118
|
+
if large?(io)
|
119
|
+
::Cloudinary::Uploader.upload_large(io, chunk_size: chunk_size, **options)
|
120
|
+
else
|
121
|
+
::Cloudinary::Uploader.upload(io, **options)
|
123
122
|
end
|
124
123
|
end
|
125
124
|
end
|
126
125
|
|
127
|
-
def to_file(io)
|
128
|
-
if io.is_a?(UploadedFile)
|
129
|
-
file = io.download
|
130
|
-
result = yield file
|
131
|
-
file.delete
|
132
|
-
result
|
133
|
-
else
|
134
|
-
yield io
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
126
|
def remote?(io)
|
139
127
|
io.is_a?(UploadedFile) && io.url.to_s =~ /^ftp:|^https?:/
|
140
128
|
end
|
@@ -147,6 +135,11 @@ class Shrine
|
|
147
135
|
{resource_type: resource_type, type: type}
|
148
136
|
end
|
149
137
|
|
138
|
+
def make_rest_client_recognize_as_file!(io)
|
139
|
+
io.instance_eval { def path; "file"; end } unless io.respond_to?(:path)
|
140
|
+
io.instance_eval { def original_filename; "file"; end } if io.respond_to?(:original_filename)
|
141
|
+
end
|
142
|
+
|
150
143
|
def update_id!(result, id)
|
151
144
|
uploaded_id = result.fetch("public_id")
|
152
145
|
uploaded_id = uploaded_id.match("#{prefix}/").post_match if prefix
|
data/shrine-cloudinary.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "shrine-cloudinary"
|
3
|
-
gem.version = "0.4.
|
3
|
+
gem.version = "0.4.2"
|
4
4
|
|
5
5
|
gem.required_ruby_version = ">= 2.1"
|
6
6
|
|
@@ -10,12 +10,12 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["janko.marohnic@gmail.com"]
|
11
11
|
gem.license = "MIT"
|
12
12
|
|
13
|
-
gem.files = Dir["README.md", "LICENSE.txt", "lib/**/*.rb", "
|
13
|
+
gem.files = Dir["README.md", "LICENSE.txt", "lib/**/*.rb", "*.gemspec"]
|
14
14
|
gem.require_path = "lib"
|
15
15
|
|
16
16
|
gem.add_dependency "shrine", "~> 2.0"
|
17
|
-
gem.add_dependency "cloudinary"
|
18
|
-
gem.add_dependency "down", ">=
|
17
|
+
gem.add_dependency "cloudinary", ">= 1.1.7", "< 2"
|
18
|
+
gem.add_dependency "down", ">= 2.3.3"
|
19
19
|
|
20
20
|
gem.add_development_dependency "rake"
|
21
21
|
gem.add_development_dependency "minitest"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shrine-cloudinary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shrine
|
@@ -30,28 +30,34 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.1.7
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '2'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
41
|
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
43
|
+
version: 1.1.7
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: down
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - ">="
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
53
|
+
version: 2.3.3
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
58
|
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
60
|
+
version: 2.3.3
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: rake
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|