shrine-imgix 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shrine/storage/imgix.rb +43 -26
- data/shrine-imgix.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18cc56065662c08a09dd0f074c0e446daea64434
|
4
|
+
data.tar.gz: 65c5a678e1383c639bd7b1d6d11b79c8df7032af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2c9381b5b8455cef67f42ce9aba4bd4502e47aaf38790dbf480d6d39bf28f81860620aea1c4d60e9e10ac000dbe4459dbb967c365acd05f32049ebcaa0fb3e1
|
7
|
+
data.tar.gz: bb0d32e5a366b2800a6b1759072b9f611918655557d2b6ec703d384a6de2362829f0c8fbba5fe0adb52c476aba160c360aaf7815dbdc90ae14478188fe17d38b
|
data/lib/shrine/storage/imgix.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "imgix"
|
2
|
-
require "forwardable"
|
3
2
|
require "net/http"
|
4
3
|
require "uri"
|
5
4
|
|
@@ -17,29 +16,56 @@ class Shrine
|
|
17
16
|
@client = ::Imgix::Client.new(options)
|
18
17
|
@api_key = options.fetch(:api_key)
|
19
18
|
@storage = storage
|
19
|
+
|
20
|
+
instance_eval do
|
21
|
+
# Purges the file from the source storage after moving it.
|
22
|
+
def move(io, id, **options)
|
23
|
+
@storage.move(io, id, **options)
|
24
|
+
io.storage.purge(io.id) if io.storage.is_a?(Storage::Imgix)
|
25
|
+
end if @storage.respond_to?(:move)
|
26
|
+
|
27
|
+
def movable?(io, id)
|
28
|
+
@storage.movable?(io, id)
|
29
|
+
end if @storage.respond_to?(:movable?)
|
30
|
+
|
31
|
+
def download(id)
|
32
|
+
@storage.download(id)
|
33
|
+
end if @storage.respond_to?(:download)
|
34
|
+
|
35
|
+
def presign(*args)
|
36
|
+
@storage.presign(*args)
|
37
|
+
end if @storage.respond_to?(:presign)
|
38
|
+
|
39
|
+
def multi_delete(ids)
|
40
|
+
@storage.multi_delete(ids)
|
41
|
+
ids.each { |id| purge(id) }
|
42
|
+
end if @storage.respond_to?(:multi_delete)
|
43
|
+
|
44
|
+
def clear!(*args)
|
45
|
+
@storage.clear!(*args)
|
46
|
+
end if @storage.respond_to?(:clear!)
|
47
|
+
end
|
20
48
|
end
|
21
49
|
|
22
|
-
|
23
|
-
|
24
|
-
|
50
|
+
def upload(io, id, **options)
|
51
|
+
@storage.upload(io, id, **options)
|
52
|
+
end
|
25
53
|
|
26
|
-
|
27
|
-
|
28
|
-
@storage.move(io, id, **options)
|
29
|
-
io.storage.purge(io.id) if io.storage.is_a?(Storage::Imgix)
|
54
|
+
def open(id)
|
55
|
+
@storage.open(id)
|
30
56
|
end
|
31
57
|
|
32
|
-
def
|
33
|
-
@storage.
|
58
|
+
def exists?(id)
|
59
|
+
@storage.exists?(id)
|
34
60
|
end
|
35
61
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
62
|
+
# Generates an Imgix URL to the file. All options passed in will be
|
63
|
+
# transformed into URL parameters, check out the [reference] for all
|
64
|
+
# available query parameters.
|
65
|
+
#
|
66
|
+
# [reference]: https://www.imgix.com/docs/reference
|
67
|
+
def url(id, **options)
|
68
|
+
client.path(id).to_url(**options)
|
43
69
|
end
|
44
70
|
|
45
71
|
# Purges the deleted file.
|
@@ -56,15 +82,6 @@ class Shrine
|
|
56
82
|
post(uri, "url" => url(id))
|
57
83
|
end
|
58
84
|
|
59
|
-
# Generates an Imgix URL to the file. All options passed in will be
|
60
|
-
# transformed into URL parameters, check out the [reference] for all
|
61
|
-
# available query parameters.
|
62
|
-
#
|
63
|
-
# [reference]: https://www.imgix.com/docs/reference
|
64
|
-
def url(id, **options)
|
65
|
-
client.path(id).to_url(**options)
|
66
|
-
end
|
67
|
-
|
68
85
|
private
|
69
86
|
|
70
87
|
def post(uri, params = {})
|
data/shrine-imgix.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shrine-imgix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shrine
|