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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13821100dcfca77321605576fbcd0e605ad8b00d
4
- data.tar.gz: 313318ca99ddec0836d2d67aa5aaa5844178f0bb
3
+ metadata.gz: 18cc56065662c08a09dd0f074c0e446daea64434
4
+ data.tar.gz: 65c5a678e1383c639bd7b1d6d11b79c8df7032af
5
5
  SHA512:
6
- metadata.gz: c89621b4f825f34ee15daa18804438d5978311bd116a86d20f59b947181531dbe1e4479dabd981531c662e1a3e66907658bcfea0e525a2505e73100b7c0c273c
7
- data.tar.gz: ba3d4788f98c2ad94f0280b50944c373fcfbdaee8209109723e86f0f103eb0b9ce6483215d3faafaab8adda7d90e3b530e4d68ca6260fd6eabc29b1769e9d8a3
6
+ metadata.gz: d2c9381b5b8455cef67f42ce9aba4bd4502e47aaf38790dbf480d6d39bf28f81860620aea1c4d60e9e10ac000dbe4459dbb967c365acd05f32049ebcaa0fb3e1
7
+ data.tar.gz: bb0d32e5a366b2800a6b1759072b9f611918655557d2b6ec703d384a6de2362829f0c8fbba5fe0adb52c476aba160c360aaf7815dbdc90ae14478188fe17d38b
@@ -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
- # We delegate all methods that are the same.
23
- extend Forwardable
24
- delegate [:upload, :download, :open, :read, :exists?, :clear!] => :storage
50
+ def upload(io, id, **options)
51
+ @storage.upload(io, id, **options)
52
+ end
25
53
 
26
- # Purges the file from the source storage after moving it.
27
- def move(io, id, **options)
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 movable?(io, id)
33
- @storage.movable?(io, id) if @storage.respond_to?(:movable?)
58
+ def exists?(id)
59
+ @storage.exists?(id)
34
60
  end
35
61
 
36
- def multi_delete(ids)
37
- if @storage.respond_to?(:multi_delete)
38
- @storage.multi_delete(ids)
39
- ids.each { |id| purge(id) }
40
- else
41
- ids.each { |id| delete(id) }
42
- end
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-imgix"
3
- gem.version = "0.3.0"
3
+ gem.version = "0.3.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.3.0
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: 2016-09-13 00:00:00.000000000 Z
11
+ date: 2017-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shrine