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 +4 -4
- data/Gemfile +1 -1
- data/README.md +18 -0
- data/lib/imglab/utils.rb +10 -2
- data/lib/imglab/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78faee0a4ff6558f7ece0d993cac443de2b480e0c230a5586dc6fdbc8c6867db
|
4
|
+
data.tar.gz: e6cbb31a3d1e86d8b54cc7c9985b10cd3555886d941ca66925b6752f8bacf51d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb456e7d68b9e66ae072ec27f5232c455cd32f040b3b029dbd0d03362709f22bbd3c61a3b2d908589eff85ff28dde67ceba0c7dd2d12ccb458a121ac035c4974
|
7
|
+
data.tar.gz: 4053ed5c372ad62d78bd0af9c8d762b0cd9a6dfa9cba6215328d59bfd73e75951b96c97986ee5657a455954d3fd09cc4d8ce91292edda7061a67b006e8e3c329
|
data/Gemfile
CHANGED
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
|
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
|
data/lib/imglab/version.rb
CHANGED
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.
|
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-
|
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.
|
57
|
+
rubygems_version: 3.1.6
|
58
58
|
signing_key:
|
59
59
|
specification_version: 4
|
60
60
|
summary: Official imglab Ruby library.
|