camo 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/lib/camo/helper.rb +16 -0
- data/lib/camo/version.rb +1 -1
- data/lib/camo.rb +15 -10
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32a27bb525c18f8b970e7e7ad29c0dff1d26239b90d44da82390d7836aeae107
|
4
|
+
data.tar.gz: c3a18682fea7f40a1360f1fb3e5acb7fcc947ee149370f68281bbd4835669431
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2df01fe4b0e018de37ba1e464d67d56b8b1b0cd36d6892c2ef8cde366d43970d7d13c8e9715745a330415752a0e487369ecdeb1b7e3097de9f86c5629e1700cf
|
7
|
+
data.tar.gz: 1c15ad4d99c8ed8786ed1b26fcb693f79a9705e87928feeaea0a03699135289929b0dd00ec512dd8da25d1e43b7a0de847cf20877d46bf5a735e7504900e6b8f
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Ruby client for [Camo](https://github.com/atmos/camo) and [Go-Camo](https://github.com/cactus/go-camo) - the SSL image proxy :lock:
|
4
4
|
|
5
|
-
[![Build Status](https://github.com/ankane/camo-ruby/workflows/build/badge.svg
|
5
|
+
[![Build Status](https://github.com/ankane/camo-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/camo-ruby/actions)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
data/lib/camo/helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Camo
|
2
|
+
module Helper
|
3
|
+
def camo(image_url, key: nil)
|
4
|
+
key ||= Camo.key
|
5
|
+
host = Camo.host
|
6
|
+
|
7
|
+
raise "No CAMO_KEY" unless key
|
8
|
+
raise "No CAMO_HOST" unless host
|
9
|
+
|
10
|
+
# TODO support base64 encoding
|
11
|
+
hexdigest = OpenSSL::HMAC.hexdigest("sha1", key, image_url)
|
12
|
+
encoded_image_url = image_url.unpack1("H*")
|
13
|
+
"#{host}/#{hexdigest}/#{encoded_image_url}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/camo/version.rb
CHANGED
data/lib/camo.rb
CHANGED
@@ -2,28 +2,33 @@
|
|
2
2
|
require "openssl"
|
3
3
|
|
4
4
|
# modules
|
5
|
-
|
5
|
+
require_relative "camo/helper"
|
6
|
+
require_relative "camo/version"
|
6
7
|
|
7
8
|
module Camo
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
class << self
|
10
|
+
attr_writer :host, :key
|
11
|
+
|
12
|
+
def host
|
13
|
+
@host ||= ENV["CAMO_HOST"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def key
|
17
|
+
@key ||= ENV["CAMO_KEY"]
|
18
|
+
end
|
14
19
|
end
|
15
20
|
end
|
16
21
|
|
17
22
|
if defined?(ActiveSupport)
|
18
23
|
ActiveSupport.on_load(:action_view) do
|
19
|
-
include Camo
|
24
|
+
include Camo::Helper
|
20
25
|
end
|
21
26
|
|
22
27
|
ActiveSupport.on_load(:action_controller) do
|
23
|
-
include Camo
|
28
|
+
include Camo::Helper
|
24
29
|
end
|
25
30
|
end
|
26
31
|
|
27
32
|
if defined?(Sinatra)
|
28
|
-
Sinatra::Base.helpers Camo
|
33
|
+
Sinatra::Base.helpers Camo::Helper
|
29
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: andrew@ankane.org
|
@@ -20,6 +20,7 @@ files:
|
|
20
20
|
- LICENSE.txt
|
21
21
|
- README.md
|
22
22
|
- lib/camo.rb
|
23
|
+
- lib/camo/helper.rb
|
23
24
|
- lib/camo/version.rb
|
24
25
|
homepage: https://github.com/ankane/camo-ruby
|
25
26
|
licenses:
|
@@ -33,14 +34,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
33
34
|
requirements:
|
34
35
|
- - ">="
|
35
36
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
37
|
+
version: '3.1'
|
37
38
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
39
|
requirements:
|
39
40
|
- - ">="
|
40
41
|
- !ruby/object:Gem::Version
|
41
42
|
version: '0'
|
42
43
|
requirements: []
|
43
|
-
rubygems_version: 3.
|
44
|
+
rubygems_version: 3.5.16
|
44
45
|
signing_key:
|
45
46
|
specification_version: 4
|
46
47
|
summary: Ruby client for Camo - the SSL image proxy
|