animoto 1.0.0 → 1.1.0

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.
Files changed (40) hide show
  1. data/README.md +95 -27
  2. data/lib/animoto/client.rb +48 -26
  3. data/lib/animoto/http_engines/base.rb +2 -14
  4. data/lib/animoto/http_engines/curl_adapter.rb +11 -2
  5. data/lib/animoto/http_engines/net_http_adapter.rb +15 -7
  6. data/lib/animoto/http_engines/patron_adapter.rb +1 -2
  7. data/lib/animoto/http_engines/rest_client_adapter.rb +2 -2
  8. data/lib/animoto/http_engines/typhoeus_adapter.rb +4 -3
  9. data/lib/animoto/manifests/base.rb +53 -3
  10. data/lib/animoto/manifests/directing.rb +6 -19
  11. data/lib/animoto/manifests/directing_and_rendering.rb +6 -19
  12. data/lib/animoto/manifests/rendering.rb +3 -16
  13. data/lib/animoto/manifests/storyboard_bundling.rb +40 -0
  14. data/lib/animoto/manifests/storyboard_unbundling.rb +39 -0
  15. data/lib/animoto/resources/base.rb +2 -2
  16. data/lib/animoto/resources/jobs/base.rb +8 -0
  17. data/lib/animoto/resources/jobs/directing.rb +0 -2
  18. data/lib/animoto/resources/jobs/directing_and_rendering.rb +0 -2
  19. data/lib/animoto/resources/jobs/rendering.rb +0 -2
  20. data/lib/animoto/resources/jobs/storyboard_bundling.rb +29 -0
  21. data/lib/animoto/resources/jobs/storyboard_unbundling.rb +34 -0
  22. data/lib/animoto/support/content_type.rb +1 -1
  23. data/lib/animoto/support/dynamic_class_loader.rb +1 -1
  24. data/lib/animoto/support/errors.rb +29 -0
  25. data/lib/animoto/support/hash.rb +2 -2
  26. data/lib/animoto/support/standard_envelope.rb +4 -2
  27. data/lib/animoto/support/string.rb +2 -2
  28. data/lib/animoto/support/visual.rb +1 -1
  29. data/lib/animoto.rb +1 -1
  30. data/spec/animoto/client_spec.rb +221 -9
  31. data/spec/animoto/http_engines/base_spec.rb +1 -14
  32. data/spec/animoto/manifests/rendering_spec.rb +1 -1
  33. data/spec/animoto/manifests/storyboard_bundling_spec.rb +73 -0
  34. data/spec/animoto/manifests/storyboard_unbundling_spec.rb +71 -0
  35. data/spec/animoto/resources/base_spec.rb +2 -2
  36. data/spec/animoto/resources/jobs/storyboard_bundling_spec.rb +43 -0
  37. data/spec/animoto/resources/jobs/storyboard_unbundling_spec.rb +48 -0
  38. data/spec/spec_helper.rb +4 -3
  39. metadata +14 -7
  40. data/integration/test.rb +0 -49
@@ -1,19 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
2
 
3
- describe Animoto::HTTPEngines::Base do
4
-
5
- describe "autoloading subclasses" do
6
- before do
7
- Animoto::HTTPEngines::Base.const_defined?(:BeefHearts).should be_false
8
- end
9
-
10
-
11
-
12
- after do
13
- Animoto::HTTPEngines::Base.remove_const(:BeefHearts)
14
- end
15
- end
16
-
3
+ describe Animoto::HTTPEngines::Base do
17
4
  describe "making a request" do
18
5
  before do
19
6
  @engine = Animoto::HTTPEngines::Base.new
@@ -41,7 +41,7 @@ describe Animoto::Manifests::Rendering do
41
41
  describe "generating a hash" do
42
42
  before do
43
43
  @storyboard = Animoto::Resources::Storyboard.new
44
- @url = "http://animoto.com/storyboards/1"
44
+ @url = "http://platform.animoto.com/storyboards/1"
45
45
  @storyboard.instance_variable_set(:@url, @url)
46
46
  manifest(@storyboard, :resolution => "720p", :framerate => 24, :format => 'flv')
47
47
  end
@@ -0,0 +1,73 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Animoto::Manifests::StoryboardBundling do
4
+
5
+ describe "initialization" do
6
+ before do
7
+ @storyboard = Animoto::Resources::Storyboard
8
+ end
9
+
10
+ it "should take a storyboard as the first argument" do
11
+ Animoto::Manifests::StoryboardBundling.new(@storyboard).storyboard.should == @storyboard
12
+ end
13
+
14
+ it "should take :http_callback_url and :http_callback_format parameters to set the callback" do
15
+ manifest = Animoto::Manifests::StoryboardBundling.new(@storyboard, :http_callback_url => "http://website.com/callback", :http_callback_format => 'xml')
16
+ manifest.http_callback_url.should == "http://website.com/callback"
17
+ manifest.http_callback_format.should == 'xml'
18
+ end
19
+ end
20
+
21
+ describe "generating a hash" do
22
+ before do
23
+ @storyboard = Animoto::Resources::Storyboard.new
24
+ @url = "http://platform.animoto.com/storyboards/1"
25
+ @storyboard.instance_variable_set(:@url, @url)
26
+ @manifest = Animoto::Manifests::StoryboardBundling.new(@storyboard)
27
+ end
28
+
29
+ it "should have a top-level storyboard_bundling_job object" do
30
+ @manifest.to_hash.should have_key('storyboard_bundling_job')
31
+ @manifest.to_hash['storyboard_bundling_job'].should be_a(Hash)
32
+ end
33
+
34
+ it "should have a storyboard_bundling_manifest object in the storyboard_bundling_job object" do
35
+ @manifest.to_hash['storyboard_bundling_job'].should have_key('storyboard_bundling_manifest')
36
+ @manifest.to_hash['storyboard_bundling_job']['storyboard_bundling_manifest'].should be_a(Hash)
37
+ end
38
+
39
+ it "should have a storyboard_url key in the manifest, whose value is the storyboard's URL" do
40
+ @manifest.to_hash['storyboard_bundling_job']['storyboard_bundling_manifest'].should have_key('storyboard_url')
41
+ @manifest.to_hash['storyboard_bundling_job']['storyboard_bundling_manifest']['storyboard_url'].should == @storyboard.url
42
+ end
43
+
44
+ describe "when a callback is set" do
45
+ before do
46
+ @manifest.http_callback_url = "http://website.com/callback"
47
+ end
48
+
49
+ describe "but a format isn't" do
50
+ it "should raise an error" do
51
+ lambda { @manifest.to_hash }.should raise_error(ArgumentError)
52
+ end
53
+ end
54
+
55
+ describe "and the format is also set" do
56
+ before do
57
+ @manifest.http_callback_format = 'xml'
58
+ end
59
+
60
+ it "should have an http_callback key in the job object, whose value is the HTTP callback URL" do
61
+ @manifest.to_hash['storyboard_bundling_job'].should have_key('http_callback')
62
+ @manifest.to_hash['storyboard_bundling_job']['http_callback'].should == @manifest.http_callback_url
63
+ end
64
+
65
+ it "should have an http_callback_format key in the job object, whose value is the callback's format" do
66
+ @manifest.to_hash['storyboard_bundling_job'].should have_key('http_callback_format')
67
+ @manifest.to_hash['storyboard_bundling_job']['http_callback_format'].should == @manifest.http_callback_format
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ end
@@ -0,0 +1,71 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Animoto::Manifests::StoryboardUnbundling do
4
+
5
+ describe "initialization" do
6
+ before do
7
+ @bundle_url = "http://partner.com/animoto-bundle.zip"
8
+ end
9
+
10
+ it "should take a storyboard as the first argument" do
11
+ Animoto::Manifests::StoryboardUnbundling.new(:bundle_url => @bundle_url).bundle_url.should == @bundle_url
12
+ end
13
+
14
+ it "should take :http_callback_url and :http_callback_format parameters to set the callback" do
15
+ manifest = Animoto::Manifests::StoryboardUnbundling.new(:bundle_url => @bundle_url, :http_callback_url => "http://website.com/callback", :http_callback_format => 'xml')
16
+ manifest.http_callback_url.should == "http://website.com/callback"
17
+ manifest.http_callback_format.should == 'xml'
18
+ end
19
+ end
20
+
21
+ describe "generating a hash" do
22
+ before do
23
+ @bundle_url = "http://partner.com/animoto-bundle.zip"
24
+ @manifest = Animoto::Manifests::StoryboardUnbundling.new(:bundle_url => @bundle_url)
25
+ end
26
+
27
+ it "should have a top-level storyboard_unbundling_job object" do
28
+ @manifest.to_hash.should have_key('storyboard_unbundling_job')
29
+ @manifest.to_hash['storyboard_unbundling_job'].should be_a(Hash)
30
+ end
31
+
32
+ it "should have a storyboard_unbundling_manifest object in the storyboard_unbundling_job object" do
33
+ @manifest.to_hash['storyboard_unbundling_job'].should have_key('storyboard_unbundling_manifest')
34
+ @manifest.to_hash['storyboard_unbundling_job']['storyboard_unbundling_manifest'].should be_a(Hash)
35
+ end
36
+
37
+ it "should have a bundle_url key in the manifest, whose value is the bundle's URL" do
38
+ @manifest.to_hash['storyboard_unbundling_job']['storyboard_unbundling_manifest'].should have_key('bundle_url')
39
+ @manifest.to_hash['storyboard_unbundling_job']['storyboard_unbundling_manifest']['bundle_url'].should == @bundle_url
40
+ end
41
+
42
+ describe "when a callback is set" do
43
+ before do
44
+ @manifest.http_callback_url = "http://website.com/callback"
45
+ end
46
+
47
+ describe "but a format isn't" do
48
+ it "should raise an error" do
49
+ lambda { @manifest.to_hash }.should raise_error(ArgumentError)
50
+ end
51
+ end
52
+
53
+ describe "and the format is also set" do
54
+ before do
55
+ @manifest.http_callback_format = 'xml'
56
+ end
57
+
58
+ it "should have an http_callback key in the job object, whose value is the HTTP callback URL" do
59
+ @manifest.to_hash['storyboard_unbundling_job'].should have_key('http_callback')
60
+ @manifest.to_hash['storyboard_unbundling_job']['http_callback'].should == @manifest.http_callback_url
61
+ end
62
+
63
+ it "should have an http_callback_format key in the job object, whose value is the callback's format" do
64
+ @manifest.to_hash['storyboard_unbundling_job'].should have_key('http_callback_format')
65
+ @manifest.to_hash['storyboard_unbundling_job']['http_callback_format'].should == @manifest.http_callback_format
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ end
@@ -17,7 +17,7 @@ describe Animoto::Resources::Base do
17
17
 
18
18
  describe "identity mapping" do
19
19
  before do
20
- @url = "https://api.animoto.com/videos/1"
20
+ @url = "https://platform.animoto.com/videos/1"
21
21
  @video = Animoto::Resources::Video.new :url => @url
22
22
  @body = {
23
23
  'response' => {
@@ -26,7 +26,7 @@ describe Animoto::Resources::Base do
26
26
  'video' => {
27
27
  'links' => {
28
28
  'download' => "http://animoto.com/videos/1",
29
- 'storyboard' => "https://api.animoto.com/storyboards/1",
29
+ 'storyboard' => "https://platform.animoto.com/storyboards/1",
30
30
  'self' => @url
31
31
  },
32
32
  'metadata' => {
@@ -0,0 +1,43 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
2
+
3
+ describe Animoto::Resources::Jobs::StoryboardBundling do
4
+
5
+ it "should have endpoint /jobs/storyboard_bundling" do
6
+ Animoto::Resources::Jobs::StoryboardBundling.endpoint.should == '/jobs/storyboard_bundling'
7
+ end
8
+
9
+ it "should have content type 'application/vnd.animoto.storyboard_bundling_job" do
10
+ Animoto::Resources::Jobs::StoryboardBundling.content_type.should == 'storyboard_bundling_job'
11
+ end
12
+
13
+ it "should have payload key storyboard_bundling_job" do
14
+ Animoto::Resources::Jobs::StoryboardBundling.payload_key.should == 'storyboard_bundling_job'
15
+ end
16
+
17
+ describe "loading from a response body" do
18
+ before do
19
+ @body = {
20
+ 'response' => {
21
+ 'status' => {
22
+ 'code' => 200
23
+ },
24
+ 'payload' => {
25
+ 'storyboard_bundling_job' => {
26
+ 'state' => 'completed',
27
+ 'links' => {
28
+ 'self' => 'https://platform.animoto.com/jobs/storyboard_bundling/1',
29
+ 'bundle' => 'http://some-kind-of-storage-service.com/animoto-bundles/1'
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ @job = Animoto::Resources::Jobs::StoryboardBundling.load @body
36
+ end
37
+
38
+ it "should set the bundle_url from the body" do
39
+ @job.bundle_url.should == "http://some-kind-of-storage-service.com/animoto-bundles/1"
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,48 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
2
+
3
+ describe Animoto::Resources::Jobs::StoryboardUnbundling do
4
+
5
+ it "should have endpoint /jobs/storyboard_unbundling" do
6
+ Animoto::Resources::Jobs::StoryboardUnbundling.endpoint.should == '/jobs/storyboard_unbundling'
7
+ end
8
+
9
+ it "should have content type 'application/vnd.animoto.storyboard_unbundling_job" do
10
+ Animoto::Resources::Jobs::StoryboardUnbundling.content_type.should == 'storyboard_unbundling_job'
11
+ end
12
+
13
+ it "should have payload key storyboard_unbundling_job" do
14
+ Animoto::Resources::Jobs::StoryboardUnbundling.payload_key.should == 'storyboard_unbundling_job'
15
+ end
16
+
17
+ describe "loading from a response body" do
18
+ before do
19
+ @body = {
20
+ 'response' => {
21
+ 'status' => {
22
+ 'code' => 200
23
+ },
24
+ 'payload' => {
25
+ 'storyboard_unbundling_job' => {
26
+ 'state' => 'completed',
27
+ 'links' => {
28
+ 'self' => 'https://platform.animoto.com/jobs/storyboard_unbundling/1',
29
+ 'storyboard' => 'https://platform.animoto.com/storyboards/1'
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ @job = Animoto::Resources::Jobs::StoryboardUnbundling.load @body
36
+ end
37
+
38
+ it "should set the storyboard_url from the body" do
39
+ @job.storyboard_url.should == "https://platform.animoto.com/storyboards/1"
40
+ end
41
+
42
+ it "should create a storyboard from the storyboard url" do
43
+ @job.storyboard.should be_a(Animoto::Resources::Storyboard)
44
+ @job.storyboard_url.should == @job.storyboard.url
45
+ end
46
+ end
47
+
48
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,10 @@
1
- require 'rubygems'
2
- require 'spec'
1
+ Bundler.setup(:default, :test)
2
+
3
+ require 'rspec'
3
4
  require 'webmock/rspec'
4
5
  require 'mocha'
5
6
 
6
- Spec::Runner.configure do |config|
7
+ RSpec.configure do |config|
7
8
  config.mock_with :mocha
8
9
  config.include WebMock::API
9
10
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: animoto
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Animoto
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-13 00:00:00 -05:00
18
+ date: 2011-02-16 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -34,7 +34,7 @@ dependencies:
34
34
  version: 0.0.0
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
- description: ""
37
+ description: The Animoto API is a RESTful web service that transforms images, videos, music, and text into amazing video presentations. The Animoto API Ruby Client provides a convenient Ruby interface for working with the Animoto RESTful HTTP API.
38
38
  email: theteam@animoto.com
39
39
  executables: []
40
40
 
@@ -44,7 +44,6 @@ extra_rdoc_files: []
44
44
 
45
45
  files:
46
46
  - README.md
47
- - ./integration/test.rb
48
47
  - ./lib/animoto/assets/base.rb
49
48
  - ./lib/animoto/assets/footage.rb
50
49
  - ./lib/animoto/assets/image.rb
@@ -61,11 +60,15 @@ files:
61
60
  - ./lib/animoto/manifests/directing.rb
62
61
  - ./lib/animoto/manifests/directing_and_rendering.rb
63
62
  - ./lib/animoto/manifests/rendering.rb
63
+ - ./lib/animoto/manifests/storyboard_bundling.rb
64
+ - ./lib/animoto/manifests/storyboard_unbundling.rb
64
65
  - ./lib/animoto/resources/base.rb
65
66
  - ./lib/animoto/resources/jobs/base.rb
66
67
  - ./lib/animoto/resources/jobs/directing.rb
67
68
  - ./lib/animoto/resources/jobs/directing_and_rendering.rb
68
69
  - ./lib/animoto/resources/jobs/rendering.rb
70
+ - ./lib/animoto/resources/jobs/storyboard_bundling.rb
71
+ - ./lib/animoto/resources/jobs/storyboard_unbundling.rb
69
72
  - ./lib/animoto/resources/storyboard.rb
70
73
  - ./lib/animoto/resources/video.rb
71
74
  - ./lib/animoto/response_parsers/base.rb
@@ -90,11 +93,15 @@ files:
90
93
  - ./spec/animoto/manifests/directing_and_rendering_spec.rb
91
94
  - ./spec/animoto/manifests/directing_spec.rb
92
95
  - ./spec/animoto/manifests/rendering_spec.rb
96
+ - ./spec/animoto/manifests/storyboard_bundling_spec.rb
97
+ - ./spec/animoto/manifests/storyboard_unbundling_spec.rb
93
98
  - ./spec/animoto/resources/base_spec.rb
94
99
  - ./spec/animoto/resources/jobs/base_spec.rb
95
100
  - ./spec/animoto/resources/jobs/directing_and_rendering_spec.rb
96
101
  - ./spec/animoto/resources/jobs/directing_spec.rb
97
102
  - ./spec/animoto/resources/jobs/rendering_spec.rb
103
+ - ./spec/animoto/resources/jobs/storyboard_bundling_spec.rb
104
+ - ./spec/animoto/resources/jobs/storyboard_unbundling_spec.rb
98
105
  - ./spec/animoto/resources/storyboard_spec.rb
99
106
  - ./spec/animoto/resources/video_spec.rb
100
107
  - ./spec/animoto/response_parsers/json_adapter_spec.rb
@@ -137,6 +144,6 @@ rubyforge_project:
137
144
  rubygems_version: 1.3.7
138
145
  signing_key:
139
146
  specification_version: 3
140
- summary: ""
147
+ summary: Client for working with the Animoto RESTful HTTP API
141
148
  test_files: []
142
149
 
data/integration/test.rb DELETED
@@ -1,49 +0,0 @@
1
- require 'rubygems'
2
- require 'rdiscount'
3
- require 'nokogiri'
4
- require 'yaml'
5
-
6
- puts "Reading in code from README.md"
7
-
8
- readme_path = File.dirname(__FILE__) + '/../README.md'
9
- begin
10
- readme = RDiscount.new(File.read(readme_path))
11
- rescue Errno::ENOENT
12
- raise "README.md not found in #{File.expand_path(readme_path)}!"
13
- end
14
-
15
- begin
16
- credentials = YAML.load(File.read(File.dirname(__FILE__) + '/credentials.yml'))
17
- rescue Errno::ENOENT
18
- raise "Credentials file not found at #{File.expand_path(File.dirname(__FILE__) + '/credentials.yml')}!"
19
- end
20
-
21
- begin
22
- assets = YAML.load(File.read(File.dirname(__FILE__) + '/assets.yml'))
23
- rescue Errno::ENOENT
24
- raise "Assets file not found in at #{File.dirname(__FILE__) + '/assets.yml'}!" unless assets
25
- end
26
-
27
- doc = Nokogiri::HTML(readme.to_html)
28
- example_code_path = '//h3[contains(text(),"basic example")]/following-sibling::pre/code/text()'
29
- code_node = doc.at(example_code_path)
30
-
31
- raise "Example code not found in README (expected at xpath '#{example_code_path}')" unless code_node
32
-
33
- code = code_node.text
34
-
35
- puts "Replacing example credentials with valid ones"
36
- code.sub!(/Client\.new\(.+\)/, %Q{Client.new("#{credentials[:key]}","#{credentials[:secret]}",:endpoint => "#{credentials[:endpoint]}")})
37
-
38
- puts "Replacing example assets with valid ones"
39
- code.gsub!(/Image\.new\(.+\)/) { %Q{Image.new("#{assets[:images].shift}")} }
40
- # Replace the song with a real one
41
- code.sub!(/Song\.new\(.+\)/, %Q{Song.new("#{assets[:song]}")})
42
- # Get rid of the footage (since it won't render right now anyway)
43
- code = code.lines.reject { |l| /Footage\.new/ === l }.join
44
-
45
- puts "Executing example"
46
- eval code
47
-
48
- puts
49
- puts "If you're seeing this, things should have worked fine!"