ruby-thumbor 0.0.2

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.
File without changes
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2011-04-02
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
@@ -0,0 +1,13 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ lib/ruby-thumbor.rb
7
+ script/console
8
+ script/destroy
9
+ script/generate
10
+ spec/ruby-thumbor_spec.rb
11
+ spec/spec.opts
12
+ spec/spec_helper.rb
13
+ tasks/rspec.rake
@@ -0,0 +1,3 @@
1
+
2
+ For more information on ruby-thumbor, see http://ruby-thumbor.rubyforge.org
3
+
@@ -0,0 +1,46 @@
1
+ = ruby-thumbor
2
+
3
+ * http://github.com/heynemann/ruby-thumbor
4
+
5
+ == DESCRIPTION:
6
+
7
+ ruby-thumbor is the client to the thumbor imaging service (http://github.com/globocom/thumbor).
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Generate thumbor encrypted URLs
12
+ * Obtain metadata from image operations in thumbor
13
+
14
+ == SYNOPSIS:
15
+
16
+ crypto => new CryptoUrl key => 'my-security-key'
17
+ url = crypyo.generate width => 200, height => 300, image => 'http://my.server.com/path/to/image.jpg'
18
+
19
+ == INSTALL:
20
+
21
+ * sudo gem install ruby-thumbor
22
+
23
+ == LICENSE:
24
+
25
+ (The MIT License)
26
+
27
+ Copyright (c) 2011 Bernardo Heynemann <heynemann@gmail.com>
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining
30
+ a copy of this software and associated documentation files (the
31
+ 'Software'), to deal in the Software without restriction, including
32
+ without limitation the rights to use, copy, modify, merge, publish,
33
+ distribute, sublicense, and/or sell copies of the Software, and to
34
+ permit persons to whom the Software is furnished to do so, subject to
35
+ the following conditions:
36
+
37
+ The above copyright notice and this permission notice shall be
38
+ included in all copies or substantial portions of the Software.
39
+
40
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
41
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
42
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
43
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
44
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
45
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
46
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/ruby-thumbor'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'ruby-thumbor' do
14
+ self.developer 'Bernardo Heynemann', 'heynemann@gmail.com'
15
+ self.post_install_message = 'PostInstall.txt'
16
+ self.rubyforge_name = 'ruby-thumbor'
17
+ end
18
+
19
+ require 'newgem/tasks'
20
+ Dir['tasks/**/*.rake'].each { |t| load t }
21
+
@@ -0,0 +1,34 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'openssl'
5
+ require 'base64'
6
+ require 'digest/md5'
7
+
8
+ module Thumbor
9
+ VERSION = '0.0.2'
10
+
11
+ class CryptoURL
12
+ attr_accessor :key
13
+
14
+ def initialize(key)
15
+ @key = (key * 16)[0..16]
16
+ end
17
+
18
+ def pad(s)
19
+ s + ("{" * (16 - s.length % 16))
20
+ end
21
+
22
+ def generate(options)
23
+ image_hash = Digest::MD5.hexdigest(options[:image])
24
+ url = pad(options[:width].to_s << 'x' << options[:height].to_s << '/' << image_hash)
25
+ cipher = OpenSSL::Cipher::Cipher.new('aes-128-ecb').encrypt
26
+ cipher.key = @key
27
+ encrypted = cipher.update(url)
28
+ based = Base64.encode64(encrypted).gsub('+', '-').gsub('/', '_').gsub!(/[\n]/, '')
29
+
30
+ '/' << based << '/' << options[:image]
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/ruby-thumbor.rb'}"
9
+ puts "Loading ruby-thumbor gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe Thumbor::CryptoURL, "#new" do
4
+
5
+ it "should create a new instance passing key and keep it" do
6
+ crypto = Thumbor::CryptoURL.new 'my-security-key'
7
+ crypto.key.should == 'my-security-keymy'
8
+ end
9
+
10
+ end
11
+
12
+ describe Thumbor::CryptoURL, "#generate" do
13
+
14
+ it "should create a new instance passing key and keep it" do
15
+ crypto = Thumbor::CryptoURL.new 'my-security-key'
16
+
17
+ url = crypto.generate :width => 300, :height => 200, :image => 'my.domain.com/some/image/url.jpg'
18
+
19
+ url.should == '/qkLDiIbvtiks0Up9n5PACtmpOfX6dPXw4vP4kJU-jTfyF6y1GJBJyp7CHYh1H3R2/my.domain.com/some/image/url.jpg'
20
+ end
21
+
22
+ end
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,2 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+ require 'ruby-thumbor'
@@ -0,0 +1,9 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec) do |t|
4
+ t.rspec_opts = ['color']
5
+ t.rcov = false
6
+ end
7
+
8
+ task :default => :spec
9
+
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-thumbor
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Bernardo Heynemann
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-03 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: hoe
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 35
29
+ segments:
30
+ - 2
31
+ - 9
32
+ - 4
33
+ version: 2.9.4
34
+ type: :development
35
+ version_requirements: *id001
36
+ description: ruby-thumbor is the client to the thumbor imaging service (http://github.com/globocom/thumbor).
37
+ email:
38
+ - heynemann@gmail.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - History.txt
45
+ - Manifest.txt
46
+ - PostInstall.txt
47
+ files:
48
+ - History.txt
49
+ - Manifest.txt
50
+ - PostInstall.txt
51
+ - README.rdoc
52
+ - Rakefile
53
+ - lib/ruby-thumbor.rb
54
+ - script/console
55
+ - script/destroy
56
+ - script/generate
57
+ - spec/ruby-thumbor_spec.rb
58
+ - spec/spec.opts
59
+ - spec/spec_helper.rb
60
+ - tasks/rspec.rake
61
+ - .gemtest
62
+ homepage: http://github.com/heynemann/ruby-thumbor
63
+ licenses: []
64
+
65
+ post_install_message: PostInstall.txt
66
+ rdoc_options:
67
+ - --main
68
+ - README.rdoc
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ requirements: []
90
+
91
+ rubyforge_project: ruby-thumbor
92
+ rubygems_version: 1.7.1
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: ruby-thumbor is the client to the thumbor imaging service (http://github.com/globocom/thumbor).
96
+ test_files: []
97
+