shrine-imgix 0.1.0 → 0.1.1

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: c8f5f6f3c73706b3e362d2c8cb015d6bc8a3ae38
4
- data.tar.gz: 5c10ec076e3dfe3d17be76f2490255612de1cccd
3
+ metadata.gz: 2d6e574f6f0188cc167c2e7df9b1f590b2e93398
4
+ data.tar.gz: 23e4c1db6334b44e904d10404b80f08ea83cd0bb
5
5
  SHA512:
6
- metadata.gz: 5926511ad322c97686b4bdfea29b1cf950341b3e7ad3bbbe9c56d1550dd0cba023ad0f347558556775a8625ef7ab10aca5e0c8c86e0a49293dc445de5240dcad
7
- data.tar.gz: 37d13abbba5afe89a4f2f656cf2e7a02c13eb40ae2985c4b7e612a25c47331a80840919645c12e424778a94df467ba1cadfe570282ffe89e93b58eb6a20224a9
6
+ metadata.gz: d85786dd62c82e2d856f39a5efa54f0df7cc919626d7d051b0d900deac9a1870b690bb0cf8cb21476413830b693f070d1ca3e90422db928ef2bdc7cbe6f0fc8d
7
+ data.tar.gz: 5261c00955dac3d6223141183fbc65230cc29341a0102a3e9aa92cda2d34293af84692bffcb49a9b5da99f9cc895914e9f0fd6c4a2a90b48fe203095beb0c1af
@@ -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-specific method
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-imgix"
3
- gem.version = "0.1.0"
3
+ gem.version = "0.1.1"
4
4
 
5
5
  gem.required_ruby_version = ">= 2.1"
6
6
 
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.0
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-05 00:00:00.000000000 Z
11
+ date: 2015-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: imgix