camo 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aba71bc194731f9fdf0518c0ae2aebd228c856263e928485678e00990cbf04ab
4
- data.tar.gz: 31b6017ef24aa772444090702572dd7b7dad32ea8de3a0849ca40dbfc66aafb3
3
+ metadata.gz: 32a27bb525c18f8b970e7e7ad29c0dff1d26239b90d44da82390d7836aeae107
4
+ data.tar.gz: c3a18682fea7f40a1360f1fb3e5acb7fcc947ee149370f68281bbd4835669431
5
5
  SHA512:
6
- metadata.gz: de569a318e30cf32a6623274a44a0b1fcc6274872afe55215c1d3049c6fcdc1a118efe76815be21f7c3141db325830e100139e801ca74a729ee9dcfe00adbeca
7
- data.tar.gz: 33f8bbdefb3ca81398435cc36e83067bdb0f5a82049fbab34885b465aef5a07fca6548d2c23dbca50c91f9648f0800ce1bce52d61894f234266905aca4cf0018
6
+ metadata.gz: 2df01fe4b0e018de37ba1e464d67d56b8b1b0cd36d6892c2ef8cde366d43970d7d13c8e9715745a330415752a0e487369ecdeb1b7e3097de9f86c5629e1700cf
7
+ data.tar.gz: 1c15ad4d99c8ed8786ed1b26fcb693f79a9705e87928feeaea0a03699135289929b0dd00ec512dd8da25d1e43b7a0de847cf20877d46bf5a735e7504900e6b8f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.3.0 (2024-10-22)
2
+
3
+ - Dropped support for Ruby < 3.1
4
+
5
+ ## 0.2.1 (2022-10-09)
6
+
7
+ - Added `key` option to `camo` method
8
+
1
9
  ## 0.2.0 (2022-09-05)
2
10
 
3
11
  - Dropped support for Ruby < 2.7
data/LICENSE.txt CHANGED
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2010 Corey Donohoe, Rick Olson
2
- Copyright (c) 2013-2022 Andrew Kane
2
+ Copyright (c) 2013-2024 Andrew Kane
3
3
 
4
4
  MIT License
5
5
 
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?branch=master)](https://github.com/ankane/camo-ruby/actions)
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
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Camo
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/camo.rb CHANGED
@@ -2,28 +2,33 @@
2
2
  require "openssl"
3
3
 
4
4
  # modules
5
- require "camo/version"
5
+ require_relative "camo/helper"
6
+ require_relative "camo/version"
6
7
 
7
8
  module Camo
8
- def camo(image_url)
9
- raise "No CAMO_KEY" unless ENV["CAMO_KEY"]
10
- raise "No CAMO_HOST" unless ENV["CAMO_HOST"]
11
- hexdigest = OpenSSL::HMAC.hexdigest("sha1", ENV["CAMO_KEY"], image_url)
12
- encoded_image_url = image_url.unpack1("H*")
13
- "#{ENV["CAMO_HOST"]}/#{hexdigest}/#{encoded_image_url}"
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.2.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: 2022-09-05 00:00:00.000000000 Z
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: '2.7'
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.3.7
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