shrine-imgix 0.3.1 → 0.4.0

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: 18cc56065662c08a09dd0f074c0e446daea64434
4
- data.tar.gz: 65c5a678e1383c639bd7b1d6d11b79c8df7032af
3
+ metadata.gz: 077f2403f448cca03b52cf8e1f07b6915366f557
4
+ data.tar.gz: 72e3f20d5fdd812118dcfd9aea342df7130c0d88
5
5
  SHA512:
6
- metadata.gz: d2c9381b5b8455cef67f42ce9aba4bd4502e47aaf38790dbf480d6d39bf28f81860620aea1c4d60e9e10ac000dbe4459dbb967c365acd05f32049ebcaa0fb3e1
7
- data.tar.gz: bb0d32e5a366b2800a6b1759072b9f611918655557d2b6ec703d384a6de2362829f0c8fbba5fe0adb52c476aba160c360aaf7815dbdc90ae14478188fe17d38b
6
+ metadata.gz: 905d474af4adbbd70b153fbecf3bcbd479c46f7b8e970c4002ca422b2ba16d3dce2ea2bcfd025ca4df6539b44f340b284a841b2f2047d8713e72ec983a34fd71
7
+ data.tar.gz: ec78d945b2506971686faf734139ecbb2bf761681c361d61c09433e29dc6364df9d964541018d7bd3ad6ef45c1a9f1a4b85a8541017c52314ac7ee52cd4a9463
data/README.md CHANGED
@@ -24,16 +24,19 @@ require "shrine/storage/s3"
24
24
 
25
25
  imgix = Shrine::Storage::Imgix.new(
26
26
  storage: Shrine::Storage::S3.new(**s3_options),
27
- api_key: "xzy123",
28
- host: "my-subdomain.imgix.net",
29
- secure_url_token: "abc123", # optional
27
+ include_prefix: true, # set to false if you have prefix configured in Imgix source
28
+ api_key: "xzy123", #
29
+ host: "my-subdomain.imgix.net", # Imgix::Client options
30
+ secure_url_token: "abc123", # optional #
30
31
  )
31
32
 
32
33
  Shrine.storages[:store] = imgix
33
34
  ```
34
35
 
35
- All options other than `:storage` are used for instantiating an `Imgix::Client`,
36
- so see the [imgix] gem for information about all possible options.
36
+ All options other than `:storage` and `:include_prefix` are used for
37
+ instantiating an `Imgix::Client`, see the [imgix] gem for information about all
38
+ possible options. The `:include_prefix` option decides whether the `#prefix`
39
+ of the underlying storage will be included in the generated Imgix URLs.
37
40
 
38
41
  All storage actions are forwarded to the main storage, and deleted files are
39
42
  automatically purged from Imgix. The only method that the Imgix storage
@@ -12,10 +12,11 @@ class Shrine
12
12
  # We initialize the Imgix client, and save the storage. We additionally
13
13
  # save the token as well, because `Imgix::Client` doesn't provide a
14
14
  # reader for the token.
15
- def initialize(storage:, **options)
15
+ def initialize(storage:, include_prefix: false, **options)
16
16
  @client = ::Imgix::Client.new(options)
17
17
  @api_key = options.fetch(:api_key)
18
18
  @storage = storage
19
+ @include_prefix = include_prefix
19
20
 
20
21
  instance_eval do
21
22
  # Purges the file from the source storage after moving it.
@@ -65,6 +66,8 @@ class Shrine
65
66
  #
66
67
  # [reference]: https://www.imgix.com/docs/reference
67
68
  def url(id, **options)
69
+ id = [*@storage.prefix, id].join("/") if @include_prefix
70
+
68
71
  client.path(id).to_url(**options)
69
72
  end
70
73
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-imgix"
3
- gem.version = "0.3.1"
3
+ gem.version = "0.4.0"
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.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-02 00:00:00.000000000 Z
11
+ date: 2017-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shrine