scene7-wrapper 0.3.3 → 0.3.4

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
@@ -3,17 +3,18 @@ require 'active_support/core_ext'
3
3
  module Scene7
4
4
  module Crop
5
5
  def self.convert_from_scale_first_and_format(params, additional_params = {})
6
- format_url_params convert_params_from_scale_first(params, additional_params)
6
+ format_url_params convert_params_from_scale_first(params), additional_params
7
7
  end
8
8
 
9
- def self.format_url_params(params)
9
+ def self.format_url_params(params, additional_params = {})
10
10
  require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
11
11
 
12
- basic = "scl=#{params.delete(:scale_factor)}&crop=#{params.delete(:x).round},#{params.delete(:y).round},#{params.delete(:width).round},#{params.delete(:height).round}&qlt=#{params.delete(:quality)}"
13
- basic << params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
12
+ query = "scl=#{params.delete(:scale_factor)}&crop=#{params.delete(:x).round},#{params.delete(:y).round},#{params.delete(:width).round},#{params.delete(:height).round}&qlt=#{params.delete(:quality)}"
13
+ query << "&" + additional_params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') if additional_params.length > 0
14
+ query
14
15
  end
15
16
 
16
- def self.convert_params_from_scale_first(orig_params, additional_params = {})
17
+ def self.convert_params_from_scale_first(orig_params)
17
18
  {}.tap do |params|
18
19
  scale_factor = orig_params[:scale_factor].to_f
19
20
  params[:scale_factor] = 1.0 / scale_factor
@@ -22,7 +23,7 @@ module Scene7
22
23
  params[:x] = (orig_params[:x].to_f / scale_factor).round
23
24
  params[:y] = (orig_params[:y].to_f / scale_factor).round
24
25
  params[:quality] = orig_params[:quality] || 95
25
- end.merge!(additional_params)
26
+ end
26
27
  end
27
28
  end
28
29
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{scene7-wrapper}
8
- s.version = "0.3.3"
8
+ s.version = "0.3.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian Rose", "Jim Whiteman"]
@@ -57,8 +57,9 @@ describe Scene7::Crop do
57
57
  } }
58
58
 
59
59
  it "converts, then formats" do
60
- subject.convert_from_scale_first_and_format(params).should == "scl=0.5&crop=50,125,225,150&qlt=70"
60
+ subject.convert_from_scale_first_and_format(params, :extra => true).should == "scl=0.5&crop=50,125,225,150&qlt=70&extra=true"
61
61
  end
62
+
62
63
  end
63
64
  end
64
65
 
@@ -87,11 +88,6 @@ describe Scene7::Crop do
87
88
  it "converts the top coordinate from the scale-first style" do
88
89
  @result[:y].should == 125
89
90
  end
90
-
91
- it "accepts additional params" do
92
- @result = subject.convert_params_from_scale_first(params, {:extra => true})
93
- @result[:extra].should == true
94
- end
95
91
  end
96
92
  end
97
93
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scene7-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 3
10
- version: 0.3.3
9
+ - 4
10
+ version: 0.3.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Rose