scene7-wrapper 0.3.2 → 0.3.3

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.2
1
+ 0.3.3
@@ -7,18 +7,21 @@ module Scene7
7
7
  end
8
8
 
9
9
  def self.format_url_params(params)
10
- "scl=#{params[:scale_factor]}&crop=#{params[:x].round},#{params[:y].round},#{params[:width].round},#{params[:height].round}&qlt=#{params[:quality] || 95}"
10
+ require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
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('&')
11
14
  end
12
15
 
13
16
  def self.convert_params_from_scale_first(orig_params, additional_params = {})
14
17
  {}.tap do |params|
15
18
  scale_factor = orig_params[:scale_factor].to_f
16
19
  params[:scale_factor] = 1.0 / scale_factor
17
- params[:height] = orig_params[:height].to_f / scale_factor
18
- params[:width] = orig_params[:width].to_f / scale_factor
19
- params[:x] = orig_params[:x].to_f / scale_factor
20
- params[:y] = orig_params[:y].to_f / scale_factor
21
- params[:quality] = orig_params[:quality] if orig_params[:quality]
20
+ params[:height] = (orig_params[:height].to_f / scale_factor).round
21
+ params[:width] = (orig_params[:width].to_f / scale_factor).round
22
+ params[:x] = (orig_params[:x].to_f / scale_factor).round
23
+ params[:y] = (orig_params[:y].to_f / scale_factor).round
24
+ params[:quality] = orig_params[:quality] || 95
22
25
  end.merge!(additional_params)
23
26
  end
24
27
  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.2"
8
+ s.version = "0.3.3"
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"]
@@ -13,7 +13,7 @@ describe Scene7::Crop do
13
13
  } }
14
14
 
15
15
  it 'includes the scale and scale factor and defaults the quality to 95' do
16
- subject.format_url_params(params).should == "scl=0.5&crop=50,100,250,150&qlt=95"
16
+ subject.format_url_params(params).should == "scl=0.5&crop=50,100,250,150&qlt="
17
17
  end
18
18
 
19
19
  context "when quality is specified" do
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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Rose