zencoder 1.0.5 → 1.0.6
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/History.txt +4 -0
- data/Rakefile +2 -2
- data/lib/zencoder.rb +5 -3
- data/test/test_zencoder.rb +19 -0
- metadata +8 -8
data/History.txt
CHANGED
@@ -23,3 +23,7 @@
|
|
23
23
|
=== 1.0.5 / 2010-05-20
|
24
24
|
|
25
25
|
* Pulled some recipes contributed by Brian Maddy
|
26
|
+
|
27
|
+
=== 1.0.6 / 2010-05-28
|
28
|
+
|
29
|
+
* Added support for toplevel options. {:test=>1} for example. This breaks the old api. The recipes argument to submit_job() must be present, and an optional :opts hash will be merged into the toplevel Zencoder request hash.
|
data/Rakefile
CHANGED
@@ -10,8 +10,8 @@ Hoe.plugin :hg
|
|
10
10
|
|
11
11
|
Hoe.spec 'zencoder' do
|
12
12
|
developer('McClain Looney', 'm@loonsoft.com')
|
13
|
-
extra_deps << %w(rest-client >=1.
|
14
|
-
extra_deps << %w(json >=1.
|
13
|
+
extra_deps << %w(rest-client >=1.5.1)
|
14
|
+
extra_deps << %w(json >=1.4.3)
|
15
15
|
extra_dev_deps << %w(shoulda >=2.10.0)
|
16
16
|
end
|
17
17
|
|
data/lib/zencoder.rb
CHANGED
@@ -13,18 +13,20 @@ class Zencoder
|
|
13
13
|
# Currently https://app.zencoder.com/api This means you have to have ssl built into your ruby!
|
14
14
|
API_URL = 'https://app.zencoder.com/api'
|
15
15
|
|
16
|
-
VERSION = '1.0.
|
16
|
+
VERSION = '1.0.6' #:nodoc:
|
17
17
|
# Submits a job to zencoder.
|
18
18
|
# The recipe should be an instance or array of instances of ZencoderAPI::Recipe
|
19
19
|
# Exceptions are not handled, but rather propagated upwards.
|
20
20
|
#
|
21
21
|
# If a block is provided, it is yielded the job configuration as a hash.
|
22
|
+
# Recipes is an array of Recipe objects.
|
23
|
+
# opts can be used to override toplevel Zencoder api options
|
22
24
|
class <<self
|
23
|
-
def submit_job(apikey, src,
|
25
|
+
def submit_job(apikey, src, recipes, opts={})
|
24
26
|
jorb = {:api_key=>apikey, :input => src, :output=>[recipes].flatten.map(&:to_hash)}
|
27
|
+
jorb.merge!(opts)
|
25
28
|
yield jorb if block_given?
|
26
29
|
JSON.parse(RestClient.post(API_URL+'/jobs', jorb.to_json, {:content_type=>:json, :accept=>:json}))
|
27
30
|
end
|
28
31
|
end
|
29
|
-
|
30
32
|
end
|
data/test/test_zencoder.rb
CHANGED
@@ -33,6 +33,24 @@ class TestZencoder < Test::Unit::TestCase
|
|
33
33
|
assert_equal Hash, h.class
|
34
34
|
end
|
35
35
|
|
36
|
+
should "be able to submit a job with opts" do
|
37
|
+
RestClient.expects(:post).with(kind_of(String), kind_of(String), kind_of(Hash)){|x,y,z|
|
38
|
+
assert_equal x, 'https://app.zencoder.com/api/jobs'
|
39
|
+
body = JSON.parse(y)
|
40
|
+
assert_equal body['input'], @src
|
41
|
+
assert_equal @base_url, body['output'][0]['base_url']
|
42
|
+
assert_equal @base_url, body['output'][1]['base_url']
|
43
|
+
assert_equal 'web', body['output'][1]['label']
|
44
|
+
assert_equal 'iphone', body['output'][0]['label']
|
45
|
+
assert_equal @apikey, body['api_key']
|
46
|
+
assert_equal 1, body['test']
|
47
|
+
assert_equal :json, z[:content_type]
|
48
|
+
assert_equal :json, z[:accept]
|
49
|
+
true
|
50
|
+
}.returns(@resp)
|
51
|
+
Zencoder.submit_job(@apikey, @src, [@recipe, @recipe2], :test => 1)
|
52
|
+
end
|
53
|
+
|
36
54
|
should "be able to submit a job" do
|
37
55
|
RestClient.expects(:post).with(kind_of(String), kind_of(String), kind_of(Hash)){|x,y,z|
|
38
56
|
assert_equal x, 'https://app.zencoder.com/api/jobs'
|
@@ -43,6 +61,7 @@ class TestZencoder < Test::Unit::TestCase
|
|
43
61
|
assert_equal body['output'][1]['label'], 'web'
|
44
62
|
assert_equal body['output'][0]['label'], 'iphone'
|
45
63
|
assert_equal body['api_key'], @apikey
|
64
|
+
assert_nil body['test']
|
46
65
|
assert_equal z[:content_type], :json
|
47
66
|
assert_equal z[:accept], :json
|
48
67
|
true
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 6
|
9
|
+
version: 1.0.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- McClain Looney
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-28 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,9 +26,9 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
segments:
|
28
28
|
- 1
|
29
|
-
-
|
30
|
-
-
|
31
|
-
version: 1.
|
29
|
+
- 5
|
30
|
+
- 1
|
31
|
+
version: 1.5.1
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
@@ -40,9 +40,9 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
segments:
|
42
42
|
- 1
|
43
|
-
-
|
43
|
+
- 4
|
44
44
|
- 3
|
45
|
-
version: 1.
|
45
|
+
version: 1.4.3
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
48
|
- !ruby/object:Gem::Dependency
|