sessionm-vast 1.0.4
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/LICENSE +20 -0
- data/README.rdoc +51 -0
- data/lib/vast/ad.rb +103 -0
- data/lib/vast/companion_creative.rb +81 -0
- data/lib/vast/creative.rb +62 -0
- data/lib/vast/document.rb +71 -0
- data/lib/vast/element.rb +9 -0
- data/lib/vast/extension.rb +18 -0
- data/lib/vast/icon.rb +87 -0
- data/lib/vast/inline_ad.rb +22 -0
- data/lib/vast/linear_creative.rb +57 -0
- data/lib/vast/mediafile.rb +56 -0
- data/lib/vast/non_linear_creative.rb +97 -0
- data/lib/vast/wrapper_ad.rb +19 -0
- data/lib/vast.rb +33 -0
- data/lib/vast3_draft.xsd +1036 -0
- data/lib/vast_2.0.1.xsd +643 -0
- data/test/ad_test.rb +122 -0
- data/test/companion_creative_test.rb +38 -0
- data/test/creative_test.rb +35 -0
- data/test/document_test.rb +72 -0
- data/test/examples/document_with_no_ads.xml +3 -0
- data/test/examples/document_with_one_inline_ad.xml +121 -0
- data/test/examples/document_with_one_inline_and_one_wrapper_ad.xml +105 -0
- data/test/examples/document_with_one_wrapper_ad.xml +40 -0
- data/test/examples/document_with_two_inline_ads.xml +120 -0
- data/test/examples/invalid_document.xml +3 -0
- data/test/examples/invalid_document_with_missing_ad_type.xml +58 -0
- data/test/examples/invalid_document_with_missing_creative_type.xml +39 -0
- data/test/examples/vast3_inline.xml +86 -0
- data/test/extension_test.rb +20 -0
- data/test/inline_ad_test.rb +14 -0
- data/test/linear_creative_test.rb +26 -0
- data/test/mediafile_test.rb +20 -0
- data/test/non_linear_creative_test.rb +39 -0
- data/test/test_helper.rb +13 -0
- data/test/vast3_inline_ad_test.rb +23 -0
- data/test/wrapper_ad_test.rb +16 -0
- metadata +94 -0
@@ -0,0 +1,97 @@
|
|
1
|
+
module VAST
|
2
|
+
# NonLinearCreative runs concurrently with the video content so the users see the ad while viewing
|
3
|
+
# the content. Non-linear video ads can be delivered as text, graphical ads, or as video overlays.
|
4
|
+
class NonLinearCreative < Creative
|
5
|
+
|
6
|
+
def id
|
7
|
+
source_node[:id]
|
8
|
+
end
|
9
|
+
|
10
|
+
# Width in pixels
|
11
|
+
def width
|
12
|
+
source_node[:width].to_i
|
13
|
+
end
|
14
|
+
|
15
|
+
# Height in pixels
|
16
|
+
def height
|
17
|
+
source_node[:height].to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
# Width in pixels when in expanded state
|
21
|
+
def expanded_width
|
22
|
+
source_node[:expandedWidth].to_i
|
23
|
+
end
|
24
|
+
|
25
|
+
# Height in pixels when in expanded state
|
26
|
+
def expanded_height
|
27
|
+
source_node[:expandedHeight].to_i
|
28
|
+
end
|
29
|
+
|
30
|
+
# Defines the method to use for communication with the companion
|
31
|
+
def api_framework
|
32
|
+
source_node[:apiFramework]
|
33
|
+
end
|
34
|
+
|
35
|
+
# URI to open as destination page when user clicks on creative
|
36
|
+
def click_through_url
|
37
|
+
URI.parse URI.escape(source_node.at('NonLinearClickThrough').content.strip)
|
38
|
+
end
|
39
|
+
|
40
|
+
def click_tracking_url
|
41
|
+
URI.parse URI.escape(source_node.at('NonLinearClickTracking').content.strip)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Whether it is acceptable to scale the mediafile.
|
45
|
+
def scalable?
|
46
|
+
source_node[:scalable]=="true"
|
47
|
+
end
|
48
|
+
|
49
|
+
# Whether the mediafile must have its aspect ratio maintained when scaled
|
50
|
+
def maintain_aspect_ratio?
|
51
|
+
source_node[:maintainAspectRatio]=="true"
|
52
|
+
end
|
53
|
+
|
54
|
+
# Suggested duration to display non-linear ad, typically for animation to complete.
|
55
|
+
# Expressed in standard time format hh:mm:ss
|
56
|
+
def min_suggested_duration
|
57
|
+
source_node[:minSuggestedDuration]
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# Type of non-linear resource, returned as a symbol. Either :static, :iframe, or :html.
|
62
|
+
def resource_type
|
63
|
+
if source_node.at('StaticResource')
|
64
|
+
:static
|
65
|
+
elsif source_node.at('IFrameResource')
|
66
|
+
:iframe
|
67
|
+
elsif source_node.at('HTMLResource')
|
68
|
+
:html
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns MIME type of static creative
|
73
|
+
def creative_type
|
74
|
+
if resource_type == :static
|
75
|
+
source_node.at('StaticResource')[:creativeType]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Returns URI for static or iframe resource
|
80
|
+
def resource_url
|
81
|
+
case resource_type
|
82
|
+
when :static
|
83
|
+
URI.parse URI.escape(source_node.at('StaticResource').content.strip)
|
84
|
+
when :iframe
|
85
|
+
URI.parse URI.escape(source_node.at('IFrameResource').content.strip)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Returns HTML text for html resource
|
90
|
+
def resource_html
|
91
|
+
if resource_type == :html
|
92
|
+
source_node.at('HTMLResource').content
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module VAST
|
2
|
+
# Points to another VAST document on a different server.
|
3
|
+
#
|
4
|
+
# WrapperAds may include any number of tracking urls to allow CompanionCreatives to be served
|
5
|
+
# from an InlineAd response but tracked separately from the Impression. It may also include
|
6
|
+
# tracking elements for separately tracking LinearCreative or NonLinearCreative views or events.
|
7
|
+
#
|
8
|
+
# The server providing the WrapperAd may not know exactly which creative elements are to be
|
9
|
+
# delivered downline in inline ads; in that case the WrapperAd should include placeholders for
|
10
|
+
# the maximum set of Creatives that could be played within the Video Player.
|
11
|
+
class WrapperAd < Ad
|
12
|
+
|
13
|
+
# URI of ad tag of downstream Secondary Ad Server
|
14
|
+
def ad_tag_url
|
15
|
+
URI.parse URI.escape(source_node.at('VASTAdTagURI').content.strip)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/vast.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
require 'vast/document'
|
4
|
+
require 'vast/element'
|
5
|
+
require 'vast/ad'
|
6
|
+
require 'vast/inline_ad'
|
7
|
+
require 'vast/wrapper_ad'
|
8
|
+
require 'vast/creative'
|
9
|
+
require 'vast/linear_creative'
|
10
|
+
require 'vast/mediafile'
|
11
|
+
require 'vast/icon'
|
12
|
+
require 'vast/companion_creative'
|
13
|
+
require 'vast/non_linear_creative'
|
14
|
+
require 'vast/extension'
|
15
|
+
|
16
|
+
# This module wraps VAST documents, as outlined by the IAB at http://www.iab.net/media/file/VAST-2_0-FINAL.pdf
|
17
|
+
module VAST
|
18
|
+
VAST_VERSION = 2.0
|
19
|
+
VAST_SCHEMA_XSD_FILE = File.expand_path(File.join(File.dirname(__FILE__), 'vast_2.0.1.xsd'))
|
20
|
+
VAST3_SCHEMA_XSD_FILE = File.expand_path(File.join(File.dirname(__FILE__), 'vast3_draft.xsd'))
|
21
|
+
|
22
|
+
class VASTError < StandardError; end
|
23
|
+
|
24
|
+
# Raised when parsing a VAST document that does not conform to the VAST spec XSD
|
25
|
+
class InvalidDocumentError < VASTError; end
|
26
|
+
|
27
|
+
# Raised when parsing a VAST ad node that is not complete
|
28
|
+
class InvalidAdError < VASTError; end
|
29
|
+
|
30
|
+
# Raised when parsing a VAST creative node that is not complete
|
31
|
+
class InvalidCreativeError < VASTError; end
|
32
|
+
|
33
|
+
end
|