Skip to content

Commit

Permalink
Preparing for 3.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
gsouza-newstore committed Jan 29, 2019
1 parent b32312f commit 1a621f4
Show file tree
Hide file tree
Showing 14 changed files with 237 additions and 510 deletions.
64 changes: 64 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# - '2.1'
# - '2.2'
# - '2.3'
# - '2.4'
# - '2.5'
# - 'ruby-head'
# - 'jruby'

version: 2
workflows:
version: 2
test:
jobs:
- test-2.1
- test-2.2
- test-2.3
- test-2.4
- test-2.5
- test-jruby
- test-latest
jobs:
test-2.1: &test-template
docker:
- image: circleci/ruby:2.1
working_directory: ~/repo
steps:
- checkout
- run: # Install Ruby dependencies
name: Bundle Install
command: bundle check || bundle install
- run:
name: Run rspec in parallel
command: |
bundle exec rspec --profile 10 \
--format RspecJunitFormatter \
--out test_results/rspec.xml \
--format progress \
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
test-2.2:
<<: *test-template
docker:
- image: circleci/ruby:2.2
test-2.3:
<<: *test-template
docker:
- image: circleci/ruby:2.3
test-2.4:
<<: *test-template
docker:
- image: circleci/ruby:2.4
test-2.5:
<<: *test-template
docker:
- image: circleci/ruby:2.5
test-jruby:
<<: *test-template
docker:
- image: circleci/jruby:latest
environment:
JRUBY_OPTS: "--debug"
test-latest:
<<: *test-template
docker:
- image: circleci/ruby:latest
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.5
2.5.1
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ cache:
sudo: false
rvm:
- '1.9'
- '2.1.8'
- '2.2.4'
- '2.3.0'
- '2.1'
- '2.2'
- '2.3'
- '2.4'
- '2.5'
- 'ruby-head'
- 'jruby'

Expand Down
19 changes: 0 additions & 19 deletions History.txt

This file was deleted.

23 changes: 11 additions & 12 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
= ruby-thumbor {<img src="https://secure.travis-ci.org/thumbor/ruby-thumbor.png?branch=master" alt="Build Status" />}[http://travis-ci.org/thumbor/ruby-thumbor] {<img src="https://gemnasium.com/thumbor/ruby-thumbor.png" alt="Dependency Status" />}[https://gemnasium.com/thumbor/ruby-thumbor] {<img src="https://badge.fury.io/rb/ruby-thumbor.svg" alt="Gem Version" />}[http://badge.fury.io/rb/ruby-thumbor] {<img src="https://coveralls.io/repos/thumbor/ruby-thumbor/badge.svg?branch=master&service=github" alt="Coverage Status" />}[https://coveralls.io/github/thumbor/ruby-thumbor?branch=master]
= ruby-thumbor {<img src="https://secure.travis-ci.org/thumbor/ruby-thumbor.png?branch=master" alt="Build Status" />}[http://travis-ci.org/thumbor/ruby-thumbor] {<img src="https://badge.fury.io/rb/ruby-thumbor.svg" alt="Gem Version" />}[http://badge.fury.io/rb/ruby-thumbor] {<img src="https://coveralls.io/repos/thumbor/ruby-thumbor/badge.svg?branch=master&service=github" alt="Coverage Status" />}[https://coveralls.io/github/thumbor/ruby-thumbor?branch=master]


* http://github.com/thumbor/ruby-thumbor

== WARING:

3.x version won't support old url's

== DESCRIPTION:

ruby-thumbor is the client to the thumbor imaging service (http://github.com/thumbor/thumbor).
Expand All @@ -28,27 +24,30 @@ No dependencies required for regular usage.

gem 'ruby-thumbor'

== BREAKING CHANGE ON 2.0:
== BREAKING CHANGE ON 3.0:

Thumbor::Cascade.new now gets key, image
Old image Url isn't supported anymore
Switch from #url_for to #generate method

== USAGE:

require 'ruby-thumbor'

crypto = Thumbor::CryptoURL.new 'my-security-key'

url = crypto.generate :width => 200, :height => 300, :image => 'my.server.com/path/to/image.jpg'
url = crypto.generate :width => 200, :height => 300, :image => 'remote-image.com/path/to/image.jpg'

# url will contain something like:
# /2913921in321n3k2nj32hjhj3h22/my.server.com/path/to/image.jpg
# /2913921in321n3k2nj32hjhj3h22/remote-image.com/path/to/image.jpg

# Now you just need to concatenate this generated path, with your thumbor server url

or

require 'ruby-thumbor'

image = Thumbor::Cascade.new('my-security-key', 'my.server.com/path/to/image.jpg')
image.width(300).height(200).watermark_filter('http://my-server.com/image.png', 30).generate
image = Thumbor::Cascade.new('my-security-key', 'remote-image.com/path/to/image.jpg')
image.width(300).height(200).watermark_filter('http://remote-image.com/path/to/image.jpg', 30).generate

Available arguments to the generate method:

Expand All @@ -72,7 +71,7 @@ Available arguments to the generate method:
:valign => :top, :middle or :bottom - horizontal alignment that thumbor should use for cropping;

:smart => <bool> - flag that indicates that thumbor should use smart cropping;

:filters => ['blur(20)', 'watermark(http://my.site.com/img.png,-10,-10,50)'] - array of filters and their arguments

If you need more info on what each option does, check thumbor's documentation at https://github.com/thumbor/thumbor/wiki.
Expand Down
12 changes: 4 additions & 8 deletions lib/thumbor/cascade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

module Thumbor
class Cascade
attr_accessor :image, :old_crypto, :options, :filters
attr_accessor :image, :crypto, :options, :filters

@available_options = [
:meta, :crop, :center,
Expand All @@ -19,7 +19,7 @@ class Cascade

extend Forwardable

def_delegators :@old_crypto, :computed_key
def_delegators :@crypto, :computed_key

@available_options.each do |opt|
define_method(opt) do |*args|
Expand All @@ -34,15 +34,11 @@ def initialize(key=false, image=nil)
@image = image
@options = {}
@filters = []
@old_crypto = Thumbor::CryptoURL.new @key
end

def url_for
@old_crypto.url_for prepare_options(@options).merge({image: @image, filters: @filters})
@crypto = Thumbor::CryptoURL.new @key
end

def generate
@old_crypto.generate prepare_options(@options).merge({image: @image, filters: @filters})
@crypto.generate prepare_options(@options).merge({image: @image, filters: @filters})
end

def method_missing(m, *args)
Expand Down
15 changes: 3 additions & 12 deletions lib/thumbor/crypto_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ def computed_key
(@key * 16)[0..15]
end

def pad(s)
s + ("{" * (16 - s.length % 16))
end

def calculate_width_and_height(url_parts, options)
width = options[:width]
height = options[:height]
Expand Down Expand Up @@ -125,7 +121,7 @@ def calculate_centered_crop(options)
options[:crop] = crop
end

def url_for(options, include_hash = true)
def url_for(options)
if not options[:image]
raise 'image is a required argument.'
end
Expand All @@ -135,7 +131,7 @@ def url_for(options, include_hash = true)
if options[:debug]
url_parts.push('debug')
end

if options[:trim]
trim_options = ['trim']
trim_options << options[:trim] unless options[:trim] == true or options[:trim][0] == true
Expand Down Expand Up @@ -193,11 +189,6 @@ def url_for(options, include_hash = true)
url_parts.push("filters:#{ filter_parts.join(':') }")
end

if include_hash
image_hash = Digest::MD5.hexdigest(options[:image])
url_parts.push(image_hash)
end

return url_parts.join('/')
end

Expand All @@ -208,7 +199,7 @@ def url_safe_base64(str)
def generate(options)
thumbor_path = ""

image_options = url_for(options, false)
image_options = url_for(options)
thumbor_path << image_options + '/' unless image_options.empty?

thumbor_path << options[:image]
Expand Down
2 changes: 1 addition & 1 deletion lib/thumbor/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Thumbor
VERSION = '2.0.1'
VERSION = '3.0.0'
end
6 changes: 0 additions & 6 deletions requirements

This file was deleted.

6 changes: 1 addition & 5 deletions ruby-thumbor.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,5 @@ Gem::Specification.new do |s|
s.add_development_dependency('rspec')
s.add_development_dependency('simplecov')
s.add_development_dependency('rake')
if RUBY_VERSION < '2.2'
s.add_development_dependency('json', ['< 2.0'])
s.add_development_dependency('term-ansicolor', ['< 1.4'])
s.add_development_dependency('tins', ['< 1.7'])
end
s.add_development_dependency('rspec_junit_formatter')
end
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
add_filter '/spec/'
end


RSpec.configure do |c|
c.filter_run :focus => true
c.run_all_when_everything_filtered = true
Expand Down
Loading

0 comments on commit 1a621f4

Please sign in to comment.