camo 0.1.0 → 0.2.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
- SHA1:
3
- metadata.gz: 6748e15c3864091c501178e7c4293463b9072e72
4
- data.tar.gz: 0aa6c60538f5f6901749262aa5aeb63f694f7dda
2
+ SHA256:
3
+ metadata.gz: aba71bc194731f9fdf0518c0ae2aebd228c856263e928485678e00990cbf04ab
4
+ data.tar.gz: 31b6017ef24aa772444090702572dd7b7dad32ea8de3a0849ca40dbfc66aafb3
5
5
  SHA512:
6
- metadata.gz: 30d86c057d8d69ef6d61846ec461b0c8f99f30a68eb65d438fc7138b454101fc0ae623c21899913473a4bac6046ceb0e40c9ff1dc24687ae41a3f799fabf8fcd
7
- data.tar.gz: 0784c479193ec3c074eda3eff0755e7cb56efc5101e2b097c1c98cee984ea4d581db8027fc6ec954feb47878788452af2f8f43920f2c4049c252a4d4f9a0ef93
6
+ metadata.gz: de569a318e30cf32a6623274a44a0b1fcc6274872afe55215c1d3049c6fcdc1a118efe76815be21f7c3141db325830e100139e801ca74a729ee9dcfe00adbeca
7
+ data.tar.gz: 33f8bbdefb3ca81398435cc36e83067bdb0f5a82049fbab34885b465aef5a07fca6548d2c23dbca50c91f9648f0800ce1bce52d61894f234266905aca4cf0018
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ ## 0.2.0 (2022-09-05)
2
+
3
+ - Dropped support for Ruby < 2.7
4
+
5
+ ## 0.1.0 (2016-10-17)
6
+
7
+ - Improved performance
8
+ - Fixed deprecation warning
9
+
10
+ ## 0.0.2 (2013-11-25)
11
+
12
+ - Added support for Sinatra
13
+
14
+ ## 0.0.1 (2013-11-25)
15
+
16
+ - First release
data/LICENSE.txt CHANGED
@@ -1,4 +1,5 @@
1
- Copyright (c) 2013 Andrew Kane
1
+ Copyright (c) 2010 Corey Donohoe, Rick Olson
2
+ Copyright (c) 2013-2022 Andrew Kane
2
3
 
3
4
  MIT License
4
5
 
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
- ## Get Started
5
+ [![Build Status](https://github.com/ankane/camo-ruby/workflows/build/badge.svg?branch=master)](https://github.com/ankane/camo-ruby/actions)
6
6
 
7
- **Note:** If you have not set up the Camo server, start with [Deploying the Server](#deploying-the-server).
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("http://placekitten.com/g/200/300") %>
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/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Camo
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/camo.rb CHANGED
@@ -1,19 +1,27 @@
1
- require "camo/version"
1
+ # stdlib
2
2
  require "openssl"
3
3
 
4
- module Camo
4
+ # modules
5
+ require "camo/version"
5
6
 
7
+ module Camo
6
8
  def camo(image_url)
7
- hexdigest = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha1"), ENV["CAMO_KEY"], image_url)
8
- encoded_image_url = image_url.unpack('H*').first
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*")
9
13
  "#{ENV["CAMO_HOST"]}/#{hexdigest}/#{encoded_image_url}"
10
14
  end
11
-
12
15
  end
13
16
 
14
- if defined?(Rails)
15
- ActionView::Base.send :include, Camo
16
- ActionController::Base.send :include, Camo
17
+ if defined?(ActiveSupport)
18
+ ActiveSupport.on_load(:action_view) do
19
+ include Camo
20
+ end
21
+
22
+ ActiveSupport.on_load(:action_controller) do
23
+ include Camo
24
+ end
17
25
  end
18
26
 
19
27
  if defined?(Sinatra)
metadata CHANGED
@@ -1,79 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
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: 2016-10-17 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
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-09-05 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
- - ".gitignore"
63
- - Gemfile
19
+ - CHANGELOG.md
64
20
  - LICENSE.txt
65
21
  - README.md
66
- - Rakefile
67
- - camo.gemspec
68
22
  - lib/camo.rb
69
23
  - lib/camo/version.rb
70
- - test/camo_test.rb
71
- - test/test_helper.rb
72
- homepage: https://github.com/ankane/camo
24
+ homepage: https://github.com/ankane/camo-ruby
73
25
  licenses:
74
26
  - MIT
75
27
  metadata: {}
76
- post_install_message:
28
+ post_install_message:
77
29
  rdoc_options: []
78
30
  require_paths:
79
31
  - lib
@@ -81,18 +33,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
33
  requirements:
82
34
  - - ">="
83
35
  - !ruby/object:Gem::Version
84
- version: '0'
36
+ version: '2.7'
85
37
  required_rubygems_version: !ruby/object:Gem::Requirement
86
38
  requirements:
87
39
  - - ">="
88
40
  - !ruby/object:Gem::Version
89
41
  version: '0'
90
42
  requirements: []
91
- rubyforge_project:
92
- rubygems_version: 2.5.1
93
- signing_key:
43
+ rubygems_version: 3.3.7
44
+ signing_key:
94
45
  specification_version: 4
95
46
  summary: Ruby client for Camo - the SSL image proxy
96
- test_files:
97
- - test/camo_test.rb
98
- - test/test_helper.rb
47
+ test_files: []
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in camo.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new do |t|
5
- t.libs << "test"
6
- t.test_files = FileList['test/**/*_test.rb']
7
- t.verbose = true
8
- end
9
-
10
- task :default => :test
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
data/test/test_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'bundler/setup'
2
- require 'camo'
3
- require 'minitest/autorun'
4
-
5
- ENV['CAMO_HOST'] ||= 'http://camo.example.com'
6
- ENV['CAMO_KEY'] ||= '461fbf74af826c3a1020'
7
-
8
- class TestContainer
9
- extend Camo
10
- end