animoto 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,38 @@
1
+ Bundler.setup(:default, :test)
2
+
3
+ require 'cucumber'
4
+ require 'rspec'
5
+ require 'mocha'
6
+
7
+ # Use mocha for mocking
8
+ RSpec.configure do |config|
9
+ config.mock_with :mocha
10
+ end
11
+
12
+ # Verify mocha after each scenario
13
+ After do
14
+ Mocha::Mockery.instance.verify(nil)
15
+ Mocha::Mockery.instance.teardown
16
+ Mocha::Mockery.reset_instance
17
+ end
18
+
19
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'animoto', 'client'))
20
+
21
+ module Animoto
22
+ class IntegrationTest
23
+ include Mocha::API
24
+
25
+ def client
26
+ @client ||= begin
27
+ endpoint = case ENV['ANIMOTO_PLATFORM_ENV']
28
+ when 'production' : ''
29
+ when NilClass : '-sandbox'
30
+ else : "-#{ENV['ANIMOTO_PLATFORM_ENV']}"
31
+ end
32
+ Client.new ENV['ANIMOTO_USERNAME'], ENV['ANIMOTO_PASSWORD'], :endpoint => endpoint
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ World { Animoto::IntegrationTest.new }
@@ -15,11 +15,12 @@ module Animoto
15
15
  links = unpack_links(body)
16
16
  params = unpack_rendering_parameters(body)
17
17
  super.merge({
18
- :download_url => links['file'],
19
- :storyboard_url => links['storyboard'],
20
- :format => params['format'],
21
- :framerate => params['framerate'],
22
- :resolution => params['resolution']
18
+ :download_url => links['file'],
19
+ :storyboard_url => links['storyboard'],
20
+ :cover_image_url => links['cover_image'],
21
+ :format => params['format'],
22
+ :framerate => params['framerate'],
23
+ :resolution => params['resolution']
23
24
  })
24
25
  end
25
26
 
@@ -35,6 +36,10 @@ module Animoto
35
36
  # @return [Resources::Storyboard]
36
37
  attr_reader :storyboard
37
38
 
39
+ # In available, the URL to the cover image file.
40
+ # @return [String]
41
+ attr_reader :cover_image_url
42
+
38
43
  # The format of the video.
39
44
  # @return [String]
40
45
  attr_reader :format
@@ -61,6 +66,7 @@ module Animoto
61
66
  @download_url = attributes[:download_url]
62
67
  @storyboard_url = attributes[:storyboard_url]
63
68
  @storyboard = Animoto::Resources::Storyboard.new(:url => @storyboard_url) if @storyboard_url
69
+ @cover_image_url = attributes[:cover_image_url]
64
70
  @format = attributes[:format]
65
71
  @framerate = attributes[:framerate]
66
72
  @resolution = attributes[:resolution]
@@ -7,7 +7,7 @@ module Animoto
7
7
  # @param [Array<Object>] keys the keys to include
8
8
  # @return [Hash{Object=>Object}] a new hash with only the listed keys
9
9
  def only *keys
10
- self.dup.delete_if { |k,v| !keys.include?(k) }
10
+ inject({}) { |h,(k,v)| h.merge(keys.include?(k) ? {k => v} : {}) }
11
11
  end unless {}.respond_to?(:only)
12
12
 
13
13
  # Returns a new hash with all keys from this hash except the listed ones.
@@ -15,7 +15,7 @@ module Animoto
15
15
  # @param [Array<Object>] keys the keys to exclude
16
16
  # @return [Hash{Object=>Object}] a new hash without the listed keys
17
17
  def except *keys
18
- self.dup.delete_if { |k,v| keys.include?(v) }
18
+ inject({}) { |h,(k,v)| h.merge(!keys.include?(v) ? {k => v} : {}) }
19
19
  end unless {}.respond_to?(:except)
20
20
 
21
21
  end
@@ -25,6 +25,7 @@ module Animoto
25
25
  if payload_key = unpack_base_payload(envelope).keys.first
26
26
  klass_name = payload_key.camelize
27
27
  if /(?:Job|Callback)$/ === klass_name
28
+ klass_name.sub!(/(?:Job|Callback)$/, '')
28
29
  Animoto::Resources::Jobs::const_get(klass_name) if Animoto::Resources::Jobs::const_defined?(klass_name)
29
30
  else
30
31
  Animoto::Resources::const_get(klass_name) if Animoto::Resources::const_defined?(klass_name)
@@ -111,9 +112,7 @@ module Animoto
111
112
  :errors => unpack_status(body)['errors'] || []
112
113
  }
113
114
  end
114
- end
115
-
116
- extend ClassMethods
115
+ end
117
116
  end
118
117
  end
119
118
  end
data/lib/animoto.rb CHANGED
@@ -6,6 +6,6 @@ module Animoto
6
6
  #
7
7
  # @return [String]
8
8
  def self.version
9
- "1.1.1"
9
+ "1.2.0"
10
10
  end
11
11
  end
@@ -2,4 +2,26 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
3
  describe Animoto::Assets::Base do
4
4
 
5
+ describe "initialization" do
6
+ before do
7
+ @source = 'http://website.com/asset'
8
+ @asset = Animoto::Assets::Base.new @source
9
+ end
10
+
11
+ it "should set the source from the given source url" do
12
+ @asset.source.should == @source
13
+ end
14
+ end
15
+
16
+ describe "#to_hash" do
17
+ before do
18
+ @asset = Animoto::Assets::Base.new 'http://website.com/asset'
19
+ end
20
+
21
+ it "should have a 'source_url' key with the url" do
22
+ @asset.to_hash.should have_key('source_url')
23
+ @asset.to_hash['source_url'].should == @asset.source
24
+ end
25
+ end
26
+
5
27
  end
@@ -20,7 +20,7 @@ describe Animoto::Manifests::DirectingAndRendering do
20
20
  manifest.to_hash.should have_key('directing_and_rendering_job')
21
21
  manifest.to_hash['directing_and_rendering_job'].should be_a(Hash)
22
22
  end
23
-
23
+
24
24
  describe "when the callback url is set" do
25
25
  before do
26
26
  manifest.http_callback_url = 'http://website.com/callback'
@@ -48,7 +48,11 @@ describe Animoto::Manifests::DirectingAndRendering do
48
48
  end
49
49
  end
50
50
  end
51
-
51
+
52
+ it "should have a directing manifest attribute" do
53
+ @manifest.directing_manifest.should be_an_instance_of(Animoto::Manifests::Directing)
54
+ end
55
+
52
56
  it "should have a 'directing_manifest' object within the job" do
53
57
  manifest.to_hash['directing_and_rendering_job'].should have_key('directing_manifest')
54
58
  manifest.to_hash['directing_and_rendering_job']['directing_manifest'].should be_a(Hash)
@@ -56,51 +60,73 @@ describe Animoto::Manifests::DirectingAndRendering do
56
60
 
57
61
  describe "directing_manifest" do
58
62
  before do
59
- @hash = manifest.to_hash['directing_and_rendering_job']['directing_manifest']
63
+ @directing_manifest = manifest.directing_manifest
60
64
  end
61
65
 
62
- it "should have a 'style' key in the manifest" do
63
- @hash.should have_key('style')
64
- @hash['style'].should == manifest.style
66
+ it "should have been initialized with the :title and :pacing attributes from the initial initialization" do
67
+ @directing_manifest.title.should == 'Funderful Wonderment'
68
+ @directing_manifest.pacing.should == 'double'
65
69
  end
66
-
67
- it "should have a 'pacing' key in the manifest" do
68
- @hash.should have_key('pacing')
69
- @hash['pacing'].should == manifest.pacing
70
+
71
+ it "should defer unknown methods to the directing manifest if the directing manifest responds to those methods" do
72
+ manifest.should_not respond_to(:pacing)
73
+ @directing_manifest.should respond_to(:pacing)
74
+ @directing_manifest.expects(:pacing)
75
+ manifest.pacing
70
76
  end
77
+
78
+ describe "to hash" do
79
+ before do
80
+ @hash = manifest.to_hash['directing_and_rendering_job']['directing_manifest']
81
+ end
82
+
83
+ it "should have a 'style' key in the manifest" do
84
+ @hash.should have_key('style')
85
+ @hash['style'].should == manifest.style
86
+ end
71
87
 
72
- it "should have a 'visuals' key in the manifest" do
73
- @hash.should have_key('visuals')
74
- end
88
+ it "should have a 'pacing' key in the manifest" do
89
+ @hash.should have_key('pacing')
90
+ @hash['pacing'].should == manifest.pacing
91
+ end
75
92
 
76
- it "should have a 'song' object in the manifest" do
77
- @hash.should have_key('song')
78
- @hash['song'].should be_a(Hash)
79
- end
93
+ it "should have a 'visuals' key in the manifest" do
94
+ @hash.should have_key('visuals')
95
+ end
80
96
 
81
- describe "visuals array" do
82
- before do
83
- @visuals = @hash['visuals']
97
+ it "should have a 'song' object in the manifest" do
98
+ @hash.should have_key('song')
99
+ @hash['song'].should be_a(Hash)
84
100
  end
101
+
102
+ describe "visuals array" do
103
+ before do
104
+ @visuals = @hash['visuals']
105
+ end
85
106
 
86
- it "should have the visuals in the order they were added" do
87
- @visuals[0].should == @image.to_hash
88
- @visuals[1].should == @title_card.to_hash
89
- @visuals[2].should == @footage.to_hash
107
+ it "should have the visuals in the order they were added" do
108
+ @visuals[0].should == @image.to_hash
109
+ @visuals[1].should == @title_card.to_hash
110
+ @visuals[2].should == @footage.to_hash
111
+ end
90
112
  end
91
- end
92
113
 
93
- describe "song" do
94
- before do
95
- @song = @hash['song']
96
- end
114
+ describe "song" do
115
+ before do
116
+ @song = @hash['song']
117
+ end
97
118
 
98
- it "should have info about the song" do
99
- @song.should == @song_obj.to_hash
119
+ it "should have info about the song" do
120
+ @song.should == @song_obj.to_hash
121
+ end
100
122
  end
101
123
  end
102
124
  end
103
125
 
126
+ it "should have a rendering manifest attribute" do
127
+ manifest.rendering_manifest.should be_an_instance_of(Animoto::Manifests::Rendering)
128
+ end
129
+
104
130
  it "should have a 'rendering_manifest' object within the job" do
105
131
  manifest.to_hash['directing_and_rendering_job'].should have_key('rendering_manifest')
106
132
  manifest.to_hash['directing_and_rendering_job']['rendering_manifest'].should be_a(Hash)
@@ -108,29 +134,48 @@ describe Animoto::Manifests::DirectingAndRendering do
108
134
 
109
135
  describe "rendering_manifest" do
110
136
  before do
111
- @hash = manifest.to_hash['directing_and_rendering_job']['rendering_manifest']
137
+ @rendering_manifest = manifest.rendering_manifest
112
138
  end
113
139
 
114
- it "should have a 'rendering_parameters' object in the manifest" do
115
- @hash.should have_key('rendering_parameters')
116
- @hash['rendering_parameters'].should be_a(Hash)
140
+ it "should have been initialized with the :format, :framerate, and :resolution attributes from the initial initialization" do
141
+ @rendering_manifest.format.should == 'flv'
142
+ @rendering_manifest.framerate.should == 24
143
+ @rendering_manifest.resolution.should == '720p'
144
+ end
145
+
146
+ it "should defer unknown methods to the rendering manifest if the rendering manifest responds to those methods" do
147
+ manifest.should_not respond_to(:resolution)
148
+ @rendering_manifest.should respond_to(:resolution)
149
+ @rendering_manifest.expects(:resolution)
150
+ manifest.resolution
117
151
  end
118
152
 
119
- describe "rendering_parameters" do
153
+ describe "to hash" do
120
154
  before do
121
- @profile = @hash['rendering_parameters']
155
+ @hash = manifest.to_hash['directing_and_rendering_job']['rendering_manifest']
122
156
  end
123
-
124
- it "should have a 'resolution' key" do
125
- @profile['resolution'].should == manifest.resolution
157
+
158
+ it "should have a 'rendering_parameters' object in the manifest" do
159
+ @hash.should have_key('rendering_parameters')
160
+ @hash['rendering_parameters'].should be_a(Hash)
126
161
  end
127
162
 
128
- it "should have a 'framerate' key" do
129
- @profile['framerate'].should == manifest.framerate
130
- end
163
+ describe "rendering_parameters" do
164
+ before do
165
+ @profile = @hash['rendering_parameters']
166
+ end
167
+
168
+ it "should have a 'resolution' key" do
169
+ @profile['resolution'].should == manifest.resolution
170
+ end
171
+
172
+ it "should have a 'framerate' key" do
173
+ @profile['framerate'].should == manifest.framerate
174
+ end
131
175
 
132
- it "should have a 'format' key" do
133
- @profile['format'].should == manifest.format
176
+ it "should have a 'format' key" do
177
+ @profile['format'].should == manifest.format
178
+ end
134
179
  end
135
180
  end
136
181
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
2
2
 
3
3
  describe Animoto::Resources::Jobs::Rendering do
4
4
 
5
- it "should have endpoint /jobs/rendering" do
5
+ it "should have endpoint '/jobs/rendering'" do
6
6
  Animoto::Resources::Jobs::Rendering.endpoint.should == '/jobs/rendering'
7
7
  end
8
8
 
@@ -2,15 +2,15 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
2
2
 
3
3
  describe Animoto::Resources::Jobs::StoryboardBundling do
4
4
 
5
- it "should have endpoint /jobs/storyboard_bundling" do
5
+ it "should have endpoint '/jobs/storyboard_bundling'" do
6
6
  Animoto::Resources::Jobs::StoryboardBundling.endpoint.should == '/jobs/storyboard_bundling'
7
7
  end
8
8
 
9
- it "should have content type 'application/vnd.animoto.storyboard_bundling_job" do
9
+ it "should have content type 'application/vnd.animoto.storyboard_bundling_job'" do
10
10
  Animoto::Resources::Jobs::StoryboardBundling.content_type.should == 'storyboard_bundling_job'
11
11
  end
12
12
 
13
- it "should have payload key storyboard_bundling_job" do
13
+ it "should have payload key 'storyboard_bundling_job'" do
14
14
  Animoto::Resources::Jobs::StoryboardBundling.payload_key.should == 'storyboard_bundling_job'
15
15
  end
16
16
 
@@ -2,15 +2,15 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
2
2
 
3
3
  describe Animoto::Resources::Jobs::StoryboardUnbundling do
4
4
 
5
- it "should have endpoint /jobs/storyboard_unbundling" do
5
+ it "should have endpoint '/jobs/storyboard_unbundling'" do
6
6
  Animoto::Resources::Jobs::StoryboardUnbundling.endpoint.should == '/jobs/storyboard_unbundling'
7
7
  end
8
8
 
9
- it "should have content type 'application/vnd.animoto.storyboard_unbundling_job" do
9
+ it "should have content type 'application/vnd.animoto.storyboard_unbundling_job'" do
10
10
  Animoto::Resources::Jobs::StoryboardUnbundling.content_type.should == 'storyboard_unbundling_job'
11
11
  end
12
12
 
13
- it "should have payload key storyboard_unbundling_job" do
13
+ it "should have payload key 'storyboard_unbundling_job'" do
14
14
  Animoto::Resources::Jobs::StoryboardUnbundling.payload_key.should == 'storyboard_unbundling_job'
15
15
  end
16
16
 
@@ -1,8 +1,54 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
3
  describe Animoto::Resources::Storyboard do
4
- def storyboard options = {}
5
- @storyboard ||= Animoto::Resources::Storyboard.new options
4
+
5
+ it "should have content type 'application/vnd.animoto.storyboard'" do
6
+ Animoto::Resources::Storyboard.content_type.should == 'storyboard'
7
+ end
8
+
9
+ it "should have payload key 'storyboard'" do
10
+ Animoto::Resources::Storyboard.payload_key.should == 'storyboard'
11
+ end
12
+
13
+ describe "initialization" do
14
+ before do
15
+ @body = {
16
+ 'response' => {
17
+ 'status' => {
18
+ 'code' => 200
19
+ },
20
+ 'payload' => {
21
+ 'storyboard' => {
22
+ 'metadata' => {
23
+ 'duration' => 300.0,
24
+ 'visuals_count' => 60
25
+ },
26
+ 'links' => {
27
+ 'self' => 'https://platform.animoto.com/storyboards/1',
28
+ 'preview' => 'http://storage.com/previews/1.mp4'
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ @storyboard = Animoto::Resources::Storyboard.load(@body)
35
+ end
36
+
37
+ it "should set its url from the 'self' link given" do
38
+ @storyboard.url.should == 'https://platform.animoto.com/storyboards/1'
39
+ end
40
+
41
+ it "should set its preview url from the 'preview' link given" do
42
+ @storyboard.preview_url.should == 'http://storage.com/previews/1.mp4'
43
+ end
44
+
45
+ it "should set its duration from the 'duration' metadata given" do
46
+ @storyboard.duration.should == 300.0
47
+ end
48
+
49
+ it "should set its visuals count from the visuals_count metadata given" do
50
+ @storyboard.visuals_count.should == 60
51
+ end
6
52
  end
7
53
 
8
54
  end
@@ -2,4 +2,74 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
3
  describe Animoto::Resources::Video do
4
4
 
5
+ it "should have content type 'application/vnd.animoto.video'" do
6
+ Animoto::Resources::Video.content_type.should == 'video'
7
+ end
8
+
9
+ it "should have payload key 'video'" do
10
+ Animoto::Resources::Video.payload_key.should == 'video'
11
+ end
12
+
13
+ describe "initialization" do
14
+ before do
15
+ @body = {
16
+ 'response' => {
17
+ 'status' => {
18
+ 'code' => 200
19
+ },
20
+ 'payload' => {
21
+ 'video' => {
22
+ 'metadata' => {
23
+ 'rendering_parameters' => {
24
+ 'format' => 'h264',
25
+ 'framerate' => 30,
26
+ 'resolution' => '720p'
27
+ }
28
+ },
29
+ 'links' => {
30
+ 'self' => 'https://platform.animoto.com/videos/1',
31
+ 'file' => 'http://storage.com/videos/1.mp4',
32
+ 'cover_image' => 'http://storage.com/videos/1/cover_image.jpg',
33
+ 'storyboard' => 'https://platform.animoto.com/storyboards/1'
34
+ }
35
+ }
36
+ }
37
+ }
38
+ }
39
+ @video = Animoto::Resources::Video.load(@body)
40
+ end
41
+
42
+ it "should set its url from the 'self' link given" do
43
+ @video.url.should == 'https://platform.animoto.com/videos/1'
44
+ end
45
+
46
+ it "should set its download url from the 'file' link given" do
47
+ @video.download_url.should == 'http://storage.com/videos/1.mp4'
48
+ end
49
+
50
+ it "should set its cover image url from the 'cover_image' link given" do
51
+ @video.cover_image_url.should == 'http://storage.com/videos/1/cover_image.jpg'
52
+ end
53
+
54
+ it "should set its storyboard url from the 'storyboard_url' given" do
55
+ @video.storyboard_url.should == 'https://platform.animoto.com/storyboards/1'
56
+ end
57
+
58
+ it "should set its storyboard from its storyboard url" do
59
+ @video.storyboard.url.should == 'https://platform.animoto.com/storyboards/1'
60
+ end
61
+
62
+ it "should set its format from the format given" do
63
+ @video.format.should == 'h264'
64
+ end
65
+
66
+ it "should set its framerate from the framerate given" do
67
+ @video.framerate.should == 30
68
+ end
69
+
70
+ it "should set its resolution from the resolution given" do
71
+ @video.resolution.should == '720p'
72
+ end
73
+ end
74
+
5
75
  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: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 1
9
- - 1
10
- version: 1.1.1
8
+ - 2
9
+ - 0
10
+ version: 1.2.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: 2011-02-23 00:00:00 -05:00
18
+ date: 2011-04-05 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -44,6 +44,14 @@ extra_rdoc_files: []
44
44
 
45
45
  files:
46
46
  - README.md
47
+ - ./features/step_definitions/bundling_steps.rb
48
+ - ./features/step_definitions/directing_and_rendering_steps.rb
49
+ - ./features/step_definitions/directing_steps.rb
50
+ - ./features/step_definitions/rendering_steps.rb
51
+ - ./features/step_definitions/storyboard_steps.rb
52
+ - ./features/step_definitions/unbundling_steps.rb
53
+ - ./features/step_definitions/video_steps.rb
54
+ - ./features/support/env.rb
47
55
  - ./lib/animoto/assets/base.rb
48
56
  - ./lib/animoto/assets/footage.rb
49
57
  - ./lib/animoto/assets/image.rb