imglab 0.2.0 → 0.2.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
  SHA256:
3
- metadata.gz: cf939223729128b42634757899edf1587158d8ca042246f53eb87a440fca5251
4
- data.tar.gz: 7635dd0f8eab66ab587b95e48665660d836a7a0d598601098b83f884f18bdcdd
3
+ metadata.gz: 78faee0a4ff6558f7ece0d993cac443de2b480e0c230a5586dc6fdbc8c6867db
4
+ data.tar.gz: e6cbb31a3d1e86d8b54cc7c9985b10cd3555886d941ca66925b6752f8bacf51d
5
5
  SHA512:
6
- metadata.gz: 22943677cf74e75e8a77b52f0ac83c5eed5df72c85edb54180eba8c262881f0d264cc60ed40b015dec1b6aeecd7deb9d65d86493162dc6068d3ad8a546a321fa
7
- data.tar.gz: 367a286bd40425c71594cf151a3d9a72d9f1a51291104b123bc778ddd342ed61f1d8572b1ef14c7e827932638051f236b9c99faacee029719e18c1017037f5ea
6
+ metadata.gz: cb456e7d68b9e66ae072ec27f5232c455cd32f040b3b029dbd0d03362709f22bbd3c61a3b2d908589eff85ff28dde67ceba0c7dd2d12ccb458a121ac035c4974
7
+ data.tar.gz: 4053ed5c372ad62d78bd0af9c8d762b0cd9a6dfa9cba6215328d59bfd73e75951b96c97986ee5657a455954d3fd09cc4d8ce91292edda7061a67b006e8e3c329
data/Gemfile CHANGED
@@ -5,4 +5,4 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem "minitest", "~> 5.11.3"
8
- gem "yard", "~> 0.9.26"
8
+ gem "yard", "~> 0.8.7"
data/README.md CHANGED
@@ -234,6 +234,24 @@ Imglab.url(
234
234
 
235
235
  `signature` query parameter will be automatically generated and attached to the nested URL value.
236
236
 
237
+ ### Specifying URLs with expiration timestamp
238
+
239
+ The `expires` parameter allows you to specify a UNIX timestamp in seconds after which the request is expired.
240
+
241
+ If a Ruby `Time` instance is used as value to `expires` parameter it will be automatically converted to UNIX timestamp. In the following example, we specify an expiration time of one hour, adding 3600 seconds to the current time:
242
+
243
+ ```ruby
244
+ Imglab.url("assets", "image.jpeg", width: 500, expires: Time.now.utc + 3600)
245
+ ```
246
+
247
+ If you are using Rails or Active Support you can use it's time helpers:
248
+
249
+ ```ruby
250
+ Imglab.url("assets", "image.jpeg", width: 500, expires: 1.hour.from_now)
251
+ ```
252
+
253
+ > Note: The `expires` parameter should be used in conjunction with secure sources. Otherwise, `expires` value could be tampered with.
254
+
237
255
  ## Generating URLs for on-premises imglab server
238
256
 
239
257
  For on-premises imglab server is possible to define custom sources pointing to your server location.
data/lib/imglab/utils.rb CHANGED
@@ -18,8 +18,7 @@ class Imglab::Utils
18
18
  # @return [Hash]
19
19
  def self.normalize_params(params)
20
20
  params.inject({}) do |normalized_params, value|
21
- normalized_params[dasherize(value[0])] = value[1]
22
- normalized_params
21
+ normalized_params.merge(normalize_param(dasherize(value[0]), value[1]))
23
22
  end
24
23
  end
25
24
 
@@ -38,4 +37,13 @@ class Imglab::Utils
38
37
  def self.dasherize(value)
39
38
  value.to_s.gsub("_", "-")
40
39
  end
40
+
41
+ def self.normalize_param(key, value)
42
+ case
43
+ when key == "expires" && value.instance_of?(Time)
44
+ {key => value.to_i}
45
+ else
46
+ {key => value}
47
+ end
48
+ end
41
49
  end
@@ -1,3 +1,3 @@
1
1
  module Imglab
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imglab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - imglab
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-12 00:00:00.000000000 Z
11
+ date: 2022-06-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Official Ruby library to integrate with imglab services.
14
14
  email:
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  requirements: []
57
- rubygems_version: 3.2.33
57
+ rubygems_version: 3.1.6
58
58
  signing_key:
59
59
  specification_version: 4
60
60
  summary: Official imglab Ruby library.