camo 0.1.0 → 0.2.1
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 +5 -5
- data/CHANGELOG.md +20 -0
- data/LICENSE.txt +2 -1
- data/README.md +23 -36
- data/lib/camo/helper.rb +16 -0
- data/lib/camo/version.rb +1 -1
- data/lib/camo.rb +25 -9
- metadata +14 -64
- data/.gitignore +0 -17
- data/Gemfile +0 -4
- data/Rakefile +0 -10
- data/camo.gemspec +0 -24
- data/test/camo_test.rb +0 -8
- data/test/test_helper.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7f9d615b8d94009e7ec746874527a8a56529d2c27d7d24af586e01adf0a8cab0
|
4
|
+
data.tar.gz: ba444423761f620a91d0a86821310ce7377e5b46fd376f5dd7629989462b88cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0440adf94048d1b3ec14c5b0b6f6546ac9adb0d97fd5e6b88458dc4a02c394f793931054f3c2a54e5b14f6b4c8c31194b973daae13a0fe4060378c9bf49ec443
|
7
|
+
data.tar.gz: e194661a571e4ca51871ebcd2229bb28dc26d982076f4eff07b565eba520d16d8cd1b1e83f65b588f6a65a4a76c3af8e99be0f41f2da36a3b888ed56e7ddf874
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
## 0.2.1 (2022-10-09)
|
2
|
+
|
3
|
+
- Added `key` option to `camo` method
|
4
|
+
|
5
|
+
## 0.2.0 (2022-09-05)
|
6
|
+
|
7
|
+
- Dropped support for Ruby < 2.7
|
8
|
+
|
9
|
+
## 0.1.0 (2016-10-17)
|
10
|
+
|
11
|
+
- Improved performance
|
12
|
+
- Fixed deprecation warning
|
13
|
+
|
14
|
+
## 0.0.2 (2013-11-25)
|
15
|
+
|
16
|
+
- Added support for Sinatra
|
17
|
+
|
18
|
+
## 0.0.1 (2013-11-25)
|
19
|
+
|
20
|
+
- First release
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
# Camo
|
1
|
+
# Camo Ruby
|
2
2
|
|
3
|
-
Ruby client for [Camo](https://github.com/atmos/camo) - the SSL image proxy :lock:
|
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
|
-
|
5
|
+
[](https://github.com/ankane/camo-ruby/actions)
|
6
6
|
|
7
|
-
|
7
|
+
## Installation
|
8
8
|
|
9
9
|
Add this line to your application’s Gemfile:
|
10
10
|
|
@@ -12,6 +12,8 @@ Add this line to your application’s Gemfile:
|
|
12
12
|
gem "camo"
|
13
13
|
```
|
14
14
|
|
15
|
+
## Getting Started
|
16
|
+
|
15
17
|
Add your Camo host and key to your environment or create an initializer `config/initializers/camo.rb`.
|
16
18
|
|
17
19
|
```ruby
|
@@ -22,47 +24,32 @@ ENV["CAMO_KEY"] = "rzsJbU5YxDfdP3FXHjshtgEN"
|
|
22
24
|
You can now use the `camo` method in your views and controllers.
|
23
25
|
|
24
26
|
```erb
|
25
|
-
<%= image_tag camo("
|
26
|
-
```
|
27
|
-
|
28
|
-
It’s that easy!
|
29
|
-
|
30
|
-
## Deploying the Server
|
31
|
-
|
32
|
-
Clone the camo repository.
|
33
|
-
|
34
|
-
```sh
|
35
|
-
git clone https://github.com/atmos/camo.git
|
36
|
-
cd camo
|
37
|
-
```
|
38
|
-
|
39
|
-
Create a new project on [Heroku](https://www.heroku.com/).
|
40
|
-
|
41
|
-
```sh
|
42
|
-
heroku create camo
|
43
|
-
```
|
44
|
-
|
45
|
-
Choose a [random secret key](https://www.random.org/passwords/?num=20&len=24&format=html&rnd=new) and add it to your app.
|
46
|
-
|
47
|
-
```sh
|
48
|
-
heroku config:set CAMO_KEY=rzsJbU5YxDfdP3FXHjshtgEN
|
49
|
-
```
|
50
|
-
|
51
|
-
Open your app to make sure it’s working. You should see the text “hwhat”.
|
52
|
-
|
53
|
-
```sh
|
54
|
-
heroku open
|
27
|
+
<%= image_tag camo("https://placekitten.com/g/200/300") %>
|
55
28
|
```
|
56
29
|
|
57
30
|
## Credit
|
58
31
|
|
59
32
|
Thanks to [Corey Donohoe](https://github.com/atmos) for creating Camo and providing most of the Ruby code for this gem.
|
60
33
|
|
34
|
+
## History
|
35
|
+
|
36
|
+
View the [changelog](CHANGELOG.md)
|
37
|
+
|
61
38
|
## Contributing
|
62
39
|
|
63
40
|
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
64
41
|
|
65
|
-
- [Report bugs](https://github.com/ankane/camo/issues)
|
66
|
-
- Fix bugs and [submit pull requests](https://github.com/ankane/camo/pulls)
|
42
|
+
- [Report bugs](https://github.com/ankane/camo-ruby/issues)
|
43
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/camo-ruby/pulls)
|
67
44
|
- Write, clarify, or fix documentation
|
68
45
|
- Suggest or add new features
|
46
|
+
|
47
|
+
To get started with development:
|
48
|
+
|
49
|
+
```sh
|
50
|
+
git clone https://github.com/ankane/camo-ruby.git
|
51
|
+
cd camo-ruby
|
52
|
+
bundle install
|
53
|
+
go-camo -k 461fbf74af826c3a1020
|
54
|
+
bundle exec rake test
|
55
|
+
```
|
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
@@ -1,21 +1,37 @@
|
|
1
|
-
|
1
|
+
# stdlib
|
2
2
|
require "openssl"
|
3
3
|
|
4
|
+
# modules
|
5
|
+
require "camo/helper"
|
6
|
+
require "camo/version"
|
7
|
+
|
4
8
|
module Camo
|
9
|
+
class << self
|
10
|
+
attr_writer :host, :key
|
11
|
+
|
12
|
+
def host
|
13
|
+
@host ||= ENV["CAMO_HOST"]
|
14
|
+
end
|
5
15
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
"#{ENV["CAMO_HOST"]}/#{hexdigest}/#{encoded_image_url}"
|
16
|
+
def key
|
17
|
+
@key ||= ENV["CAMO_KEY"]
|
18
|
+
end
|
10
19
|
end
|
11
20
|
|
21
|
+
# TODO remove in 0.3.0
|
22
|
+
include Helper
|
12
23
|
end
|
13
24
|
|
14
|
-
if defined?(
|
15
|
-
|
16
|
-
|
25
|
+
if defined?(ActiveSupport)
|
26
|
+
ActiveSupport.on_load(:action_view) do
|
27
|
+
include Camo::Helper
|
28
|
+
end
|
29
|
+
|
30
|
+
ActiveSupport.on_load(:action_controller) do
|
31
|
+
include Camo::Helper
|
32
|
+
end
|
17
33
|
end
|
18
34
|
|
19
35
|
if defined?(Sinatra)
|
20
|
-
Sinatra::Base.helpers Camo
|
36
|
+
Sinatra::Base.helpers Camo::Helper
|
21
37
|
end
|
metadata
CHANGED
@@ -1,79 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.3'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.3'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: minitest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
description: Ruby client for Camo - the SSL image proxy
|
56
|
-
email:
|
57
|
-
- andrew@chartkick.com
|
11
|
+
date: 2022-10-10 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: andrew@ankane.org
|
58
15
|
executables: []
|
59
16
|
extensions: []
|
60
17
|
extra_rdoc_files: []
|
61
18
|
files:
|
62
|
-
-
|
63
|
-
- Gemfile
|
19
|
+
- CHANGELOG.md
|
64
20
|
- LICENSE.txt
|
65
21
|
- README.md
|
66
|
-
- Rakefile
|
67
|
-
- camo.gemspec
|
68
22
|
- lib/camo.rb
|
23
|
+
- lib/camo/helper.rb
|
69
24
|
- lib/camo/version.rb
|
70
|
-
|
71
|
-
- test/test_helper.rb
|
72
|
-
homepage: https://github.com/ankane/camo
|
25
|
+
homepage: https://github.com/ankane/camo-ruby
|
73
26
|
licenses:
|
74
27
|
- MIT
|
75
28
|
metadata: {}
|
76
|
-
post_install_message:
|
29
|
+
post_install_message:
|
77
30
|
rdoc_options: []
|
78
31
|
require_paths:
|
79
32
|
- lib
|
@@ -81,18 +34,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
34
|
requirements:
|
82
35
|
- - ">="
|
83
36
|
- !ruby/object:Gem::Version
|
84
|
-
version: '
|
37
|
+
version: '2.7'
|
85
38
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
39
|
requirements:
|
87
40
|
- - ">="
|
88
41
|
- !ruby/object:Gem::Version
|
89
42
|
version: '0'
|
90
43
|
requirements: []
|
91
|
-
|
92
|
-
|
93
|
-
signing_key:
|
44
|
+
rubygems_version: 3.3.7
|
45
|
+
signing_key:
|
94
46
|
specification_version: 4
|
95
47
|
summary: Ruby client for Camo - the SSL image proxy
|
96
|
-
test_files:
|
97
|
-
- test/camo_test.rb
|
98
|
-
- test/test_helper.rb
|
48
|
+
test_files: []
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/camo.gemspec
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'camo/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "camo"
|
8
|
-
spec.version = Camo::VERSION
|
9
|
-
spec.authors = ["Andrew Kane"]
|
10
|
-
spec.email = ["andrew@chartkick.com"]
|
11
|
-
spec.description = %q{Ruby client for Camo - the SSL image proxy}
|
12
|
-
spec.summary = %q{Ruby client for Camo - the SSL image proxy}
|
13
|
-
spec.homepage = "https://github.com/ankane/camo"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "minitest"
|
24
|
-
end
|
data/test/camo_test.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class CamoTest < Minitest::Test
|
4
|
-
def test_view_helper
|
5
|
-
expected = 'http://camo.example.com/b82e650cfe20239b66f7165e54c3b9036d722aef/68747470733a2f2f7777772e6578616d706c652e636f6d2f706174682f746f2f696d6167652e706e67'
|
6
|
-
assert_equal expected, TestContainer.camo('https://www.example.com/path/to/image.png')
|
7
|
-
end
|
8
|
-
end
|