Skip to content

Commit

Permalink
Merge pull request #10 from tokubai/Fix-AVAILABLE_TYPES-order
Browse files Browse the repository at this point in the history
Add support allow geometry options manual crop with original
  • Loading branch information
shuhei-kaneko authored Sep 6, 2023
2 parents 468e11f + eb49c36 commit 48495ad
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 3 deletions.
14 changes: 14 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
changelog:
categories:
- title: Added
labels:
- add
- title: Changed
labels:
- change
- title: Removed
labels:
- remove
- title: Others
labels:
- "*"
1 change: 1 addition & 0 deletions kinu.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_dependency "faraday"
spec.add_dependency "faraday-multipart"

spec.add_development_dependency "bundler"
spec.add_development_dependency "rake", "~> 10.0"
Expand Down
4 changes: 2 additions & 2 deletions lib/kinu/geometry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ class Geometry
height: :h,
quality: :q,
crop: :c,
original: :o,
middle: :m,
manual_crop: :mc,
width_offset: :wo,
height_offset: :ho,
crop_width: :cw,
crop_height: :ch,
assumption_width: :aw,
original: :o,
middle: :m,
}.freeze

def initialize(options)
Expand Down
1 change: 1 addition & 0 deletions lib/kinu/http_client.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'faraday'
require 'faraday/multipart'
require 'kinu/errors'

module Kinu
Expand Down
2 changes: 1 addition & 1 deletion lib/kinu/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Kinu
VERSION = "2.0.1"
VERSION = "2.0.2"
end
56 changes: 56 additions & 0 deletions spec/kinu/resource_base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,62 @@ module Kinu
end
end

context 'with manual crop option' do
let(:height) { 100 }
let(:width) { 100 }
let(:width_offset) { 10 }
let(:height_offset) { 10 }
let(:crop_width) { 80 }
let(:crop_height) { 80 }
let(:assumption_width) { 100 }
let(:geometry) do
{
width: width,
height: height,
width_offset: width_offset,
height_offset: height_offset,
crop_width: crop_width,
crop_height: crop_height,
assumption_width: assumption_width,
}
end
let(:uri) do
URI::HTTP.build(
host: hostname,
path: "/images/#{name}/w=#{width},h=#{height},wo=#{width_offset},ho=#{height_offset},cw=#{crop_width},ch=#{crop_height},aw=#{assumption_width}/#{id}.jpg"
)
end

it 'returns uri' do
is_expected.to eq(uri)
end

context 'with original' do
let(:geometry) do
{
width: width,
height: height,
width_offset: width_offset,
height_offset: height_offset,
crop_width: crop_width,
crop_height: crop_height,
assumption_width: assumption_width,
original: true,
}
end
let(:uri) do
URI::HTTP.build(
host: hostname,
path: "/images/#{name}/w=#{width},h=#{height},wo=#{width_offset},ho=#{height_offset},cw=#{crop_width},ch=#{crop_height},aw=#{assumption_width},o=true/#{id}.jpg"
)
end

it 'returns uri' do
is_expected.to eq(uri)
end
end
end

context 'with middle' do
let(:geometry) { { middle: true } }
let(:uri) { URI::HTTP.build(host: hostname, path: "/images/#{name}/m=true/#{id}.jpg") }
Expand Down

0 comments on commit 48495ad

Please sign in to comment.