Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add without processing and updating some documentation

  • Loading branch information...
commit d8bf1d93a6f54758dd68b7ffc117fc3e6ae73712 1 parent b8cc18d
@knaveofdiamonds knaveofdiamonds authored
Showing with 39 additions and 1 deletion.
  1. +15 −1 lib/encoding_dot_com/facade.rb
  2. +24 −0 spec/facade_spec.rb
View
16 lib/encoding_dot_com/facade.rb
@@ -18,7 +18,7 @@ def initialize(user_id, user_key, http=HttpAdapters::CurbAdapter.new)
end
# Add a video/image to the encoding.com queue to be encoded in
- # various formats.
+ # various formats. Item will be processed after being added.
#
# Source is the source url
# formats is a hash of destination urls => format objects
@@ -31,6 +31,20 @@ def add_and_process(source, formats={})
media_id.to_i if media_id
end
+ # Add a video/image to the encoding.com queue to be encoded in
+ # various formats.
+ #
+ # Source is the source url
+ # formats is a hash of destination urls => format objects
+ def add(source, formats={})
+ response = make_request("AddMediaBenchmark") do |q|
+ q.source source
+ formats.each {|url, format| format.build_xml(q, url) }
+ end
+ media_id = response.xpath("/response/MediaID").text
+ media_id.to_i if media_id
+ end
+
# Returns the status string of a particular media item in the
# encoding.com queue. The status will be for the job as a whole,
# rather than individual ouput formats
View
24 spec/facade_spec.rb
@@ -207,6 +207,30 @@ def expect_response_xml(response_xml)
end
end
+ describe "adding an item to the encoding.com queue but not processing it" do
+ it "should have an action of 'AddMedia'." do
+ expect_xml_with_xpath("/query/action[text()='AddMediaBenchmark']")
+ @facade.add(stub("source"), {})
+ end
+
+ it "should include the source url" do
+ expect_xml_with_xpath("/query/source[text()='http://example.com/']")
+ @facade.add("http://example.com/", {})
+ end
+
+ it "should include the formats provided" do
+ expect_xml_with_xpath("/query/format/output[text()='flv']")
+ format = EncodingDotCom::Format.create("output" => "flv")
+ @facade.add(stub("source"), {stub("destination") => format})
+ end
+
+ it "should include the destination urls in the formats provided" do
+ expect_xml_with_xpath("/query/format/destination[text()='http://example.com']")
+ format = EncodingDotCom::Format.create("output" => "flv")
+ @facade.add(stub("source"), {"http://example.com" => format})
+ end
+ end
+
describe "getting information about a specified media item" do
it "should have an action of 'GetMediaInfo'." do
expect_xml_with_xpath("/query/action[text()='GetMediaInfo']")
Please sign in to comment.
Something went wrong with that request. Please try again.