shrine-imgix 0.1.0 → 0.1.1
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 +4 -4
- data/lib/shrine/storage/imgix.rb +13 -2
- 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: 2d6e574f6f0188cc167c2e7df9b1f590b2e93398
|
4
|
+
data.tar.gz: 23e4c1db6334b44e904d10404b80f08ea83cd0bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d85786dd62c82e2d856f39a5efa54f0df7cc919626d7d051b0d900deac9a1870b690bb0cf8cb21476413830b693f070d1ca3e90422db928ef2bdc7cbe6f0fc8d
|
7
|
+
data.tar.gz: 5261c00955dac3d6223141183fbc65230cc29341a0102a3e9aa92cda2d34293af84692bffcb49a9b5da99f9cc895914e9f0fd6c4a2a90b48fe203095beb0c1af
|
data/lib/shrine/storage/imgix.rb
CHANGED
@@ -10,30 +10,36 @@ class Shrine
|
|
10
10
|
|
11
11
|
attr_reader :client, :storage
|
12
12
|
|
13
|
+
# We initialize the Imgix client, and save the storage. We additionally
|
14
|
+
# save the token as well, because `Imgix::Client` doesn't provide a
|
15
|
+
# reader for the token.
|
13
16
|
def initialize(storage:, **options)
|
14
17
|
@client = ::Imgix::Client.new(options)
|
15
18
|
@token = options[:token]
|
16
19
|
@storage = storage
|
17
20
|
end
|
18
21
|
|
22
|
+
# We delegate all methods that are the same.
|
19
23
|
extend Forwardable
|
20
24
|
delegate [:upload, :download, :open, :read, :exists?, :clear!] => :storage
|
21
25
|
|
26
|
+
# Purges the file from the source storage after moving it.
|
22
27
|
def move(io, id, metadata = {})
|
23
28
|
@storage.move(io, id, metadata)
|
24
|
-
purge(io.id)
|
29
|
+
io.storage.purge(io.id) if io.storage.is_a?(Storage::Imgix)
|
25
30
|
end
|
26
31
|
|
27
32
|
def movable?(io, id)
|
28
33
|
@storage.movable?(io, id) if @storage.respond_to?(:movable?)
|
29
34
|
end
|
30
35
|
|
36
|
+
# Purges the deleted file.
|
31
37
|
def delete(id)
|
32
38
|
@storage.delete(id)
|
33
39
|
purge(id)
|
34
40
|
end
|
35
41
|
|
36
|
-
# Imgix
|
42
|
+
# Removes the file from Imgix, along with the generated versions.
|
37
43
|
def purge(id)
|
38
44
|
uri = URI.parse(PURGE_URL)
|
39
45
|
uri.user = @token
|
@@ -41,6 +47,11 @@ class Shrine
|
|
41
47
|
post(uri, "url" => url(id))
|
42
48
|
end
|
43
49
|
|
50
|
+
# Generates an Imgix URL to the file. All options passed in will be
|
51
|
+
# transformed into URL parameters, check out the [reference] for all
|
52
|
+
# available query parameters.
|
53
|
+
#
|
54
|
+
# [reference]: https://www.imgix.com/docs/reference
|
44
55
|
def url(id, **options)
|
45
56
|
client.path(id).to_url(**options)
|
46
57
|
end
|
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.1.
|
4
|
+
version: 0.1.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: 2015-12-
|
11
|
+
date: 2015-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: imgix
|