vast 1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -2
- data/lib/vast/ad.rb +11 -11
- data/lib/vast/creative.rb +2 -2
- data/lib/vast/document.rb +6 -2
- data/lib/vast/extension.rb +2 -0
- data/lib/vast/linear_creative.rb +4 -0
- data/lib/vast/mediafile.rb +2 -0
- data/test/examples/document_with_one_inline_ad.xml +3 -1
- data/test/examples/document_with_one_wrapper_ad.xml +3 -1
- metadata +11 -3
data/README.rdoc
CHANGED
@@ -21,9 +21,9 @@ Parse a VAST document and access its contents using an easy-to-understand model.
|
|
21
21
|
|
22
22
|
document = VAST::Document.parse(File.read("vast_document.xml"))
|
23
23
|
inline_ad = document.inline_ads.first
|
24
|
-
puts
|
24
|
+
puts inline_ad.linear_creative.mediafiles.first.type
|
25
25
|
=> "video/x-flv"
|
26
|
-
puts
|
26
|
+
puts inline_ad.linear_creative.mediafiles.first.url
|
27
27
|
=> #<URI::HTTP:0x1015ad5f0 URL:http://creativeurl.ca/mediafile>
|
28
28
|
|
29
29
|
See the documentation for the individual classes for an overview of what information available for each class.
|
data/lib/vast/ad.rb
CHANGED
@@ -8,8 +8,8 @@ module VAST
|
|
8
8
|
# The VAST response does not contain information on the placement or timing of each ad. It is up
|
9
9
|
# to the Video Player to determine the optimal inclusion points of the ads.
|
10
10
|
#
|
11
|
-
# Can either be
|
12
|
-
# visual experience, or
|
11
|
+
# Can either be a InlineAd, meaning it contains all the elements necessary to display the
|
12
|
+
# visual experience, or a WrapperAd, which points to a downstream VAST document that must be
|
13
13
|
# requested from another server.
|
14
14
|
#
|
15
15
|
# An Ad may include one or more pieces of creative that are part of a single execution. For example, an Ad
|
@@ -17,7 +17,7 @@ module VAST
|
|
17
17
|
# elements, one LinearCreative and one CompanionCreative.
|
18
18
|
class Ad < Element
|
19
19
|
|
20
|
-
#
|
20
|
+
# Creates proper ad type
|
21
21
|
def self.create(node)
|
22
22
|
if node.at('InLine')
|
23
23
|
InlineAd.new(node)
|
@@ -33,7 +33,7 @@ module VAST
|
|
33
33
|
source_node[:id]
|
34
34
|
end
|
35
35
|
|
36
|
-
#
|
36
|
+
# Returns name of source ad server
|
37
37
|
def ad_system
|
38
38
|
ad_system_node = source_node.at("AdSystem")
|
39
39
|
if ad_system_node
|
@@ -43,33 +43,33 @@ module VAST
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
# URI to request if ad does not play due to error
|
46
|
+
# Returns URI to request if ad does not play due to error.
|
47
47
|
def error_url
|
48
48
|
error_url_node = source_node.at("Error")
|
49
49
|
URI.parse(error_url_node.content) if error_url_node
|
50
50
|
end
|
51
51
|
|
52
|
-
# Returns an array containing all linear creatives
|
52
|
+
# Returns an array containing all linear creatives.
|
53
53
|
def linear_creatives
|
54
54
|
source_node.xpath('.//Creative/Linear').to_a.collect do |node|
|
55
55
|
LinearCreative.new(node)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
#
|
60
|
-
#
|
59
|
+
# This is a convenience method for when only the first piece of linear creative is needed.
|
60
|
+
# It's common for an ad to contain only one piece of linear creative.
|
61
61
|
def linear_creative
|
62
62
|
linear_creatives.first
|
63
63
|
end
|
64
64
|
|
65
|
-
# Returns an array containing all non linear creatives
|
65
|
+
# Returns an array containing all non linear creatives.
|
66
66
|
def non_linear_creatives
|
67
67
|
source_node.xpath('.//Creative/NonLinearAds/NonLinear').to_a.collect do |node|
|
68
68
|
NonLinearCreative.new(node)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
# Returns an array containing all companion creatives
|
72
|
+
# Returns an array containing all companion creatives.
|
73
73
|
def companion_creatives
|
74
74
|
source_node.xpath('.//Creative/CompanionAds/Companion').to_a.collect do |node|
|
75
75
|
CompanionCreative.new(node)
|
@@ -89,7 +89,7 @@ module VAST
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
#
|
92
|
+
# All extensions included with this ad.
|
93
93
|
def extensions
|
94
94
|
source_node.xpath('.//Extension').to_a.collect do |node|
|
95
95
|
Extension.new(node)
|
data/lib/vast/creative.rb
CHANGED
@@ -35,9 +35,9 @@ module VAST
|
|
35
35
|
source_node.xpath('.//Tracking').to_a.collect do |node|
|
36
36
|
underscored_name = underscore(node[:event])
|
37
37
|
if tracking_urls[underscored_name.to_sym]
|
38
|
-
tracking_urls[underscored_name.to_sym] << URI.parse(node.content)
|
38
|
+
tracking_urls[underscored_name.to_sym] << URI.parse(node.content.strip)
|
39
39
|
else
|
40
|
-
tracking_urls[underscored_name.to_sym] = [URI.parse(node.content)]
|
40
|
+
tracking_urls[underscored_name.to_sym] = [URI.parse(node.content.strip)]
|
41
41
|
end
|
42
42
|
end
|
43
43
|
tracking_urls
|
data/lib/vast/document.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module VAST
|
2
|
+
# A complete VAST document
|
2
3
|
class Document < Nokogiri::XML::Document
|
3
4
|
|
4
5
|
# Parse a VAST XML document
|
@@ -20,8 +21,11 @@ module VAST
|
|
20
21
|
xsd.valid?(self)
|
21
22
|
end
|
22
23
|
|
23
|
-
#
|
24
|
-
#
|
24
|
+
# A single VAST response may include multiple Ads from multiple advertisers. It will be up to the
|
25
|
+
# Video Player to determine the order, timing, placement, etc for the multiple ads. However, the
|
26
|
+
# player should generally respect the sequential order of the Ad elements within the ad.
|
27
|
+
#
|
28
|
+
# If no ads of any type are available, it would be indicated by the absence of any ads.
|
25
29
|
def ads
|
26
30
|
self.root.xpath('.//Ad').to_a.collect do |node|
|
27
31
|
Ad.create(node)
|
data/lib/vast/extension.rb
CHANGED
data/lib/vast/linear_creative.rb
CHANGED
@@ -32,6 +32,10 @@ module VAST
|
|
32
32
|
custom_click_urls
|
33
33
|
end
|
34
34
|
|
35
|
+
# Returns mediafiles containing the information required to display the linear creative's media
|
36
|
+
#
|
37
|
+
# It is assumed that all mediafiles accessible represent the same creative unit with the same
|
38
|
+
# duration, Ad-ID (ISCI code), etc.
|
35
39
|
def mediafiles
|
36
40
|
source_node.xpath('.//MediaFile').to_a.collect do |node|
|
37
41
|
Mediafile.new(node)
|
data/lib/vast/mediafile.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module VAST
|
2
|
+
# Any number of Mediafile objects can be provided for a single Ad, but it is assumed that all Mediafiles belongs
|
3
|
+
# to a single Ad object represent the same creative unit with the same duration, Ad-ID (ISCI code), etc.
|
2
4
|
class Mediafile < Element
|
3
5
|
|
4
6
|
# Location of linear file
|
@@ -18,7 +18,9 @@
|
|
18
18
|
<TrackingEvents>
|
19
19
|
<Tracking event="creativeView"><![CDATA[http://myTrackingURL/creativeView]]></Tracking>
|
20
20
|
|
21
|
-
<Tracking event="start"
|
21
|
+
<Tracking event="start">
|
22
|
+
<![CDATA[http://myTrackingURL/start1]]>
|
23
|
+
</Tracking>
|
22
24
|
<Tracking event="start"><![CDATA[http://myTrackingURL/start2]]></Tracking>
|
23
25
|
<Tracking event="midpoint"><![CDATA[http://myTrackingURL/midpoint]]></Tracking>
|
24
26
|
<Tracking event="firstQuartile"><![CDATA[http://myTrackingURL/firstQuartile]]></Tracking>
|
@@ -26,7 +26,9 @@
|
|
26
26
|
</Companion>
|
27
27
|
<Companion width="728" height="90">
|
28
28
|
|
29
|
-
<StaticResource creativeType="image/jpeg">
|
29
|
+
<StaticResource creativeType="image/jpeg">
|
30
|
+
http://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg
|
31
|
+
</StaticResource>
|
30
32
|
<CompanionClickThrough>http://www.tremormedia.com</CompanionClickThrough>
|
31
33
|
</Companion>
|
32
34
|
</CompanionAds>
|
metadata
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 0
|
8
|
-
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
9
11
|
platform: ruby
|
10
12
|
authors:
|
11
13
|
- Chris Dinn
|
@@ -13,16 +15,18 @@ autorequire:
|
|
13
15
|
bindir: bin
|
14
16
|
cert_chain: []
|
15
17
|
|
16
|
-
date:
|
18
|
+
date: 2011-06-01 00:00:00 -04:00
|
17
19
|
default_executable:
|
18
20
|
dependencies:
|
19
21
|
- !ruby/object:Gem::Dependency
|
20
22
|
name: nokogiri
|
21
23
|
prerelease: false
|
22
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 1
|
26
30
|
segments:
|
27
31
|
- 1
|
28
32
|
- 4
|
@@ -84,23 +88,27 @@ rdoc_options: []
|
|
84
88
|
require_paths:
|
85
89
|
- lib
|
86
90
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
87
92
|
requirements:
|
88
93
|
- - ">="
|
89
94
|
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
90
96
|
segments:
|
91
97
|
- 0
|
92
98
|
version: "0"
|
93
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
94
101
|
requirements:
|
95
102
|
- - ">="
|
96
103
|
- !ruby/object:Gem::Version
|
104
|
+
hash: 3
|
97
105
|
segments:
|
98
106
|
- 0
|
99
107
|
version: "0"
|
100
108
|
requirements: []
|
101
109
|
|
102
110
|
rubyforge_project:
|
103
|
-
rubygems_version: 1.3.
|
111
|
+
rubygems_version: 1.3.7
|
104
112
|
signing_key:
|
105
113
|
specification_version: 3
|
106
114
|
summary: A gem for working with VAST 2.0 documents
|