Skip to content

Commit

Permalink
Add support for the quality_override parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Amir Tocker committed Dec 6, 2018
1 parent 48c918a commit f454954
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/cloudinary/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,20 @@ def self.update(public_id, options={})
uri = "resources/#{resource_type}/#{type}/#{public_id}"
update_options = {
:access_control => Cloudinary::Utils.json_array_param(options[:access_control]),
:tags => options[:tags] && Cloudinary::Utils.build_array(options[:tags]).join(","),
:auto_tagging => options[:auto_tagging] && options[:auto_tagging].to_f,
:background_removal => options[:background_removal],
:categorization => options[:categorization],
:context => Cloudinary::Utils.encode_context(options[:context]),
:face_coordinates => Cloudinary::Utils.encode_double_array(options[:face_coordinates]),
:custom_coordinates => Cloudinary::Utils.encode_double_array(options[:custom_coordinates]),
:detection => options[:detection],
:face_coordinates => Cloudinary::Utils.encode_double_array(options[:face_coordinates]),
:moderation_status => options[:moderation_status],
:raw_convert => options[:raw_convert],
:notification_url => options[:notification_url],
:quality_override => options[:quality_override],
:ocr => options[:ocr],
:categorization => options[:categorization],
:detection => options[:detection],
:raw_convert => options[:raw_convert],
:similarity_search => options[:similarity_search],
:background_removal => options[:background_removal],
:auto_tagging => options[:auto_tagging] && options[:auto_tagging].to_f,
:notification_url => options[:notification_url]
:tags => options[:tags] && Cloudinary::Utils.build_array(options[:tags]).join(",")
}
call_api(:post, uri, update_options, options)
end
Expand Down
1 change: 1 addition & 0 deletions lib/cloudinary/uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def self.build_upload_params(options)
:phash => Cloudinary::Utils.as_safe_bool(options[:phash]),
:proxy => options[:proxy],
:public_id => options[:public_id],
:quality_override => options[:quality_override],
:raw_convert => options[:raw_convert],
:responsive_breakpoints => Cloudinary::Utils.generate_responsive_breakpoints_string(options[:responsive_breakpoints]),
:return_delete_token => Cloudinary::Utils.as_safe_bool(options[:return_delete_token]),
Expand Down
8 changes: 8 additions & 0 deletions spec/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@
Cloudinary::Api.update("public_id", {:auto_tagging => 0.5})
end

it "should support quality_override" do
['auto:advanced', 'auto:best', '80:420', 'none'].each do |q|
expected = {[:payload, :quality_override] => q}
expect(RestClient::Request).to receive(:execute).with(deep_hash_value(expected))
Cloudinary::Api.update Pathname.new(TEST_IMG), :quality_override => q
end
end

it "should support listing by moderation kind and value" do
expect(RestClient::Request).to receive(:execute).with(deep_hash_value([:url] => /.*manual\/approved$/, [:payload, :max_results] => 1000))
Cloudinary::Api.resources_by_moderation(:manual, :approved, :max_results => 1000)
Expand Down
8 changes: 8 additions & 0 deletions spec/uploader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
expect(result["status"]).to eq("pending")
end

it "should support the quality_override parameter" do
['auto:advanced', 'auto:best', '80:420', 'none'].each do |q|
expected = {[:payload, :quality_override] => q}
expect(RestClient::Request).to receive(:execute).with(deep_hash_value(expected))
Cloudinary::Uploader.upload Pathname.new(TEST_IMG), :quality_override => q
end
end

describe '.rename' do
before(:all) do
@result = Cloudinary::Uploader.upload(TEST_IMG, :tags => [TEST_TAG, TIMESTAMP_TAG])
Expand Down

0 comments on commit f454954

Please sign in to comment.