openx 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +26 -0
- data/README.txt +80 -0
- data/Rakefile +40 -0
- data/lib/openx.rb +7 -0
- data/lib/openx/image.rb +22 -0
- data/lib/openx/services.rb +8 -0
- data/lib/openx/services/advertiser.rb +32 -0
- data/lib/openx/services/agency.rb +35 -0
- data/lib/openx/services/banner.rb +80 -0
- data/lib/openx/services/base.rb +125 -0
- data/lib/openx/services/campaign.rb +46 -0
- data/lib/openx/services/publisher.rb +32 -0
- data/lib/openx/services/session.rb +25 -0
- data/lib/openx/services/zone.rb +99 -0
- data/test/assets/300x250.jpg +0 -0
- data/test/assets/cat.swf +0 -0
- data/test/helper.rb +99 -0
- data/test/test_advertiser.rb +82 -0
- data/test/test_agency.rb +94 -0
- data/test/test_banner.rb +82 -0
- data/test/test_base.rb +37 -0
- data/test/test_campaign.rb +64 -0
- data/test/test_publisher.rb +69 -0
- data/test/test_session.rb +24 -0
- data/test/test_zone.rb +100 -0
- metadata +98 -0
data/test/test_banner.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
class BannerTest < OpenX::TestCase
|
5
|
+
def test_destroy
|
6
|
+
params = init_params
|
7
|
+
banner = Banner.create!(params)
|
8
|
+
id = banner.id
|
9
|
+
assert_nothing_raised {
|
10
|
+
banner.destroy
|
11
|
+
}
|
12
|
+
assert_raises(XMLRPC::FaultException) {
|
13
|
+
Banner.find(id)
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_find
|
18
|
+
params = init_params
|
19
|
+
banner = Banner.create!(params)
|
20
|
+
assert_not_nil banner
|
21
|
+
found_banner = Banner.find(banner.id)
|
22
|
+
assert_not_nil found_banner
|
23
|
+
assert_equal(banner, found_banner)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_update
|
27
|
+
params = init_params
|
28
|
+
banner = Banner.create!(params)
|
29
|
+
assert_not_nil banner
|
30
|
+
banner.name = 'super awesome'
|
31
|
+
banner.save!
|
32
|
+
|
33
|
+
found = Banner.find(banner.id)
|
34
|
+
assert_equal('super awesome', found.name)
|
35
|
+
found.destroy
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_find_all
|
39
|
+
params = init_params
|
40
|
+
banner = Banner.create!(params)
|
41
|
+
list = Banner.find(:all, banner.campaign.id)
|
42
|
+
assert list.all? { |x| x.is_a?(Banner) }
|
43
|
+
assert list.any? { |x| x == banner }
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_create
|
47
|
+
banner = nil
|
48
|
+
params = init_params
|
49
|
+
assert_nothing_raised {
|
50
|
+
banner = Banner.create!(params)
|
51
|
+
}
|
52
|
+
assert_not_nil banner
|
53
|
+
params.each do |k,v|
|
54
|
+
assert_equal(v, banner.send(:"#{k}"))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_create_with_jpg
|
59
|
+
banner = nil
|
60
|
+
params = init_params.merge({
|
61
|
+
:image => OpenX::Image.new(File.open(TEST_JPG, 'rb'))
|
62
|
+
})
|
63
|
+
assert_nothing_raised {
|
64
|
+
banner = Banner.create!(params)
|
65
|
+
}
|
66
|
+
assert_not_nil banner
|
67
|
+
params.each do |k,v|
|
68
|
+
assert_equal(v, banner.send(:"#{k}"))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def init_params
|
73
|
+
{
|
74
|
+
:name => "Banner-#{Time.now}",
|
75
|
+
:storage_type => Banner::LOCAL_SQL,
|
76
|
+
:campaign => campaign,
|
77
|
+
:url => 'http://tenderlovemaking.com/',
|
78
|
+
:file_name => 'oogabooga',
|
79
|
+
:image => OpenX::Image.new(File.open(TEST_SWF, 'rb'))
|
80
|
+
}
|
81
|
+
end
|
82
|
+
end
|
data/test/test_base.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
class BaseTest < OpenX::TestCase
|
5
|
+
def test_configuration_reads_from_yaml
|
6
|
+
before_env = ENV['OPENX_ENV']
|
7
|
+
exists = false
|
8
|
+
contents = nil
|
9
|
+
if File.exists?(Base::CONFIGURATION_YAML)
|
10
|
+
exists = true
|
11
|
+
contents = File.read(Base::CONFIGURATION_YAML)
|
12
|
+
end
|
13
|
+
|
14
|
+
config = {
|
15
|
+
'awesome' => {
|
16
|
+
'username' => 'aaron',
|
17
|
+
'password' => 'p',
|
18
|
+
'url' => 'http://tenderlovemaking.com/',
|
19
|
+
}
|
20
|
+
}
|
21
|
+
ENV['OPENX_ENV'] = 'awesome'
|
22
|
+
|
23
|
+
Base.configuration = nil
|
24
|
+
FileUtils.mkdir_p(File.dirname(Base::CONFIGURATION_YAML))
|
25
|
+
File.open(Base::CONFIGURATION_YAML, 'wb') { |f|
|
26
|
+
f.write(YAML.dump(config))
|
27
|
+
}
|
28
|
+
assert_equal(config['awesome'], Base.configuration)
|
29
|
+
|
30
|
+
FileUtils.rm(Base::CONFIGURATION_YAML) if !exists
|
31
|
+
File.open(Base::CONFIGURATION_YAML, 'wb') { |f|
|
32
|
+
f.write(contents)
|
33
|
+
} if exists
|
34
|
+
ENV['OPENX_ENV'] = before_env
|
35
|
+
Base.configuration = nil
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
class CampaignTest < OpenX::TestCase
|
5
|
+
def test_destroy
|
6
|
+
a = nil
|
7
|
+
assert_nothing_raised {
|
8
|
+
a = Campaign.create!(init_params)
|
9
|
+
}
|
10
|
+
id = a.id
|
11
|
+
assert_nothing_raised {
|
12
|
+
a.destroy
|
13
|
+
}
|
14
|
+
assert_raises(XMLRPC::FaultException) {
|
15
|
+
Campaign.find(id)
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_create_campaign
|
20
|
+
campaign = nil
|
21
|
+
params = init_params
|
22
|
+
assert_nothing_raised {
|
23
|
+
campaign = Campaign.create!(params)
|
24
|
+
}
|
25
|
+
assert_not_nil campaign
|
26
|
+
params.each do |k,v|
|
27
|
+
assert_equal(v, campaign.send(:"#{k}"))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_find
|
32
|
+
a = nil
|
33
|
+
params = init_params
|
34
|
+
assert_nothing_raised {
|
35
|
+
a = Campaign.create!(params)
|
36
|
+
}
|
37
|
+
assert_not_nil a
|
38
|
+
a = Campaign.find(a.id)
|
39
|
+
assert a
|
40
|
+
assert_equal(params[:advertiser].id, a.advertiser.id)
|
41
|
+
params.each { |k,v|
|
42
|
+
assert_equal(v, a.send(:"#{k}"))
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_find_all
|
47
|
+
a = nil
|
48
|
+
params = init_params
|
49
|
+
assert_nothing_raised {
|
50
|
+
a = Campaign.create!(params)
|
51
|
+
}
|
52
|
+
list = Campaign.find(:all, a.advertiser.id)
|
53
|
+
assert list.all? { |x| x.is_a?(Campaign) }
|
54
|
+
assert list.any? { |x| x.name == params[:name] }
|
55
|
+
end
|
56
|
+
|
57
|
+
def init_params
|
58
|
+
{
|
59
|
+
:advertiser => advertiser,
|
60
|
+
:name => "Test Campaign-#{Time.now}",
|
61
|
+
:impressions => 2000
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class PublisherTest < OpenX::TestCase
|
4
|
+
def test_update
|
5
|
+
params = init_params
|
6
|
+
publisher = Publisher.create!(params)
|
7
|
+
found_pub = Publisher.find(publisher.id)
|
8
|
+
assert_equal(publisher, found_pub)
|
9
|
+
found_pub.name = 'awesome!!!!'
|
10
|
+
found_pub.save!
|
11
|
+
|
12
|
+
found_pub = Publisher.find(publisher.id)
|
13
|
+
assert_equal('awesome!!!!', found_pub.name)
|
14
|
+
found_pub.destroy
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_create
|
18
|
+
params = init_params
|
19
|
+
publisher = Publisher.create!(params)
|
20
|
+
assert_not_nil publisher
|
21
|
+
params.each do |k,v|
|
22
|
+
assert_equal(v, publisher.send(:"#{k}"))
|
23
|
+
end
|
24
|
+
publisher.destroy
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_find
|
28
|
+
params = init_params
|
29
|
+
publisher = Publisher.create!(params)
|
30
|
+
assert_not_nil publisher
|
31
|
+
found_pub = Publisher.find(publisher.id)
|
32
|
+
assert_equal(publisher, found_pub)
|
33
|
+
publisher.destroy
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_find_all
|
37
|
+
params = init_params
|
38
|
+
publisher = Publisher.create!(params)
|
39
|
+
publishers = Publisher.find(:all, agency.id)
|
40
|
+
pub = publishers.find { |a| a.id == publisher.id }
|
41
|
+
assert_not_nil pub
|
42
|
+
assert_equal(publisher, pub)
|
43
|
+
publisher.destroy
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_destroy
|
47
|
+
params = init_params
|
48
|
+
publisher = Publisher.create!(params)
|
49
|
+
assert_not_nil publisher
|
50
|
+
id = publisher.id
|
51
|
+
assert_nothing_raised {
|
52
|
+
publisher.destroy
|
53
|
+
}
|
54
|
+
assert_raises(XMLRPC::FaultException) {
|
55
|
+
Publisher.find(id)
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def init_params
|
60
|
+
{
|
61
|
+
:agency => agency,
|
62
|
+
:name => "Publisher! - #{Time.now}",
|
63
|
+
:contact_name => 'Aaron Patterson',
|
64
|
+
:email => 'aaron@tenderlovemaking.com',
|
65
|
+
:username => 'one',
|
66
|
+
:password => 'two',
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class SessionTest < OpenX::TestCase
|
4
|
+
def test_login
|
5
|
+
config = Base.configuration
|
6
|
+
session = Session.new(config['url'])
|
7
|
+
assert_nothing_raised {
|
8
|
+
session.create(config['username'], config['password'])
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_logout
|
13
|
+
config = Base.configuration
|
14
|
+
session = Session.new(config['url'])
|
15
|
+
assert_nothing_raised {
|
16
|
+
session.create(config['username'], config['password'])
|
17
|
+
}
|
18
|
+
assert_not_nil session.id
|
19
|
+
assert_nothing_raised {
|
20
|
+
session.destroy
|
21
|
+
}
|
22
|
+
assert_nil session.id
|
23
|
+
end
|
24
|
+
end
|
data/test/test_zone.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class ZoneTest < OpenX::TestCase
|
4
|
+
def test_create
|
5
|
+
params = init_params
|
6
|
+
zone = Zone.create!(params)
|
7
|
+
assert_not_nil zone
|
8
|
+
params.each do |k,v|
|
9
|
+
assert_equal(v, zone.send(:"#{k}"))
|
10
|
+
end
|
11
|
+
zone.destroy
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_find
|
15
|
+
params = init_params
|
16
|
+
zone = Zone.create!(params)
|
17
|
+
assert_not_nil zone
|
18
|
+
found_zone = Zone.find(zone.id)
|
19
|
+
assert_not_nil found_zone
|
20
|
+
assert_equal(zone, found_zone)
|
21
|
+
zone.destroy
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_find_all
|
25
|
+
params = init_params
|
26
|
+
zone = Zone.create!(params)
|
27
|
+
assert_not_nil zone
|
28
|
+
|
29
|
+
zones = Zone.find(:all, publisher.id)
|
30
|
+
assert_equal(zones.sort, publisher.zones.sort)
|
31
|
+
found_zone = zones.find { |z| z.id == zone.id }
|
32
|
+
assert found_zone
|
33
|
+
assert_equal(zone, found_zone)
|
34
|
+
zone.destroy
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_destroy
|
38
|
+
params = init_params
|
39
|
+
zone = Zone.create!(params)
|
40
|
+
assert_not_nil zone
|
41
|
+
id = zone.id
|
42
|
+
assert_nothing_raised {
|
43
|
+
zone.destroy
|
44
|
+
}
|
45
|
+
assert_raises(XMLRPC::FaultException) {
|
46
|
+
Zone.find(id)
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_update
|
51
|
+
params = init_params
|
52
|
+
zone = Zone.create!(params)
|
53
|
+
assert_not_nil zone
|
54
|
+
|
55
|
+
found_zone = Zone.find(zone.id)
|
56
|
+
found_zone.name = 'tenderlove'
|
57
|
+
found_zone.save!
|
58
|
+
|
59
|
+
found_zone = Zone.find(zone.id)
|
60
|
+
assert_equal('tenderlove', found_zone.name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_link_campaign
|
64
|
+
assert zone.link_campaign(campaign)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_unlink_campaign
|
68
|
+
assert_raises(XMLRPC::FaultException) {
|
69
|
+
zone.unlink_campaign(campaign)
|
70
|
+
}
|
71
|
+
assert zone.link_campaign(campaign)
|
72
|
+
assert zone.unlink_campaign(campaign)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_link_banner
|
76
|
+
assert zone.link_banner(banner)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_unlink_banner
|
80
|
+
assert_raises(XMLRPC::FaultException) {
|
81
|
+
zone.unlink_banner(banner)
|
82
|
+
}
|
83
|
+
assert zone.link_banner(banner)
|
84
|
+
assert zone.unlink_banner(banner)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_generate_tags
|
88
|
+
assert_match(/iframe/, zone.generate_tags)
|
89
|
+
end
|
90
|
+
|
91
|
+
def init_params
|
92
|
+
{
|
93
|
+
:publisher => publisher,
|
94
|
+
:name => "Zone - #{Time.now}",
|
95
|
+
:type => Zone::BANNER,
|
96
|
+
:width => 468,
|
97
|
+
:height => 60,
|
98
|
+
}
|
99
|
+
end
|
100
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openx
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Patterson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-10 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.8.2
|
24
|
+
version:
|
25
|
+
description: A Ruby interface to the OpenX XML-RPC API.
|
26
|
+
email:
|
27
|
+
- aaron.patterson@gmail.com
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- README.txt
|
36
|
+
files:
|
37
|
+
- History.txt
|
38
|
+
- Manifest.txt
|
39
|
+
- README.txt
|
40
|
+
- Rakefile
|
41
|
+
- lib/openx.rb
|
42
|
+
- lib/openx/image.rb
|
43
|
+
- lib/openx/services.rb
|
44
|
+
- lib/openx/services/advertiser.rb
|
45
|
+
- lib/openx/services/agency.rb
|
46
|
+
- lib/openx/services/banner.rb
|
47
|
+
- lib/openx/services/base.rb
|
48
|
+
- lib/openx/services/campaign.rb
|
49
|
+
- lib/openx/services/publisher.rb
|
50
|
+
- lib/openx/services/session.rb
|
51
|
+
- lib/openx/services/zone.rb
|
52
|
+
- test/assets/300x250.jpg
|
53
|
+
- test/assets/cat.swf
|
54
|
+
- test/helper.rb
|
55
|
+
- test/test_advertiser.rb
|
56
|
+
- test/test_agency.rb
|
57
|
+
- test/test_banner.rb
|
58
|
+
- test/test_base.rb
|
59
|
+
- test/test_campaign.rb
|
60
|
+
- test/test_publisher.rb
|
61
|
+
- test/test_session.rb
|
62
|
+
- test/test_zone.rb
|
63
|
+
has_rdoc: true
|
64
|
+
homepage: http://openx.rubyforge.org
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options:
|
67
|
+
- --main
|
68
|
+
- README.txt
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
version:
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project: openx
|
86
|
+
rubygems_version: 1.3.1
|
87
|
+
signing_key:
|
88
|
+
specification_version: 2
|
89
|
+
summary: A Ruby interface to the OpenX XML-RPC API.
|
90
|
+
test_files:
|
91
|
+
- test/test_advertiser.rb
|
92
|
+
- test/test_agency.rb
|
93
|
+
- test/test_banner.rb
|
94
|
+
- test/test_base.rb
|
95
|
+
- test/test_campaign.rb
|
96
|
+
- test/test_publisher.rb
|
97
|
+
- test/test_session.rb
|
98
|
+
- test/test_zone.rb
|