animoto 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/animoto.rb CHANGED
@@ -6,6 +6,6 @@ module Animoto
6
6
  #
7
7
  # @return [String]
8
8
  def self.version
9
- "1.2.0"
9
+ "1.3.0"
10
10
  end
11
- end
11
+ end
@@ -11,6 +11,7 @@ module Animoto
11
11
  # Creates a new asset.
12
12
  #
13
13
  # @param [String] source the URL of this asset
14
+ # @param [Hash{Symbol=>Object}] options
14
15
  # @return [Assets::Base] the asset
15
16
  def initialize source, options = {}
16
17
  @source = source
@@ -21,7 +22,7 @@ module Animoto
21
22
  #
22
23
  # @return [Hash{String=>Object}] this asset as a Hash
23
24
  def to_hash
24
- { 'source_url' => @source }
25
+ { 'source_url' => @source, 'type' => self.class.name.split('::').last.underscore }
25
26
  end
26
27
 
27
28
  end
@@ -1,9 +1,6 @@
1
1
  module Animoto
2
2
  module Assets
3
3
  class Footage < Animoto::Assets::Base
4
- include Support::Visual
5
- include Support::Coverable
6
-
7
4
  # Whether or not to mix the audio of this footage with the video's soundtrack.
8
5
  # @return [Boolean]
9
6
  attr_accessor :audio_mix
@@ -17,16 +14,51 @@ module Animoto
17
14
  # @return [Float]
18
15
  attr_accessor :duration
19
16
 
17
+ # The number of clockwise 90-degree rotations that should be applied to this video.
18
+ # @return [Integer]
19
+ attr_accessor :rotation
20
+
21
+ # Whether or not this footage is the cover of the video. If this piece of footage is
22
+ # the video's cover, the cover image will be generated from a frame in this footage.
23
+ # @return [Boolean]
24
+ attr_writer :cover
25
+
26
+ # Returns whether or not this footage is marked as the cover.
27
+ # @return [Boolean]
28
+ def cover?
29
+ @cover
30
+ end
31
+
32
+ # Creates a new Footage object.
33
+ #
34
+ # @param [String] source the source URL of this footage
35
+ # @param [Hash{Symbol=>Object}] options
36
+ # @option options [Boolean] :audio_mix whether or not to mix the audio from this footage with the soundtrack of the video
37
+ # @option options [Float] :start_time the offset in seconds from the beginning of where to start playing this footage
38
+ # @option options [Float] :duration the length in seconds to play this footage
39
+ # @option options [Integer] :rotation the number of clockwise 90-degree rotations to apply to this footage
40
+ # @option options [Boolean] :cover whether or not to generate the cover of this video from this footage
41
+ # @return [Assets::Footage] the Footage object
42
+ def initialize source, options = {}
43
+ super
44
+ @audio_mix = options[:audio_mix]
45
+ @start_time = options[:start_time]
46
+ @duration = options[:duration]
47
+ @rotation = options[:rotation]
48
+ @cover = options[:cover]
49
+ end
50
+
20
51
  # Returns a representation of this Footage as a Hash.
21
52
  #
22
53
  # @return [Hash{String=>Object}] this asset as a Hash
23
- # @see Animoto::Support::Visual#to_hash
24
54
  # @see Animoto::Assets::Base#to_hash
25
55
  def to_hash
26
56
  hash = super
27
57
  hash['audio_mix'] = 'MIX' if audio_mix
28
58
  hash['start_time'] = start_time if start_time
29
59
  hash['duration'] = duration if duration
60
+ hash['rotation'] = rotation if rotation
61
+ hash['cover'] = cover? unless @cover.nil?
30
62
  hash
31
63
  end
32
64
  end
@@ -1,17 +1,50 @@
1
1
  module Animoto
2
2
  module Assets
3
3
  class Image < Animoto::Assets::Base
4
- include Support::Visual
5
- include Support::Coverable
6
-
7
- # The EXIF rotation value for how this image should be rotated in the video.
4
+ # The number of clockwise 90-degree rotations that should be applied to this image.
8
5
  # @return [Integer]
9
6
  attr_accessor :rotation
10
-
7
+
8
+ # Whether or not this image is spotlit. Spotlighting a visual tells to director to add
9
+ # more emphasis to this visual when directing.
10
+ # @return [Boolean]
11
+ attr_writer :spotlit
12
+
13
+ # Returns whether or not this image is spotlit.
14
+ # @return [Boolean]
15
+ def spotlit?
16
+ @spotlit
17
+ end
18
+
19
+ # Whether or not this image is the cover of the video. If this image is the video's cover,
20
+ # the cover image will be generated using this image.
21
+ # @return [Boolean]
22
+ attr_writer :cover
23
+
24
+ # Returns whether or not this footage is marked as the cover.
25
+ # @return [Boolean]
26
+ def cover?
27
+ @cover
28
+ end
29
+
30
+ # Creates a new Image object.
31
+ #
32
+ # @param [String] source the source URL of this image
33
+ # @param [Hash{Symbol=>Object}] options
34
+ # @option options [Integer] :rotation the number of clockwise 90-degree rotations to apply to this image
35
+ # @option options [Boolean] :spotlit whether or not to spotlight this image
36
+ # @option options [Boolean] :cover whether or not to generate the cover of this video from this image
37
+ # @return [Assets::Image] the Image object
38
+ def initialize source, options = {}
39
+ super
40
+ @rotation = options[:rotation]
41
+ @spotlit = options[:spotlit]
42
+ @cover = options[:cover]
43
+ end
44
+
11
45
  # Returns a representation of this Image as a Hash.
12
46
  #
13
47
  # @return [Hash{String=>Object}] this asset as a Hash
14
- # @see Animoto::Support::Visual#to_hash
15
48
  # @see Animoto::Assets::Base#to_hash
16
49
  def to_hash
17
50
  hash = super
@@ -10,6 +10,33 @@ module Animoto
10
10
  # The duration in seconds of how long this song should play.
11
11
  # @return [Float]
12
12
  attr_accessor :duration
13
+
14
+ # The title of this song. Defaults to the title read from the metadata of
15
+ # the source file.
16
+ # @return [String]
17
+ attr_accessor :title
18
+
19
+ # The artist of this song. Default to the title read from the metadata of
20
+ # the source file.
21
+ # @return [String]
22
+ attr_accessor :artist
23
+
24
+ # Creates a new Song object.
25
+ #
26
+ # @param [String] source the source URL of this song
27
+ # @param [Hash{Symbol=>Object}] options
28
+ # @option options [Float] :start_time the time offset in seconds from the beginning of where to start playing this song
29
+ # @option options [Float] :duration the length in seconds of how long to play this song
30
+ # @option options [String] :title the title of this song. Defaults to being read from the song file's metadata
31
+ # @option options [String] :artist the artist of this song. Defaults to being read from the song file's metadata
32
+ # @return [Assets::Song] the Song object
33
+ def initialize source, options = {}
34
+ super
35
+ @start_time = options[:start_time]
36
+ @duration = options[:duration]
37
+ @title = options[:title]
38
+ @artist = options[:artist]
39
+ end
13
40
 
14
41
  # Returns a representation of this Song as a Hash.
15
42
  #
@@ -19,6 +46,8 @@ module Animoto
19
46
  hash = super
20
47
  hash['start_time'] = start_time if start_time
21
48
  hash['duration'] = duration if duration
49
+ hash['title'] = title if title
50
+ hash['artist'] = artist if artist
22
51
  hash
23
52
  end
24
53
 
@@ -1,8 +1,6 @@
1
1
  module Animoto
2
2
  module Assets
3
3
  class TitleCard
4
- include Support::Visual
5
-
6
4
  # The main text of this title card.
7
5
  # @return [String]
8
6
  attr_accessor :title
@@ -11,20 +9,34 @@ module Animoto
11
9
  # @return [String]
12
10
  attr_accessor :subtitle
13
11
 
12
+ # Whether or not this image is spotlit. Spotlighting a visual tells to director to add
13
+ # more emphasis to this visual when directing.
14
+ # @return [Boolean]
15
+ attr_writer :spotlit
16
+
17
+ # Returns whether or not this image is spotlit.
18
+ # @return [Boolean]
19
+ def spotlit?
20
+ @spotlit
21
+ end
22
+
14
23
  # Creates a new TitleCard.
15
24
  #
16
25
  # @param [String] title the main text
17
26
  # @param [String] subtitle the secondary text
18
- def initialize title, subtitle = nil
27
+ # @param [Hash{Symbol=>Object}] options
28
+ # @option options [Boolean] :spotlit whether or not to spotlight this title card
29
+ # @return [Assets::TitleCard] the TitleCard object
30
+ def initialize title, subtitle = nil, options = {}
19
31
  @title, @subtitle = title, subtitle
32
+ @spotlit = options[:spotlit]
20
33
  end
21
34
 
22
35
  # Returns a representation of this TitleCard as a Hash.
23
36
  #
24
37
  # @return [Hash{String=>Object}] this TitleCard as a Hash
25
- # @see Animoto::Support::Visual#to_hash
26
38
  def to_hash
27
- hash = super
39
+ hash = {}
28
40
  hash['h1'] = title
29
41
  hash['h2'] = subtitle if subtitle
30
42
  hash['spotlit'] = spotlit? unless @spotlit.nil?
@@ -3,13 +3,11 @@ require 'uri'
3
3
  require 'logger'
4
4
 
5
5
  require 'animoto/support/content_type'
6
- require 'animoto/support/coverable'
7
6
  require 'animoto/support/dynamic_class_loader'
8
7
  require 'animoto/support/errors'
9
8
  require 'animoto/support/hash'
10
9
  require 'animoto/support/standard_envelope'
11
10
  require 'animoto/support/string'
12
- require 'animoto/support/visual'
13
11
 
14
12
  require 'animoto/resources/base'
15
13
  require 'animoto/resources/storyboard'
@@ -11,8 +11,8 @@ module Animoto
11
11
  # @return [String]
12
12
  attr_accessor :pacing
13
13
 
14
- # The array of Visual objects in this manifest.
15
- # @return [Array<Support::Visual>]
14
+ # The array of visual objects in this manifest.
15
+ # @return [Array<Assets::Base,Assets::TitleCard>]
16
16
  attr_reader :visuals
17
17
 
18
18
  # The song for this video.
@@ -85,14 +85,14 @@ module Animoto
85
85
 
86
86
  # Adds a visual/song to this manifest.
87
87
  #
88
- # @param [Support::Visual,Assets::Song] asset the asset to add
88
+ # @param [Assets::Base,Assets::TitleCard] asset the asset to add
89
89
  # @return [void]
90
- # @raise [ArgumentError] if the asset isn't a Song or Visual
90
+ # @raise [ArgumentError] if the asset isn't a Song, Image, Footage, or TitleCard
91
91
  def add_visual asset
92
92
  case asset
93
93
  when Animoto::Assets::Song
94
94
  @song = asset
95
- when Animoto::Support::Visual
95
+ when Animoto::Assets::Base, Animoto::Assets::TitleCard
96
96
  @visuals << asset
97
97
  else
98
98
  raise ArgumentError
@@ -101,7 +101,7 @@ module Animoto
101
101
 
102
102
  # Adds a visual/song to this manifest.
103
103
  #
104
- # @param [Support::Visual,Assets::Song] asset the asset to add
104
+ # @param [Assets::Base,Assets::TitleCard] asset the asset to add
105
105
  # @return [self]
106
106
  def << asset
107
107
  add_visual asset
@@ -2,8 +2,35 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
3
  describe Animoto::Assets::Footage do
4
4
 
5
- it "should be a visual" do
6
- Animoto::Assets::Footage.should include(Animoto::Support::Visual)
5
+ describe "initialization" do
6
+ before do
7
+ @footage = Animoto::Assets::Footage.new 'http://website.com/movie.mp4',
8
+ :audio_mix => true, :start_time => 1.0, :duration => 5.0, :rotation => 3, :cover => true
9
+ end
10
+
11
+ it "should set the source to the given url" do
12
+ @footage.source.should == 'http://website.com/movie.mp4'
13
+ end
14
+
15
+ it "should set the audio mix to the given value" do
16
+ @footage.audio_mix.should be_true
17
+ end
18
+
19
+ it "should set the start time to the given time" do
20
+ @footage.start_time.should == 1.0
21
+ end
22
+
23
+ it "should set the duration to the given length" do
24
+ @footage.duration.should == 5.0
25
+ end
26
+
27
+ it "should set the rotation to the given amount" do
28
+ @footage.rotation.should == 3
29
+ end
30
+
31
+ it "should set the cover to the given value" do
32
+ @footage.should be_a_cover
33
+ end
7
34
  end
8
35
 
9
36
  describe "#to_hash" do
@@ -16,10 +43,6 @@ describe Animoto::Assets::Footage do
16
43
  @footage.to_hash['source_url'].should == @footage.source
17
44
  end
18
45
 
19
- it "should not have a 'spotlit' key" do
20
- @footage.to_hash.should_not have_key('spotlit')
21
- end
22
-
23
46
  describe "if audio mixing is turned on" do
24
47
  before do
25
48
  @footage.audio_mix = true
@@ -52,5 +75,27 @@ describe Animoto::Assets::Footage do
52
75
  @footage.to_hash['duration'].should == @footage.duration
53
76
  end
54
77
  end
78
+
79
+ describe "if a rotation was given" do
80
+ before do
81
+ @footage.rotation = 3
82
+ end
83
+
84
+ it "should have a 'rotation' key with the rotation" do
85
+ @footage.to_hash.should have_key('rotation')
86
+ @footage.to_hash['rotation'].should == @footage.rotation
87
+ end
88
+ end
89
+
90
+ describe "if this footage is the cover" do
91
+ before do
92
+ @footage.cover = true
93
+ end
94
+
95
+ it "should have a 'cover' key with telling whether or not this footage is the cover" do
96
+ @footage.to_hash.should have_key('cover')
97
+ @footage.to_hash['cover'].should == @footage.cover?
98
+ end
99
+ end
55
100
  end
56
101
  end
@@ -2,10 +2,29 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
3
  describe Animoto::Assets::Image do
4
4
 
5
- it "should be a visual" do
6
- Animoto::Assets::Image.should include(Animoto::Support::Visual)
5
+ describe "initialization" do
6
+ before do
7
+ @image = Animoto::Assets::Image.new 'http://website.com/image.png',
8
+ :rotation => 2, :spotlit => true, :cover => true
9
+ end
10
+
11
+ it "should set the source to the given url" do
12
+ @image.source.should == 'http://website.com/image.png'
13
+ end
14
+
15
+ it "should set the rotation to the given amount" do
16
+ @image.rotation.should == 2
17
+ end
18
+
19
+ it "should set the spotlighting to the given value" do
20
+ @image.should be_spotlit
21
+ end
22
+
23
+ it "should set the cover to the given value" do
24
+ @image.should be_a_cover
25
+ end
7
26
  end
8
-
27
+
9
28
  describe "#to_hash" do
10
29
  before do
11
30
  @image = Animoto::Assets::Image.new 'http://website.com/image.png'
@@ -21,7 +40,7 @@ describe Animoto::Assets::Image do
21
40
  @image.rotation = 2
22
41
  end
23
42
 
24
- it "should have a 'rotation' key with the EXIF rotation value" do
43
+ it "should have a 'rotation' key with the rotation value" do
25
44
  @image.to_hash.should have_key('rotation')
26
45
  @image.to_hash['rotation'].should == @image.rotation
27
46
  end
@@ -37,5 +56,16 @@ describe Animoto::Assets::Image do
37
56
  @image.to_hash['spotlit'].should == @image.spotlit?
38
57
  end
39
58
  end
59
+
60
+ describe "if this image is the cover" do
61
+ before do
62
+ @image.cover = true
63
+ end
64
+
65
+ it "should have a 'cover' key telling whether or not this image is the cover" do
66
+ @image.to_hash.should have_key('cover')
67
+ @image.to_hash['cover'].should == @image.cover?
68
+ end
69
+ end
40
70
  end
41
71
  end
@@ -2,6 +2,33 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
3
  describe Animoto::Assets::Song do
4
4
 
5
+ describe "initialization" do
6
+ before do
7
+ @song = Animoto::Assets::Song.new 'http://website.com/song.mp3',
8
+ :start_time => 30.0, :duration => 90.0, :title => "Hooray for Dolphins!", :artist => "Some Chick with Bangs"
9
+ end
10
+
11
+ it "should set the source to the given url" do
12
+ @song.source.should == 'http://website.com/song.mp3'
13
+ end
14
+
15
+ it "should set the start time to the given time" do
16
+ @song.start_time.should == 30.0
17
+ end
18
+
19
+ it "should set the duration to the given length" do
20
+ @song.duration.should == 90.0
21
+ end
22
+
23
+ it "should set the title to the given string" do
24
+ @song.title.should == 'Hooray for Dolphins!'
25
+ end
26
+
27
+ it "should set the artist to the given string" do
28
+ @song.artist.should == 'Some Chick with Bangs'
29
+ end
30
+ end
31
+
5
32
  describe "#to_hash" do
6
33
  before do
7
34
  @song = Animoto::Assets::Song.new 'http://website.com/song.mp3'
@@ -32,6 +59,28 @@ describe Animoto::Assets::Song do
32
59
  @song.to_hash.should have_key('duration')
33
60
  @song.to_hash['duration'].should == @song.duration
34
61
  end
35
- end
62
+ end
63
+
64
+ describe "if a title was specified" do
65
+ before do
66
+ @song.title = 'Hooray for Dolphins!'
67
+ end
68
+
69
+ it "should have a 'title' key with the title" do
70
+ @song.to_hash.should have_key('title')
71
+ @song.to_hash['title'].should == @song.title
72
+ end
73
+ end
74
+
75
+ describe "if an artist was specified do" do
76
+ before do
77
+ @song.artist = 'Some Chick with Bangs'
78
+ end
79
+
80
+ it "should have an 'artist' key with the artist" do
81
+ @song.to_hash.should have_key('artist')
82
+ @song.to_hash['artist'].should == @song.artist
83
+ end
84
+ end
36
85
  end
37
86
  end
@@ -2,10 +2,24 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
3
  describe Animoto::Assets::TitleCard do
4
4
 
5
- it "should be a visual" do
6
- Animoto::Assets::TitleCard.should include(Animoto::Support::Visual)
5
+ describe "initialization" do
6
+ before do
7
+ @card = Animoto::Assets::TitleCard.new "hooray", "for everything", :spotlit => true
8
+ end
9
+
10
+ it "should set the title to the given string" do
11
+ @card.title.should == 'hooray'
12
+ end
13
+
14
+ it "should set the subtitle to the given string" do
15
+ @card.subtitle.should == 'for everything'
16
+ end
17
+
18
+ it "should set the spotlighting to the given value" do
19
+ @card.should be_spotlit
20
+ end
7
21
  end
8
-
22
+
9
23
  describe "#to_hash" do
10
24
  before do
11
25
  @card = Animoto::Assets::TitleCard.new("hooray")
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: 31
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 1.2.0
10
+ version: 1.3.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-04-05 00:00:00 -04:00
18
+ date: 2011-04-21 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -83,13 +83,11 @@ files:
83
83
  - ./lib/animoto/response_parsers/json_adapter.rb
84
84
  - ./lib/animoto/response_parsers/yajl_adapter.rb
85
85
  - ./lib/animoto/support/content_type.rb
86
- - ./lib/animoto/support/coverable.rb
87
86
  - ./lib/animoto/support/dynamic_class_loader.rb
88
87
  - ./lib/animoto/support/errors.rb
89
88
  - ./lib/animoto/support/hash.rb
90
89
  - ./lib/animoto/support/standard_envelope.rb
91
90
  - ./lib/animoto/support/string.rb
92
- - ./lib/animoto/support/visual.rb
93
91
  - ./lib/animoto.rb
94
92
  - ./spec/animoto/assets/base_spec.rb
95
93
  - ./spec/animoto/assets/footage_spec.rb
@@ -114,9 +112,7 @@ files:
114
112
  - ./spec/animoto/resources/video_spec.rb
115
113
  - ./spec/animoto/response_parsers/json_adapter_spec.rb
116
114
  - ./spec/animoto/response_parsers/yajl_adapter_spec.rb
117
- - ./spec/animoto/support/coverable_spec.rb
118
115
  - ./spec/animoto/support/standard_envelope_spec.rb
119
- - ./spec/animoto/support/visual_spec.rb
120
116
  - ./spec/animoto_spec.rb
121
117
  - ./spec/spec_helper.rb
122
118
  has_rdoc: true
@@ -1,31 +0,0 @@
1
- module Animoto
2
- module Support
3
- module Coverable
4
-
5
- # Setter for cover, which makes this visual the cover for the video. Only
6
- # one image or piece of footage in a manifest can be declared the cover.
7
- #
8
- # @param [Boolean] bool true if this visual should be the cover
9
- def cover= bool
10
- @cover = bool
11
- end
12
-
13
- # Returns true if this visual is the cover.
14
- #
15
- # @return [Boolean] whether or not this visual is the cover
16
- def cover?
17
- @cover
18
- end
19
-
20
- # Returns a representation of this visual as a Hash.
21
- #
22
- # @return [Hash{String=>Object}] this visual as a Hash
23
- def to_hash
24
- hash = super rescue {}
25
- hash['cover'] = cover? unless @cover.nil?
26
- hash
27
- end
28
-
29
- end
30
- end
31
- end
@@ -1,32 +0,0 @@
1
- module Animoto
2
- module Support
3
- module Visual
4
-
5
- # Setter for spotlighting, which instructs the director to give special attention
6
- # to this visual when directing.
7
- #
8
- # @param [Boolean] bool true if this visual should receive special attention
9
- def spotlit= bool
10
- @spotlit = bool
11
- end
12
-
13
- # Returns true if this visual is spotlit.
14
- #
15
- # @return [Boolean] whether or not this visual is spotlit
16
- def spotlit?
17
- @spotlit
18
- end
19
-
20
- # Returns a representation of this Visual as a Hash
21
- #
22
- # @return [Hash{String=>Object}] this Visual as a Hash
23
- def to_hash
24
- hash = super rescue {}
25
- hash['spotlit'] = spotlit? unless @spotlit.nil?
26
- hash['type'] = self.class.name.split('::').last.underscore
27
- hash
28
- end
29
-
30
- end
31
- end
32
- end
@@ -1,5 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
-
3
- describe Animoto::Support::Coverable do
4
-
5
- end
@@ -1,5 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
-
3
- describe Animoto::Support::Visual do
4
-
5
- end