From 168113a11fb53ad32dd79ee3ff42d004ba8542e2 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Wed, 30 Sep 2009 10:30:09 +1000 Subject: [PATCH 01/36] Add basic support for XMLRPC invocation of OpenX ads --- lib/openx/invocation.rb | 63 ++++++++++++++++++++++++++++++++++++++ lib/openx/xmlrpc_client.rb | 48 +++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 lib/openx/invocation.rb create mode 100644 lib/openx/xmlrpc_client.rb diff --git a/lib/openx/invocation.rb b/lib/openx/invocation.rb new file mode 100644 index 0000000..6744805 --- /dev/null +++ b/lib/openx/invocation.rb @@ -0,0 +1,63 @@ +module OpenX + class Invocation + class << self + # + # banner = OpenX::Invocation.view("Plumber") + # + # banners = OpenX::Invocation.view("Plumber", :count => 2, :exclude_by_bannerid => true) ;nil + # banners.each do |banner| + # puts "Banner #{banner['bannerid']}" + # end; nil + # + def view(what, params = {}) + defaults = { + :count => 1, + :campaignid => 0, + :target => '', + :source => '', + :with_text => false, + :exclusions => [], + :inclusions => [], + :exclude_by_campaignid => false, + :exclude_by_bannerid => false + } + params = defaults.merge(params) + + url = OpenX::Services::Base.configuration['invocation_url'] + + settings = {:cookies => [], :remote_addr => 'localhost'} + + context = [] # used by reference after initial use + params[:exclusions].each { |item| context << convert_to_context(false, item) } + params[:inclusions].each { |item| context << convert_to_context(true, item) } + count = params[:count].to_i + + remote_params = [ what, params[:campaignid], params[:target], params[:source], params[:with_text], context] + server = XmlrpcClient.new2(url) + + out = [] + if count > 0 + (0...count).each do + out << banner = server.call('openads.view', settings, *remote_params) + if count > 1 + if params[:exclude_by_campaignid] + campaign_id = banner['campaignid'] + context << convert_to_context(false, "campaignid:#{campaign_id}") + elsif params[:exclude_by_bannerid] + banner_id = banner['bannerid'] + context << convert_to_context(false, "bannerid:#{banner_id}") + end + end + end + end + count > 1 ? out : out.first + end + + def convert_to_context(is_inclusion, item) + key = is_inclusion ? '==' : '!=' + { key => item } + end + protected :convert_to_context + end + end +end diff --git a/lib/openx/xmlrpc_client.rb b/lib/openx/xmlrpc_client.rb new file mode 100644 index 0000000..faac8f2 --- /dev/null +++ b/lib/openx/xmlrpc_client.rb @@ -0,0 +1,48 @@ +require 'xmlrpc/client' + +module OpenX + + unless defined? HTTPBroken + # A module that captures all the possible Net::HTTP exceptions + # from http://pastie.org/pastes/145154 + module HTTPBroken; end + + [Timeout::Error, Errno::EINVAL, Errno::EPIPE, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, + Net::HTTPHeaderSyntaxError, Net::ProtocolError].each {|m| m.send(:include, HTTPBroken)} + end + + class XmlrpcClient + @uri = nil + @server = nil + + @@retry_on_http_error = true + @@timeout = 10 # seconds + cattr_accessor :retry_on_http_error, :timeout + + class << self + def init_server(uri) + server = XMLRPC::Client.new2(uri) + server.timeout = self.timeout + server + end + protected :init_server + + def new2(uri) + @uri = uri + @server = init_server(uri) + end + end + + + def call(method, *args) + begin + @server.call(method, *args) + rescue HTTPBroken => httpbe + if self.class.retry_on_http_error + @server = init_server(uri) + @server.call(method, *args) + end + end + end + end +end From 5283812dbf1278aa67f90c780900e4c879bb1913 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Wed, 30 Sep 2009 10:59:16 +1000 Subject: [PATCH 02/36] Add basic support for XMLRPC invocation of OpenX ads (version bump) --- .gitignore | 1 + lib/openx.rb | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1377554..ec4911e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.swp +.svn/ diff --git a/lib/openx.rb b/lib/openx.rb index 4a01b8a..c06dd2a 100644 --- a/lib/openx.rb +++ b/lib/openx.rb @@ -1,7 +1,9 @@ require 'xmlrpc/client' +require 'openx/xmlrpc_client' require 'openx/services' +require 'openx/invocation' require 'openx/image' module OpenX - VERSION = '1.0.0' + VERSION = '1.0.1' end From 4ed547cdd249c4aea88f7bd2af696578627aa392 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Wed, 30 Sep 2009 11:07:29 +1000 Subject: [PATCH 03/36] Update readme information with configuration and copyright info --- README.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.txt b/README.txt index 1b3547e..e19fa62 100644 --- a/README.txt +++ b/README.txt @@ -46,10 +46,13 @@ A Ruby interface to the OpenX XML-RPC API. production: username: admin password: admin - url: http://localhost/~asmith/openx/www/api/v2/xmlrpc/ + url: http://www.example.com/www/api/v2/xmlrpc/ + invocation_url: http://www.example.com/www/delivery/axmlrpc.php The YAML file lists configuration for each environment. The gem uses the -'production' environment by default. +'production' environment by default. Trailing slash is required on the 'url'. +'invocation_url' is only used by the OpenX::Invocation methods to serve +advertisements over XML-RPC == LICENSE: @@ -59,6 +62,7 @@ Copyright (c) 2008: * {Aaron Patterson}[http://tenderlovemaking.com] * Andy Smith +* {TouchLocal P/L}[http://www.touchlocal.com] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From 22b5ebf5cbc27d68fd9c8c54b4c1fe461b9eaa3a Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Wed, 30 Sep 2009 14:56:14 +1000 Subject: [PATCH 04/36] Change to using internal XMLRPC Client that has some simple retry/reconnection behaviour. Helps subsequent calls to .save! (etc) to not raise HTTP Exceptions --- lib/openx/services/banner.rb | 2 +- lib/openx/services/base.rb | 4 ++-- lib/openx/services/session.rb | 2 +- lib/openx/services/zone.rb | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/openx/services/banner.rb b/lib/openx/services/banner.rb index 6319faa..7da3ea4 100644 --- a/lib/openx/services/banner.rb +++ b/lib/openx/services/banner.rb @@ -15,7 +15,7 @@ class Banner < Base class << self def find(id, *args) session = self.connection - server = XMLRPC::Client.new2("#{session.url}") + server = XmlrpcClient.new2("#{session.url}") if id == :all responses = server.call(find_all(), session.id, *args) response = responses.first diff --git a/lib/openx/services/base.rb b/lib/openx/services/base.rb index 4ae4a9d..286531d 100644 --- a/lib/openx/services/base.rb +++ b/lib/openx/services/base.rb @@ -60,7 +60,7 @@ def has_one(*things) def find(id, *args) session = self.connection - server = XMLRPC::Client.new2("#{session.url}") + server = XmlrpcClient.new2("#{session.url}") if id == :all responses = server.call(find_all(), session.id, *args) responses.map { |response| @@ -89,7 +89,7 @@ def translate(response) def initialize(params = {}) @id = nil params.each { |k,v| send(:"#{k}=", v) } - @server = XMLRPC::Client.new2("#{self.class.connection.url}") + @server = XmlrpcClient.new2("#{self.class.connection.url}") #@server.instance_variable_get(:@http).set_debug_output($stderr) end diff --git a/lib/openx/services/session.rb b/lib/openx/services/session.rb index bb5fbcb..86d9647 100644 --- a/lib/openx/services/session.rb +++ b/lib/openx/services/session.rb @@ -5,7 +5,7 @@ class Session def initialize(url) @url = url - @server = XMLRPC::Client.new2("#{@url}") + @server = XmlrpcClient.new2("#{@url}") @id = nil end diff --git a/lib/openx/services/zone.rb b/lib/openx/services/zone.rb index af60a1c..04277a9 100644 --- a/lib/openx/services/zone.rb +++ b/lib/openx/services/zone.rb @@ -33,7 +33,7 @@ class << self # Deliver +zone_id+ to +ip_address+ with +cookies+, def deliver zone_id, ip_address = '192.168.1.1', cookies = [] url = "#{self.configuration['root']}/delivery/axmlrpc.php" - server = XMLRPC::Client.new2(url) + server = XmlrpcClient.new2(url) server.call('openads.view', { 'cookies' => cookies, 'remote_addr' => ip_address, @@ -53,7 +53,7 @@ def link_campaign(campaign) raise ArgumentError.new("Campaign must be saved")if campaign.new_record? session = self.class.connection - server = XMLRPC::Client.new2("#{session.url}") + server = XmlrpcClient.new2("#{session.url}") server.call("ox.linkCampaign", session.id, self.id, campaign.id) end @@ -63,7 +63,7 @@ def unlink_campaign(campaign) raise ArgumentError.new("Campaign must be saved")if campaign.new_record? session = self.class.connection - server = XMLRPC::Client.new2("#{session.url}") + server = XmlrpcClient.new2("#{session.url}") server.call("ox.unlinkCampaign", session.id, self.id, campaign.id) end @@ -73,7 +73,7 @@ def link_banner(banner) raise ArgumentError.new("Banner must be saved")if banner.new_record? session = self.class.connection - server = XMLRPC::Client.new2("#{session.url}") + server = XmlrpcClient.new2("#{session.url}") server.call("ox.linkBanner", session.id, self.id, banner.id) end @@ -83,14 +83,14 @@ def unlink_banner(banner) raise ArgumentError.new("Banner must be saved")if banner.new_record? session = self.class.connection - server = XMLRPC::Client.new2("#{session.url}") + server = XmlrpcClient.new2("#{session.url}") server.call("ox.unlinkBanner", session.id, self.id, banner.id) end # Generate tags for displaying this zone using +tag_type+ def generate_tags(tag_type = IFRAME) session = self.class.connection - server = XMLRPC::Client.new2("#{session.url}") + server = XmlrpcClient.new2("#{session.url}") server.call("ox.generateTags", session.id, self.id, tag_type, []) end end From 807c383c3cb0111b88eec1b742091139875e751e Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Wed, 30 Sep 2009 15:01:06 +1000 Subject: [PATCH 05/36] Move (commented-out) debug lines to new class --- lib/openx/services/base.rb | 1 - lib/openx/xmlrpc_client.rb | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/openx/services/base.rb b/lib/openx/services/base.rb index 286531d..0530f51 100644 --- a/lib/openx/services/base.rb +++ b/lib/openx/services/base.rb @@ -90,7 +90,6 @@ def initialize(params = {}) @id = nil params.each { |k,v| send(:"#{k}=", v) } @server = XmlrpcClient.new2("#{self.class.connection.url}") - #@server.instance_variable_get(:@http).set_debug_output($stderr) end def new_record?; @id.nil?; end diff --git a/lib/openx/xmlrpc_client.rb b/lib/openx/xmlrpc_client.rb index faac8f2..8a805f8 100644 --- a/lib/openx/xmlrpc_client.rb +++ b/lib/openx/xmlrpc_client.rb @@ -23,6 +23,7 @@ class << self def init_server(uri) server = XMLRPC::Client.new2(uri) server.timeout = self.timeout + #server.instance_variable_get(:@http).set_debug_output($stderr) server end protected :init_server From b5cff44bfe3cdcac039201c7b65e5cdaba1a8904 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Mon, 5 Oct 2009 14:52:44 +1000 Subject: [PATCH 06/36] Add support for accessing keywords on OpenX banners (where server is patched to support it) --- lib/openx/services/banner.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/openx/services/banner.rb b/lib/openx/services/banner.rb index 7da3ea4..537f5da 100644 --- a/lib/openx/services/banner.rb +++ b/lib/openx/services/banner.rb @@ -57,7 +57,11 @@ def find(id, *args) :adserver => :adserver, :transparent => :transparent, :image => :aImage, - :backup_image => :aBackupImage + :backup_image => :aBackupImage, + # 'keyword' only supported by patched server + # as per https://developer.openx.org/jira/browse/OX-4779 + # No averse effect when unsupported by server (returns nil) + :keyword => :keyword has_one :campaign From 496cb64ab66c1342f8eb8eed732205e22780f176 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Fri, 23 Oct 2009 14:30:00 +1000 Subject: [PATCH 07/36] Add explicit support for retrying in the face of 'Session ID is invalid' errors from the OpenX server --- lib/openx/invocation.rb | 2 +- lib/openx/services/banner.rb | 12 ++++++------ lib/openx/services/base.rb | 10 +++++----- lib/openx/services/campaign.rb | 2 +- lib/openx/services/session.rb | 11 ++++++++++- lib/openx/services/zone.rb | 10 +++++----- lib/openx/xmlrpc_client.rb | 36 ++++++++++++++++++++++++++++++---- 7 files changed, 60 insertions(+), 23 deletions(-) diff --git a/lib/openx/invocation.rb b/lib/openx/invocation.rb index 6744805..3a96e57 100644 --- a/lib/openx/invocation.rb +++ b/lib/openx/invocation.rb @@ -4,7 +4,7 @@ class << self # # banner = OpenX::Invocation.view("Plumber") # - # banners = OpenX::Invocation.view("Plumber", :count => 2, :exclude_by_bannerid => true) ;nil + # banners = OpenX::Invocation.view("Plumber", :count => 2, :exclude_by_campaignid => true) ;nil # banners.each do |banner| # puts "Banner #{banner['bannerid']}" # end; nil diff --git a/lib/openx/services/banner.rb b/lib/openx/services/banner.rb index 537f5da..baa0d47 100644 --- a/lib/openx/services/banner.rb +++ b/lib/openx/services/banner.rb @@ -17,7 +17,7 @@ def find(id, *args) session = self.connection server = XmlrpcClient.new2("#{session.url}") if id == :all - responses = server.call(find_all(), session.id, *args) + responses = server.call(find_all(), session, *args) response = responses.first return [] unless response responses = [response] @@ -34,7 +34,7 @@ def find(id, *args) new(translate(response)) } else - response = server.call(find_one(), session.id, id) + response = server.call(find_one(), session, id) new(translate(response)) end end @@ -72,24 +72,24 @@ def find(id, *args) self.find_all = 'ox.getBannerListByCampaignId' def initialize(params = {}) - raise ArgumentError unless params[:campaign_id] || params[:campaign] + raise ArgumentError.new("Missing campaign_id") unless params[:campaign_id] || params[:campaign] params[:campaign_id] ||= params[:campaign].id super(params) end def statistics start_on = Date.today, end_on = Date.today session = self.class.connection - @server.call('ox.bannerDailyStatistics', session.id, self.id, start_on, end_on) + @server.call('ox.bannerDailyStatistics', session, self.id, start_on, end_on) end def targeting session = self.class.connection - @server.call('ox.getBannerTargeting', session.id, self.id) + @server.call('ox.getBannerTargeting', session, self.id) end def targeting= targeting session = self.class.connection - @server.call('ox.setBannerTargeting', session.id, self.id, targeting) + @server.call('ox.setBannerTargeting', session, self.id, targeting) end end end diff --git a/lib/openx/services/base.rb b/lib/openx/services/base.rb index 0530f51..e0bad2d 100644 --- a/lib/openx/services/base.rb +++ b/lib/openx/services/base.rb @@ -62,12 +62,12 @@ def find(id, *args) session = self.connection server = XmlrpcClient.new2("#{session.url}") if id == :all - responses = server.call(find_all(), session.id, *args) + responses = server.call(find_all(), session, *args) responses.map { |response| new(translate(response)) } else - response = server.call(find_one(), session.id, id) + response = server.call(find_one(), session, id) new(translate(response)) end end @@ -103,16 +103,16 @@ def save! } if new_record? - @id = @server.call(self.class.create, session.id, params) + @id = @server.call(self.class.create, session, params) else - @server.call(self.class.update, session.id, params) + @server.call(self.class.update, session, params) end self end def destroy session = self.class.connection - @server.call(self.class.delete, session.id, id) + @server.call(self.class.delete, session, id) @id = nil end diff --git a/lib/openx/services/campaign.rb b/lib/openx/services/campaign.rb index 17bb72e..82ff56a 100644 --- a/lib/openx/services/campaign.rb +++ b/lib/openx/services/campaign.rb @@ -38,7 +38,7 @@ class Campaign < Base EXCLUSIVE = 3 def initialize(params = {}) - raise ArgumentError unless params[:advertiser_id] || params[:advertiser] + raise ArgumentError.new("Missing advertiser_id") unless params[:advertiser_id] || params[:advertiser] params[:advertiser_id] ||= params[:advertiser].id super(params) end diff --git a/lib/openx/services/session.rb b/lib/openx/services/session.rb index 86d9647..fd31d29 100644 --- a/lib/openx/services/session.rb +++ b/lib/openx/services/session.rb @@ -2,6 +2,7 @@ module OpenX module Services class Session attr_accessor :url, :id + attr_accessor :user, :password def initialize(url) @url = url @@ -10,7 +11,15 @@ def initialize(url) end def create(user, password) - @id = @server.call('ox.logon', user, password) + @user = user + @password = password + @id = @server.call('ox.logon', @user, @password) + self + end + + def recreate! + raise "Unable to refresh Session" unless @user && @password + @id = @server.call('ox.logon', @user, @password) self end diff --git a/lib/openx/services/zone.rb b/lib/openx/services/zone.rb index 04277a9..358c61d 100644 --- a/lib/openx/services/zone.rb +++ b/lib/openx/services/zone.rb @@ -54,7 +54,7 @@ def link_campaign(campaign) session = self.class.connection server = XmlrpcClient.new2("#{session.url}") - server.call("ox.linkCampaign", session.id, self.id, campaign.id) + server.call("ox.linkCampaign", session, self.id, campaign.id) end # Unlink this zone from +campaign+ @@ -64,7 +64,7 @@ def unlink_campaign(campaign) session = self.class.connection server = XmlrpcClient.new2("#{session.url}") - server.call("ox.unlinkCampaign", session.id, self.id, campaign.id) + server.call("ox.unlinkCampaign", session, self.id, campaign.id) end # Link this zone to +banner+ @@ -74,7 +74,7 @@ def link_banner(banner) session = self.class.connection server = XmlrpcClient.new2("#{session.url}") - server.call("ox.linkBanner", session.id, self.id, banner.id) + server.call("ox.linkBanner", session, self.id, banner.id) end # Unlink this zone from +banner+ @@ -84,14 +84,14 @@ def unlink_banner(banner) session = self.class.connection server = XmlrpcClient.new2("#{session.url}") - server.call("ox.unlinkBanner", session.id, self.id, banner.id) + server.call("ox.unlinkBanner", session, self.id, banner.id) end # Generate tags for displaying this zone using +tag_type+ def generate_tags(tag_type = IFRAME) session = self.class.connection server = XmlrpcClient.new2("#{session.url}") - server.call("ox.generateTags", session.id, self.id, tag_type, []) + server.call("ox.generateTags", session, self.id, tag_type, []) end end end diff --git a/lib/openx/xmlrpc_client.rb b/lib/openx/xmlrpc_client.rb index 8a805f8..49ad68c 100644 --- a/lib/openx/xmlrpc_client.rb +++ b/lib/openx/xmlrpc_client.rb @@ -26,24 +26,52 @@ def init_server(uri) #server.instance_variable_get(:@http).set_debug_output($stderr) server end - protected :init_server def new2(uri) - @uri = uri - @server = init_server(uri) + server = init_server(uri) + new(server, uri) end end + def initialize(server, uri) + @server = server + @uri = uri + end def call(method, *args) + if args.first.is_a?(OpenX::Services::Session) + session = args.shift() + args.unshift(session.id) + begin + do_call(method, *args) + rescue XMLRPC::FaultException => sess_id_err + if sess_id_err.message.strip == 'Session ID is invalid' + session.recreate! + args.shift() + args.unshift(session.id) + do_call(method, *args) + else + raise sess_id_err + end + end + else + do_call(method, *args) + end + end + + def do_call(method, *args) begin @server.call(method, *args) rescue HTTPBroken => httpbe if self.class.retry_on_http_error - @server = init_server(uri) + @server = self.class.init_server(@uri) @server.call(method, *args) + else + raise httpbe end end end + private :do_call + end end From b9e7e2ebdcb9b748bde0962f113a17fe3fc20c49 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Mon, 26 Oct 2009 14:40:27 +1000 Subject: [PATCH 08/36] Version bump to 0.0.0 --- VERSION | 1 + 1 file changed, 1 insertion(+) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..77d6f4c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.0 From cab34a5bb621b5ce42ba701ab3b7495bc3ce8e61 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Mon, 26 Oct 2009 14:40:50 +1000 Subject: [PATCH 09/36] Version bump to 1.0.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 77d6f4c..3eefcb9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.0 +1.0.0 From a5ba5f81d9eb18e2223808a4341f59a5d65997f7 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Mon, 26 Oct 2009 14:40:56 +1000 Subject: [PATCH 10/36] Version bump to 1.1.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3eefcb9..9084fa2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +1.1.0 From 9d3536220a8302537735527112bc73c6b5fb799e Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Mon, 26 Oct 2009 15:17:42 +1000 Subject: [PATCH 11/36] Remove inadvertent dependence on ActiveSupport --- lib/openx/xmlrpc_client.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/openx/xmlrpc_client.rb b/lib/openx/xmlrpc_client.rb index 49ad68c..1fd4fad 100644 --- a/lib/openx/xmlrpc_client.rb +++ b/lib/openx/xmlrpc_client.rb @@ -15,11 +15,12 @@ class XmlrpcClient @uri = nil @server = nil - @@retry_on_http_error = true - @@timeout = 10 # seconds - cattr_accessor :retry_on_http_error, :timeout + @retry_on_http_error = true + @timeout = 10 # seconds class << self + attr_accessor :retry_on_http_error, :timeout + def init_server(uri) server = XMLRPC::Client.new2(uri) server.timeout = self.timeout From 6264effd8d72f46a5b5d20101991b5afa15a25a6 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Mon, 26 Oct 2009 15:38:06 +1000 Subject: [PATCH 12/36] Package and deploy gem to gemcutter.org --- .gitignore | 1 + Rakefile | 32 ++++++++--------- lib/openx.rb | 2 +- touchlocal-openx.gemspec | 77 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 17 deletions(-) create mode 100644 touchlocal-openx.gemspec diff --git a/.gitignore b/.gitignore index ec4911e..bcef9c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.swp .svn/ +pkg/ diff --git a/Rakefile b/Rakefile index c179232..ad25542 100644 --- a/Rakefile +++ b/Rakefile @@ -1,16 +1,26 @@ # -*- ruby -*- require 'rubygems' -require 'hoe' +require 'rake' + +begin + require 'jeweler' + Jeweler::Tasks.new do |gemspec| + gemspec.name = "touchlocal-openx" + gemspec.summary = "A Ruby interface to the OpenX XML-RPC API" + gemspec.description = "A Ruby interface to the OpenX XML-RPC API" + gemspec.email = "info@touchlocal.com" + gemspec.homepage = "http://github.com/touchlocal/openx" + gemspec.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc"] + end + Jeweler::GemcutterTasks.new +rescue LoadError + puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" +end $: << "lib/" require 'openx' -HOE = Hoe.new('openx', OpenX::VERSION) do |p| - # p.rubyforge_name = 'ruby-openxx' # if different than lowercase project name - p.developer('Aaron Patterson', 'aaron.patterson@gmail.com') -end - namespace :openx do task :clean do include OpenX::Services @@ -28,13 +38,3 @@ namespace :openx do end end end - -namespace :gem do - task :spec do - File.open("#{HOE.name}.gemspec", 'w') do |f| - f.write(HOE.spec.to_ruby) - end - end -end - -# vim: syntax=Ruby diff --git a/lib/openx.rb b/lib/openx.rb index c06dd2a..1fc8240 100644 --- a/lib/openx.rb +++ b/lib/openx.rb @@ -5,5 +5,5 @@ require 'openx/image' module OpenX - VERSION = '1.0.1' + VERSION = '1.1.0' end diff --git a/touchlocal-openx.gemspec b/touchlocal-openx.gemspec new file mode 100644 index 0000000..2a4ce82 --- /dev/null +++ b/touchlocal-openx.gemspec @@ -0,0 +1,77 @@ +# Generated by jeweler +# DO NOT EDIT THIS FILE DIRECTLY +# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{touchlocal-openx} + s.version = "1.1.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc"] + s.date = %q{2009-10-26} + s.description = %q{A Ruby interface to the OpenX XML-RPC API} + s.email = %q{info@touchlocal.com} + s.extra_rdoc_files = [ + "README.txt" + ] + s.files = [ + ".gitignore", + "History.txt", + "Manifest.txt", + "README.txt", + "Rakefile", + "VERSION", + "lib/openx.rb", + "lib/openx/image.rb", + "lib/openx/invocation.rb", + "lib/openx/services.rb", + "lib/openx/services/advertiser.rb", + "lib/openx/services/agency.rb", + "lib/openx/services/banner.rb", + "lib/openx/services/base.rb", + "lib/openx/services/campaign.rb", + "lib/openx/services/publisher.rb", + "lib/openx/services/session.rb", + "lib/openx/services/zone.rb", + "lib/openx/xmlrpc_client.rb", + "test/assets/300x250.jpg", + "test/assets/cat.swf", + "test/helper.rb", + "test/test_advertiser.rb", + "test/test_agency.rb", + "test/test_banner.rb", + "test/test_base.rb", + "test/test_campaign.rb", + "test/test_publisher.rb", + "test/test_session.rb", + "test/test_zone.rb" + ] + s.homepage = %q{http://github.com/touchlocal/openx} + s.rdoc_options = ["--charset=UTF-8"] + s.require_paths = ["lib"] + s.rubygems_version = %q{1.3.5} + s.summary = %q{A Ruby interface to the OpenX XML-RPC API} + s.test_files = [ + "test/helper.rb", + "test/test_advertiser.rb", + "test/test_agency.rb", + "test/test_banner.rb", + "test/test_base.rb", + "test/test_campaign.rb", + "test/test_publisher.rb", + "test/test_session.rb", + "test/test_zone.rb" + ] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end + From 0d8a9803a4fd3f354335f056a2a89a9b83cbd585 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Mon, 26 Oct 2009 15:38:33 +1000 Subject: [PATCH 13/36] Readme for deployed gem --- README.txt | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/README.txt b/README.txt index e19fa62..617afac 100644 --- a/README.txt +++ b/README.txt @@ -54,6 +54,31 @@ The YAML file lists configuration for each environment. The gem uses the 'invocation_url' is only used by the OpenX::Invocation methods to serve advertisements over XML-RPC +== RUBY ON RAILS INTEGRATION + +As common deployment scenarios for RoR projects dictates that you manage all +of your dependent files from within your project, storing your credentials.yml +file in the default location (as above) will not work. However, this is easily +fixed. + +Create your credentials.yml file in your ./config folder, and populate it with +the necessary environment settings. It may in fact be more useful to name your +file something like openx_credentials.yml to be explicit about the content. + +Then, add your gem require line to the initialize block of the environment.rb: + + config.gem "touchlocal-openx", + :lib => "openx", :source => "http://gemcutter.org" + +You will of course need to install the gem, either manually or via +rake gems:install + +Finally, create a config/initializers/openx.rb and include the following line: + + OpenX::Services::Base.configuration = + YAML.load_file(File.join(Rails.root, 'config', 'credentials.yml'))[Rails.env] + + == LICENSE: (The MIT License) @@ -62,7 +87,7 @@ Copyright (c) 2008: * {Aaron Patterson}[http://tenderlovemaking.com] * Andy Smith -* {TouchLocal P/L}[http://www.touchlocal.com] +* {TouchLocal Plc}[http://www.touchlocal.com] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From 169909f5acc822ca405c4a0c976a6fc8e347f12b Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Fri, 6 Nov 2009 11:24:28 +1000 Subject: [PATCH 14/36] Enviroment variable handling for non-*nix and non-standard environments --- lib/openx/services/base.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/openx/services/base.rb b/lib/openx/services/base.rb index e0bad2d..9aef08f 100644 --- a/lib/openx/services/base.rb +++ b/lib/openx/services/base.rb @@ -5,7 +5,15 @@ module Services class Base include Comparable - CONFIGURATION_YAML = File.join(ENV['HOME'], '.openx', 'credentials.yml') + # HOME || HOMEPATH is for Win32 users who do not have HOME set by default + # + # Configuration can be overridden for Rails at load time by doing this: + # OpenX::Services::Base.configuration = + # YAML.load_file(File.join(Rails.root, 'config', 'credentials.yml'))[Rails.env] + # + # Rescue nil is there for Rails sites that are monitored by Monit, + # which does not set the environment variables as expected + CONFIGURATION_YAML = File.join((ENV['HOME'] || ENV['HOMEPATH']), '.openx', 'credentials.yml') rescue nil @@connection = nil @@configuration = nil From 02ef5f7ac888800070c5656044edb7f1c356f7e9 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Fri, 6 Nov 2009 11:24:45 +1000 Subject: [PATCH 15/36] Version bump to 1.1.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 9084fa2..524cb55 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.1.1 From 8c274561737d2f6df27f5803b7cf4c9eb214e4ec Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Fri, 6 Nov 2009 11:37:42 +1000 Subject: [PATCH 16/36] Update gemspec --- touchlocal-openx.gemspec | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/touchlocal-openx.gemspec b/touchlocal-openx.gemspec index 2a4ce82..b07a535 100644 --- a/touchlocal-openx.gemspec +++ b/touchlocal-openx.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = %q{touchlocal-openx} - s.version = "1.1.0" + s.version = "1.1.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc"] - s.date = %q{2009-10-26} + s.date = %q{2009-11-06} s.description = %q{A Ruby interface to the OpenX XML-RPC API} s.email = %q{info@touchlocal.com} s.extra_rdoc_files = [ @@ -45,7 +45,8 @@ Gem::Specification.new do |s| "test/test_campaign.rb", "test/test_publisher.rb", "test/test_session.rb", - "test/test_zone.rb" + "test/test_zone.rb", + "touchlocal-openx.gemspec" ] s.homepage = %q{http://github.com/touchlocal/openx} s.rdoc_options = ["--charset=UTF-8"] From d5b31cd35a943b2659f484fa67ff7429a47977ec Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Thu, 19 Nov 2009 11:37:54 +1000 Subject: [PATCH 17/36] Correct formatting of README --- README.txt => README.rdoc | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README.txt => README.rdoc (100%) diff --git a/README.txt b/README.rdoc similarity index 100% rename from README.txt rename to README.rdoc From 7b860ea9b63550482a01560c26e38741102bae80 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Thu, 19 Nov 2009 11:45:38 +1000 Subject: [PATCH 18/36] Documentation update --- README.rdoc | 22 ++++++++++++---------- lib/openx/services/base.rb | 4 +++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.rdoc b/README.rdoc index 617afac..17fc8ec 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,12 +1,13 @@ -= openx += OpenX -* http://openx.rubyforge.org +* http://gemcutter.org/gems/touchlocal-openx +* http://github.com/touchlocal/openx -== DESCRIPTION: +== Description A Ruby interface to the OpenX XML-RPC API. -== SYNOPSIS: +== Synopsis OpenX::Services::Base.configuration = { 'username' => 'admin', @@ -26,18 +27,18 @@ A Ruby interface to the OpenX XML-RPC API. Publisher.create!( :agency => agency, :name => 'My Test Publisher', - :contact_name => 'Aaron Patterson', - :email => 'aaron@tenderlovemaking.com', + :contact_name => 'My Contact', + :email => 'agency@example.com', :username => 'user', :password => 'password' ) end -== REQUIREMENTS: +== Requirements * ruby -== INSTALL: +== Install * sudo gem install openx * Update your $HOME/.openx/credentials.yml file. Here is a sample: @@ -54,7 +55,7 @@ The YAML file lists configuration for each environment. The gem uses the 'invocation_url' is only used by the OpenX::Invocation methods to serve advertisements over XML-RPC -== RUBY ON RAILS INTEGRATION +== Ruby on Rails Integration As common deployment scenarios for RoR projects dictates that you manage all of your dependent files from within your project, storing your credentials.yml @@ -73,8 +74,9 @@ Then, add your gem require line to the initialize block of the environment.rb: You will of course need to install the gem, either manually or via rake gems:install -Finally, create a config/initializers/openx.rb and include the following line: +Finally, create a config/initializers/openx.rb and include the following: + require 'yaml' OpenX::Services::Base.configuration = YAML.load_file(File.join(Rails.root, 'config', 'credentials.yml'))[Rails.env] diff --git a/lib/openx/services/base.rb b/lib/openx/services/base.rb index 9aef08f..56db799 100644 --- a/lib/openx/services/base.rb +++ b/lib/openx/services/base.rb @@ -12,7 +12,9 @@ class Base # YAML.load_file(File.join(Rails.root, 'config', 'credentials.yml'))[Rails.env] # # Rescue nil is there for Rails sites that are monitored by Monit, - # which does not set the environment variables as expected + # which does not set the environment variables as expected. + # Note that the configuration can be set explicitly (as above), + # in which case this constant is not used and can safely be nil. CONFIGURATION_YAML = File.join((ENV['HOME'] || ENV['HOMEPATH']), '.openx', 'credentials.yml') rescue nil @@connection = nil From 4f17005d3d530b2557d711204c489786c874e931 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Thu, 19 Nov 2009 11:46:31 +1000 Subject: [PATCH 19/36] Documentation update --- README.rdoc | 1 - 1 file changed, 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 17fc8ec..67f8b58 100644 --- a/README.rdoc +++ b/README.rdoc @@ -43,7 +43,6 @@ A Ruby interface to the OpenX XML-RPC API. * sudo gem install openx * Update your $HOME/.openx/credentials.yml file. Here is a sample: - --- production: username: admin password: admin From 517225bdfe869afa7edc327be56e1ec1b7531ca7 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Thu, 19 Nov 2009 11:47:31 +1000 Subject: [PATCH 20/36] Documentation update --- README.rdoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.rdoc b/README.rdoc index 67f8b58..f3c636a 100644 --- a/README.rdoc +++ b/README.rdoc @@ -43,11 +43,11 @@ A Ruby interface to the OpenX XML-RPC API. * sudo gem install openx * Update your $HOME/.openx/credentials.yml file. Here is a sample: - production: - username: admin - password: admin - url: http://www.example.com/www/api/v2/xmlrpc/ - invocation_url: http://www.example.com/www/delivery/axmlrpc.php + production: + username: admin + password: admin + url: http://www.example.com/www/api/v2/xmlrpc/ + invocation_url: http://www.example.com/www/delivery/axmlrpc.php The YAML file lists configuration for each environment. The gem uses the 'production' environment by default. Trailing slash is required on the 'url'. From 66876ed3aff03b7b14628faf97a4bb80edffdc7c Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Thu, 19 Nov 2009 11:49:56 +1000 Subject: [PATCH 21/36] Documentation update --- README.rdoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index f3c636a..c9370b0 100644 --- a/README.rdoc +++ b/README.rdoc @@ -40,7 +40,8 @@ A Ruby interface to the OpenX XML-RPC API. == Install -* sudo gem install openx +* sudo gem install touchlocal-openx --source "http://gemcutter.org" +* add "require 'openx'" to your code * Update your $HOME/.openx/credentials.yml file. Here is a sample: production: From 95c3acb915ae7ba548951fde164a6b8296cfce0b Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Thu, 19 Nov 2009 12:54:04 +1000 Subject: [PATCH 22/36] Add documentation and patch for enabling Banner Keyword access via API --- README.rdoc | 30 +++++++++- lib/openx/invocation.rb | 1 + php/openx-2.8.1-keywords.diff | 110 ++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 php/openx-2.8.1-keywords.diff diff --git a/README.rdoc b/README.rdoc index c9370b0..d98de41 100644 --- a/README.rdoc +++ b/README.rdoc @@ -81,7 +81,35 @@ Finally, create a config/initializers/openx.rb and include the following: YAML.load_file(File.join(Rails.root, 'config', 'credentials.yml'))[Rails.env] -== LICENSE: +== Banner Keyword Support + +Not all attributes of OpenX objects that can be set in the web interface are +accessible via the API. A notable case of this is the ability to access +Banner Keywords. While it seems to be a case of "We'll add them as people +need them," this process is slower that one might expect; +https://developer.openx.org/jira/browse/OX-4779 has been an open ticket since +January 2009. + +As TouchLocal required the ability to access Banner Keywords, the +OpenX::Services::Banner object has the support for this attribute. If the +server does not support the attribute, then setting it will have no effect, +and it will return nil when retrieving it. To enable support on the server, +you will need access to the server source, and the included +php/openx-2.8.1-keywords.diff + +Copy the openx-2.8.1-keywords.diff file to the root of the OpenX distribution +on your server, and execute: + + patch -p0 < openx-2.8.1-keywords.diff + +This will patch the relevant OpenX API to allow access to the keyword +attribute, meaning that now both your client and server support it. Happy days. + +This patch has been tested on OpenX Server versions 2.8.1 and 2.8.2 at the +time of writing. + + +== License (The MIT License) diff --git a/lib/openx/invocation.rb b/lib/openx/invocation.rb index 3a96e57..9340b80 100644 --- a/lib/openx/invocation.rb +++ b/lib/openx/invocation.rb @@ -25,6 +25,7 @@ def view(what, params = {}) url = OpenX::Services::Base.configuration['invocation_url'] + # Basic requirement as per /lib/max/Delivery/XML-RPC.php in OpenX settings = {:cookies => [], :remote_addr => 'localhost'} context = [] # used by reference after initial use diff --git a/php/openx-2.8.1-keywords.diff b/php/openx-2.8.1-keywords.diff new file mode 100644 index 0000000..823dfce --- /dev/null +++ b/php/openx-2.8.1-keywords.diff @@ -0,0 +1,110 @@ +Index: www/api/v2/xmlrpc/BannerXmlRpcService.php +=================================================================== +--- www/api/v2/xmlrpc/BannerXmlRpcService.php (revision 44144) ++++ www/api/v2/xmlrpc/BannerXmlRpcService.php (working copy) +@@ -86,7 +86,7 @@ + 1, array('campaignId', 'bannerName', 'storageType', 'fileName', + 'imageURL', 'htmlTemplate', 'width', 'height', 'weight', + 'target', 'url', 'bannerText', 'status', 'adserver', 'transparent', +- 'capping', 'sessionCapping', 'block', 'comments'), ++ 'capping', 'sessionCapping', 'block', 'comments', 'keyword'), + array('aImage', 'aBackupImage'), $oResponseWithError)) { + + return $oResponseWithError; +@@ -121,7 +121,7 @@ + 1, array('bannerId', 'campaignId', 'bannerName', 'storageType', 'fileName', + 'imageURL', 'htmlTemplate', 'width', 'height', 'weight', + 'target', 'url', 'bannerText', 'status', 'adserver', 'transparent', +- 'capping', 'sessionCapping', 'block', 'comments'), ++ 'capping', 'sessionCapping', 'block', 'comments', 'keyword'), + array('aImage', 'aBackupImage'), $oResponseWithError)) { + + return $oResponseWithError; +Index: lib/OA/Dll/Banner.php +=================================================================== +--- lib/OA/Dll/Banner.php (revision 44144) ++++ lib/OA/Dll/Banner.php (working copy) +@@ -203,7 +203,8 @@ + !$this->checkStructureNotRequiredIntegerField($oBanner, 'capping') || + !$this->checkStructureNotRequiredIntegerField($oBanner, 'sessionCapping') || + !$this->checkStructureNotRequiredIntegerField($oBanner, 'block') || +- !$this->checkStructureNotRequiredStringField($oBanner, 'comments') ++ !$this->checkStructureNotRequiredStringField($oBanner, 'comments') || ++ !$this->checkStructureNotRequiredStringField($oBanner, 'keyword') + ) { + return false; + } +Index: lib/OA/Dll/BannerInfo.php +=================================================================== +--- lib/OA/Dll/BannerInfo.php (revision 44144) ++++ lib/OA/Dll/BannerInfo.php (working copy) +@@ -210,6 +210,13 @@ + var $comments; + + /** ++ * This field provides keywords to be stored. ++ * ++ * @var string $keyword ++ */ ++ var $keyword; ++ ++ /** + * This method sets all default values when adding a new banner. + * + * @access public +@@ -251,6 +258,10 @@ + if (is_null($this->block)) { + // Leave null + } ++ ++ if (is_null($this->keyword)) { ++ // Leave null ++ } + } + + function encodeImage($aImage) +@@ -305,6 +316,7 @@ + 'aImage' => 'custom', + 'aBackupImage' => 'custom', + 'comments' => 'string', ++ 'keyword' => 'string', + ); + } + } +Index: lib/xmlrpc/php/BannerInfo.php +=================================================================== +--- lib/xmlrpc/php/BannerInfo.php (revision 44144) ++++ lib/xmlrpc/php/BannerInfo.php (working copy) +@@ -210,6 +210,13 @@ + var $comments; + + /** ++ * This field provides keywords to be stored. ++ * ++ * @var string $keyword ++ */ ++ var $keyword; ++ ++ /** + * This method sets all default values when adding a new banner. + * + * @access public +@@ -251,6 +258,10 @@ + if (is_null($this->block)) { + // Leave null + } ++ ++ if (is_null($this->keyword)) { ++ // Leave null ++ } + } + + function encodeImage($aImage) +@@ -305,6 +316,7 @@ + 'aImage' => 'custom', + 'aBackupImage' => 'custom', + 'comments' => 'string', ++ 'keyword' => 'string', + ); + } + } From a88468a599c234b724189f113e36bb01abf45d32 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Thu, 19 Nov 2009 12:59:06 +1000 Subject: [PATCH 23/36] Add documentation and patch for enabling Banner Keyword access via API --- README.rdoc | 2 +- lib/openx/services/banner.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rdoc b/README.rdoc index d98de41..5dd941b 100644 --- a/README.rdoc +++ b/README.rdoc @@ -86,7 +86,7 @@ Finally, create a config/initializers/openx.rb and include the following: Not all attributes of OpenX objects that can be set in the web interface are accessible via the API. A notable case of this is the ability to access Banner Keywords. While it seems to be a case of "We'll add them as people -need them," this process is slower that one might expect; +need them," this process is slower than one might expect; https://developer.openx.org/jira/browse/OX-4779 has been an open ticket since January 2009. diff --git a/lib/openx/services/banner.rb b/lib/openx/services/banner.rb index baa0d47..ca2b275 100644 --- a/lib/openx/services/banner.rb +++ b/lib/openx/services/banner.rb @@ -59,7 +59,7 @@ def find(id, *args) :image => :aImage, :backup_image => :aBackupImage, # 'keyword' only supported by patched server - # as per https://developer.openx.org/jira/browse/OX-4779 + # as per README.rdoc # No averse effect when unsupported by server (returns nil) :keyword => :keyword From 244592733de8a50dee9654ece5c4016c076f2556 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Thu, 19 Nov 2009 13:06:01 +1000 Subject: [PATCH 24/36] Update History --- History.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/History.txt b/History.txt index 103a7a6..2047fb1 100644 --- a/History.txt +++ b/History.txt @@ -4,3 +4,17 @@ * Birthday! +=== 1.1.0 / 2009-10-26 + +* 2 major enhancements + + * OpenX API Version 2 Support added + * OpenX Invocation API Support added + +* 1 minor enhancement + + * Ruby on Rails documentation support added + +=== 1.1.1 / 2009-11-06 + +* Minor bugfix to environment handling for Win32 users From 869c0b3f6e6dbad6b86c04b0389456e52df149a3 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Thu, 19 Nov 2009 13:07:12 +1000 Subject: [PATCH 25/36] Update gemspec to include new readme and patch files --- touchlocal-openx.gemspec | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/touchlocal-openx.gemspec b/touchlocal-openx.gemspec index b07a535..79b09ce 100644 --- a/touchlocal-openx.gemspec +++ b/touchlocal-openx.gemspec @@ -9,17 +9,17 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc"] - s.date = %q{2009-11-06} + s.date = %q{2009-11-19} s.description = %q{A Ruby interface to the OpenX XML-RPC API} s.email = %q{info@touchlocal.com} s.extra_rdoc_files = [ - "README.txt" + "README.rdoc" ] s.files = [ ".gitignore", "History.txt", "Manifest.txt", - "README.txt", + "README.rdoc", "Rakefile", "VERSION", "lib/openx.rb", @@ -35,6 +35,7 @@ Gem::Specification.new do |s| "lib/openx/services/session.rb", "lib/openx/services/zone.rb", "lib/openx/xmlrpc_client.rb", + "php/openx-2.8.1-keywords.diff", "test/assets/300x250.jpg", "test/assets/cat.swf", "test/helper.rb", From bb464102bc46d3a5da46369af89435f8532c52f9 Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Thu, 19 Nov 2009 13:08:52 +1000 Subject: [PATCH 26/36] Version bump to 1.1.2 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 524cb55..45a1b3f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.1 +1.1.2 From e7a38f8f068e9b176a5f11f6e5ea80d19b3cc0cf Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Thu, 19 Nov 2009 13:09:17 +1000 Subject: [PATCH 27/36] Update gemspec for new version --- touchlocal-openx.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/touchlocal-openx.gemspec b/touchlocal-openx.gemspec index 79b09ce..3fcfaf6 100644 --- a/touchlocal-openx.gemspec +++ b/touchlocal-openx.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = %q{touchlocal-openx} - s.version = "1.1.1" + s.version = "1.1.2" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc"] From 3f4a6d16eb8de04b1dffc432aa75e00235843cfc Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Thu, 19 Nov 2009 13:10:32 +1000 Subject: [PATCH 28/36] Update history for new version --- History.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History.txt b/History.txt index 2047fb1..e800831 100644 --- a/History.txt +++ b/History.txt @@ -18,3 +18,7 @@ === 1.1.1 / 2009-11-06 * Minor bugfix to environment handling for Win32 users + +=== 1.1.2 / 2009-11-19 + +* Documentation updates and patch to enable banner support on the OpenX Server From fe3845543f2c71c19324536e2553c055d4d8da7d Mon Sep 17 00:00:00 2001 From: Dan Sketcher Date: Tue, 24 Nov 2009 11:54:46 +1000 Subject: [PATCH 29/36] Update copyright notice --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 5dd941b..217ba3d 100644 --- a/README.rdoc +++ b/README.rdoc @@ -117,7 +117,7 @@ Copyright (c) 2008: * {Aaron Patterson}[http://tenderlovemaking.com] * Andy Smith -* {TouchLocal Plc}[http://www.touchlocal.com] +* {TouchLocal Ltd}[http://www.touchlocal.com] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From c459b80ec895eb9de1510e256b568567f5c31e34 Mon Sep 17 00:00:00 2001 From: DoppioJP Date: Sun, 18 Apr 2010 09:10:47 -0700 Subject: [PATCH 30/36] Added methods publisher_statistics and zone_statistics. Changed statistics method to daily_statistics to stick to the OpenX API naming conventions. Kept statistics method as an alias for daily_statistics. --- lib/openx/services/banner.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/openx/services/banner.rb b/lib/openx/services/banner.rb index ca2b275..37e607d 100644 --- a/lib/openx/services/banner.rb +++ b/lib/openx/services/banner.rb @@ -77,10 +77,33 @@ def initialize(params = {}) super(params) end + # Alias for daily_statistics method to keep consistency with OpenX API calls + # Originally it was call for ox.bannerDailyStatistics so it is kept for compatibility with the previous version def statistics start_on = Date.today, end_on = Date.today + daily_statistics start_on, end_on + end + + # Returns statistics in Array of Hashes by day, which are: impressions, clicks, requests and revenue. + # Each day is represented by XMLRPC::DateTime which has instant variables: + # @year, @month, @day, @hour, @min, @sec + def daily_statistics start_on = Date.today, end_on = Date.today session = self.class.connection @server.call('ox.bannerDailyStatistics', session, self.id, start_on, end_on) end + + # Returns statistics in Array of Hashes by publisher, which are: impression, clicks, requests and revenue. + # Also returns publisherName and publisherId + def publisher_statistics start_on = Date.today, end_on = Date.today + session = self.class.connection + @server.call('ox.bannerPublisherStatistics', session, self.id, start_on, end_on) + end + + # Returns statistics in Array of Hashes by zone, which are: impression, clicks, requests, conversions and revenue. + # Also returns publisherName, publisherId, zoneName, zoneId + def zone_statistics start_on = Date.today, end_on = Date.today + session = self.class.connection + @server.call('ox.bannerZoneStatistics', session, self.id, start_on, end_on) + end def targeting session = self.class.connection From 804e2d7b588c18dc7dd64979e87005810696cf51 Mon Sep 17 00:00:00 2001 From: Jakub Date: Sun, 18 Apr 2010 17:58:46 +0100 Subject: [PATCH 31/36] changed touchlocal-openx.gemspec into jjp-openx.gemspec --- Rakefile | 8 ++-- VERSION | 2 +- touchlocal-openx.gemspec | 79 ---------------------------------------- 3 files changed, 5 insertions(+), 84 deletions(-) delete mode 100644 touchlocal-openx.gemspec diff --git a/Rakefile b/Rakefile index ad25542..aab69c0 100644 --- a/Rakefile +++ b/Rakefile @@ -6,12 +6,12 @@ require 'rake' begin require 'jeweler' Jeweler::Tasks.new do |gemspec| - gemspec.name = "touchlocal-openx" + gemspec.name = "jjp-openx" gemspec.summary = "A Ruby interface to the OpenX XML-RPC API" gemspec.description = "A Ruby interface to the OpenX XML-RPC API" - gemspec.email = "info@touchlocal.com" - gemspec.homepage = "http://github.com/touchlocal/openx" - gemspec.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc"] + gemspec.email = "jacobjp@mac.com" + gemspec.homepage = "http://github.com/DoppioJP/openx" + gemspec.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc", "DoppioJP"] end Jeweler::GemcutterTasks.new rescue LoadError diff --git a/VERSION b/VERSION index 45a1b3f..781dcb0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.2 +1.1.3 diff --git a/touchlocal-openx.gemspec b/touchlocal-openx.gemspec deleted file mode 100644 index 3fcfaf6..0000000 --- a/touchlocal-openx.gemspec +++ /dev/null @@ -1,79 +0,0 @@ -# Generated by jeweler -# DO NOT EDIT THIS FILE DIRECTLY -# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{touchlocal-openx} - s.version = "1.1.2" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc"] - s.date = %q{2009-11-19} - s.description = %q{A Ruby interface to the OpenX XML-RPC API} - s.email = %q{info@touchlocal.com} - s.extra_rdoc_files = [ - "README.rdoc" - ] - s.files = [ - ".gitignore", - "History.txt", - "Manifest.txt", - "README.rdoc", - "Rakefile", - "VERSION", - "lib/openx.rb", - "lib/openx/image.rb", - "lib/openx/invocation.rb", - "lib/openx/services.rb", - "lib/openx/services/advertiser.rb", - "lib/openx/services/agency.rb", - "lib/openx/services/banner.rb", - "lib/openx/services/base.rb", - "lib/openx/services/campaign.rb", - "lib/openx/services/publisher.rb", - "lib/openx/services/session.rb", - "lib/openx/services/zone.rb", - "lib/openx/xmlrpc_client.rb", - "php/openx-2.8.1-keywords.diff", - "test/assets/300x250.jpg", - "test/assets/cat.swf", - "test/helper.rb", - "test/test_advertiser.rb", - "test/test_agency.rb", - "test/test_banner.rb", - "test/test_base.rb", - "test/test_campaign.rb", - "test/test_publisher.rb", - "test/test_session.rb", - "test/test_zone.rb", - "touchlocal-openx.gemspec" - ] - s.homepage = %q{http://github.com/touchlocal/openx} - s.rdoc_options = ["--charset=UTF-8"] - s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.5} - s.summary = %q{A Ruby interface to the OpenX XML-RPC API} - s.test_files = [ - "test/helper.rb", - "test/test_advertiser.rb", - "test/test_agency.rb", - "test/test_banner.rb", - "test/test_base.rb", - "test/test_campaign.rb", - "test/test_publisher.rb", - "test/test_session.rb", - "test/test_zone.rb" - ] - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 3 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - else - end - else - end -end - From 72e0ed772b6caa8ed9c657db83a92da9b40a63cd Mon Sep 17 00:00:00 2001 From: Jakub Date: Sun, 18 Apr 2010 18:06:42 +0100 Subject: [PATCH 32/36] added jjp-openx.gemspec --- jjp-openx.gemspec | 78 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 jjp-openx.gemspec diff --git a/jjp-openx.gemspec b/jjp-openx.gemspec new file mode 100644 index 0000000..aa95f0f --- /dev/null +++ b/jjp-openx.gemspec @@ -0,0 +1,78 @@ +# Generated by jeweler +# DO NOT EDIT THIS FILE +# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec` +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{jjp-openx} + s.version = "1.1.3" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc", "DoppioJP"] + s.date = %q{2010-04-18} + s.description = %q{A Ruby interface to the OpenX XML-RPC API} + s.email = %q{jacobjp@mac.com} + s.extra_rdoc_files = [ + "README.rdoc" + ] + s.files = [ + ".gitignore", + "History.txt", + "Manifest.txt", + "README.rdoc", + "Rakefile", + "VERSION", + "lib/openx.rb", + "lib/openx/image.rb", + "lib/openx/invocation.rb", + "lib/openx/services.rb", + "lib/openx/services/advertiser.rb", + "lib/openx/services/agency.rb", + "lib/openx/services/banner.rb", + "lib/openx/services/base.rb", + "lib/openx/services/campaign.rb", + "lib/openx/services/publisher.rb", + "lib/openx/services/session.rb", + "lib/openx/services/zone.rb", + "lib/openx/xmlrpc_client.rb", + "php/openx-2.8.1-keywords.diff", + "test/assets/300x250.jpg", + "test/assets/cat.swf", + "test/helper.rb", + "test/test_advertiser.rb", + "test/test_agency.rb", + "test/test_banner.rb", + "test/test_base.rb", + "test/test_campaign.rb", + "test/test_publisher.rb", + "test/test_session.rb", + "test/test_zone.rb", + "touchlocal-openx.gemspec" + ] + s.homepage = %q{http://github.com/DoppioJP/openx} + s.rdoc_options = ["--charset=UTF-8"] + s.require_paths = ["lib"] + s.rubygems_version = %q{1.3.6} + s.summary = %q{A Ruby interface to the OpenX XML-RPC API} + s.test_files = [ + "test/helper.rb", + "test/test_advertiser.rb", + "test/test_agency.rb", + "test/test_banner.rb", + "test/test_base.rb", + "test/test_campaign.rb", + "test/test_publisher.rb", + "test/test_session.rb", + "test/test_zone.rb" + ] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end From 6b437cecdb4faea13196133d5e43dd4b654e3987 Mon Sep 17 00:00:00 2001 From: Jakub Date: Sun, 18 Apr 2010 18:31:49 +0100 Subject: [PATCH 33/36] Some doc changed, settings to push gem in version 1.1.4 to RubyGems.org --- README.rdoc | 6 +++--- Rakefile | 4 ++-- VERSION | 2 +- jjp-openx.gemspec | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.rdoc b/README.rdoc index 217ba3d..68a870e 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,11 +1,11 @@ = OpenX -* http://gemcutter.org/gems/touchlocal-openx -* http://github.com/touchlocal/openx +* http://rubygems.org/gems/jjp-openx +* http://github.com/DoppioJP/openx == Description -A Ruby interface to the OpenX XML-RPC API. +A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/ == Synopsis diff --git a/Rakefile b/Rakefile index aab69c0..2d0f7e1 100644 --- a/Rakefile +++ b/Rakefile @@ -7,8 +7,8 @@ begin require 'jeweler' Jeweler::Tasks.new do |gemspec| gemspec.name = "jjp-openx" - gemspec.summary = "A Ruby interface to the OpenX XML-RPC API" - gemspec.description = "A Ruby interface to the OpenX XML-RPC API" + gemspec.summary = "A Ruby interface to the OpenX XML-RPC API with more OpenX APIs used" + gemspec.description = "A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/" gemspec.email = "jacobjp@mac.com" gemspec.homepage = "http://github.com/DoppioJP/openx" gemspec.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc", "DoppioJP"] diff --git a/VERSION b/VERSION index 781dcb0..65087b4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.3 +1.1.4 diff --git a/jjp-openx.gemspec b/jjp-openx.gemspec index aa95f0f..68a8d68 100644 --- a/jjp-openx.gemspec +++ b/jjp-openx.gemspec @@ -5,12 +5,12 @@ Gem::Specification.new do |s| s.name = %q{jjp-openx} - s.version = "1.1.3" + s.version = "1.1.4" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc", "DoppioJP"] s.date = %q{2010-04-18} - s.description = %q{A Ruby interface to the OpenX XML-RPC API} + s.description = %q{A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/} s.email = %q{jacobjp@mac.com} s.extra_rdoc_files = [ "README.rdoc" @@ -22,6 +22,7 @@ Gem::Specification.new do |s| "README.rdoc", "Rakefile", "VERSION", + "jjp-openx.gemspec", "lib/openx.rb", "lib/openx/image.rb", "lib/openx/invocation.rb", @@ -46,14 +47,13 @@ Gem::Specification.new do |s| "test/test_campaign.rb", "test/test_publisher.rb", "test/test_session.rb", - "test/test_zone.rb", - "touchlocal-openx.gemspec" + "test/test_zone.rb" ] s.homepage = %q{http://github.com/DoppioJP/openx} s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] s.rubygems_version = %q{1.3.6} - s.summary = %q{A Ruby interface to the OpenX XML-RPC API} + s.summary = %q{A Ruby interface to the OpenX XML-RPC API with more OpenX APIs used} s.test_files = [ "test/helper.rb", "test/test_advertiser.rb", From 37e9d6a8a15ceaf3071624ff07827eb07e29fbf3 Mon Sep 17 00:00:00 2001 From: DoppioJP Date: Wed, 19 May 2010 11:40:25 +0100 Subject: [PATCH 34/36] v 1.1.5 - localTZ for v2 of OpenX API added with respect of v1 not using that parameter. Added daily_statistics and banner_statistics for Publisher. --- lib/openx/services/statistics.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/openx/services/statistics.rb diff --git a/lib/openx/services/statistics.rb b/lib/openx/services/statistics.rb new file mode 100644 index 0000000..f003e1c --- /dev/null +++ b/lib/openx/services/statistics.rb @@ -0,0 +1,25 @@ +module OpenX + module Services + module Statistics + + # Generic method to get statistics. + # - +service_method+ - The name of the OpenX API service method to be called. + # - +start_on+ - When date range starts for stats request. OpenX parameter +oStartDate+ which ignores time part of it. + # - +end_on+ - When date range ends for stats request. OpenX parameter +oEndDate+ which ignores time part of it. + # - +local_time_zone+ - For v2 of OpenX API only which will respect the local Time Zone. OpenX parameter +localTZ+. + # + # With such generic method the gem is able to get any statistics available from the OpenX API, + # because all those statistics methods have the same call format. + def get_statistics service_method, start_on = Date.today, end_on = Date.today, local_time_zone = true + session = self.class.connection + + # For compatibility with v1 of OpenX API. + if OpenX::Services::Base.configuration["url"].include?("/v1/") + @server.call(service_method, session, self.id, start_on, end_on) + else + @server.call(service_method, session, self.id, start_on, end_on, local_time_zone) + end + end + end + end +end \ No newline at end of file From 570a6b5e70ea66016a912f65391e30e1f8eecd41 Mon Sep 17 00:00:00 2001 From: DoppioJP Date: Wed, 19 May 2010 12:15:28 +0100 Subject: [PATCH 35/36] v 1.1.6 --- History.txt | 43 ++++++++++++++++++++++++++++++++ README.rdoc | 2 +- Rakefile | 2 +- VERSION | 2 +- jjp-openx.gemspec | 7 +++--- lib/openx/invocation.rb | 23 +++++++++++++---- lib/openx/services/advertiser.rb | 4 +++ lib/openx/services/agency.rb | 4 +++ lib/openx/services/banner.rb | 31 ++++++++++++----------- lib/openx/services/campaign.rb | 8 +++++- lib/openx/services/publisher.rb | 16 ++++++++++++ lib/openx/services/zone.rb | 4 +++ 12 files changed, 119 insertions(+), 27 deletions(-) diff --git a/History.txt b/History.txt index e800831..26b461c 100644 --- a/History.txt +++ b/History.txt @@ -22,3 +22,46 @@ === 1.1.2 / 2009-11-19 * Documentation updates and patch to enable banner support on the OpenX Server + +=== 1.1.4 / 2010-04-17 + +* Fork of 1.1.2 + + * Added statistic methods for Banner: + + * renamed statistics method into daily_statistics, left statistics method as an alias for daily_statistics + * daily_statistics(start_on = Date.today, end_on = Date.today) - Daily stats for the Banner + * publisher_statistics(start_on = Date.today, end_on = Date.today) - Banner stats by Publisher + * zone_statistics(start_on = Date.today, end_on = Date.today) - Banner stats by Zone + +=== 1.1.5 / 2010-05-18 + +* Created generic statistics method: + + * get_statistics(service_method, start_on = Date.today, end_on = Date.today, local_time_zone = true) in sepearate module OpenX::Services::Statistics in file statistics.rb + * included statistics module in all stats objects: Agency, Advertiser, Campaign, Banner, Publisher, Zone. + * all existing statistics methods are now calling get_statistics. + +* Added to statistics methods localTZ parameter default to true. This way OpenX will return stats for the period of time with offset according to the local time zone. If that parameter is false it will give numbers for UTC. The localTZ implementation based only on that post http://forum.openx.org/index.php?s=18f1d84f86e32297083f87f8d9eb4fda&showtopic=503433151 + + * statistics + * daily_statistics + * publisher_statistics + * zone_statistics + +* Added statistics methods for other objects as well + + * Agency + * Advertiser + * Campaign + * Banner + * Publisher + + * daily_statistics + * banner_statistics + + * Zone + +=== 1.1.6 / 2010-05-18 + +* lib/openx/services/statistic.rb file was missing on github while building gemspec, so the version 1.1.5 is actually broken. \ No newline at end of file diff --git a/README.rdoc b/README.rdoc index 68a870e..4444dac 100644 --- a/README.rdoc +++ b/README.rdoc @@ -5,7 +5,7 @@ == Description -A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/ +A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/ . It also works with v2 of OpenX API, especially that it now can pass localTZ to the OpenX API which will give back the correct statistics for the local time zone. == Synopsis diff --git a/Rakefile b/Rakefile index 2d0f7e1..475d93c 100644 --- a/Rakefile +++ b/Rakefile @@ -8,7 +8,7 @@ begin Jeweler::Tasks.new do |gemspec| gemspec.name = "jjp-openx" gemspec.summary = "A Ruby interface to the OpenX XML-RPC API with more OpenX APIs used" - gemspec.description = "A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/" + gemspec.description = "A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/ . It also works with v2 of OpenX API, especially that it now can pass localTZ to the OpenX API which will give back the correct statistics for the local time zone." gemspec.email = "jacobjp@mac.com" gemspec.homepage = "http://github.com/DoppioJP/openx" gemspec.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc", "DoppioJP"] diff --git a/VERSION b/VERSION index 65087b4..0664a8f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.4 +1.1.6 diff --git a/jjp-openx.gemspec b/jjp-openx.gemspec index 68a8d68..dd9f99d 100644 --- a/jjp-openx.gemspec +++ b/jjp-openx.gemspec @@ -5,12 +5,12 @@ Gem::Specification.new do |s| s.name = %q{jjp-openx} - s.version = "1.1.4" + s.version = "1.1.5" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc", "DoppioJP"] - s.date = %q{2010-04-18} - s.description = %q{A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/} + s.date = %q{2010-05-19} + s.description = %q{A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/ . It also works with v2 of OpenX API, especially that it now can pass localTZ to the OpenX API which will give back the correct statistics for the local time zone.} s.email = %q{jacobjp@mac.com} s.extra_rdoc_files = [ "README.rdoc" @@ -34,6 +34,7 @@ Gem::Specification.new do |s| "lib/openx/services/campaign.rb", "lib/openx/services/publisher.rb", "lib/openx/services/session.rb", + "lib/openx/services/statistics.rb", "lib/openx/services/zone.rb", "lib/openx/xmlrpc_client.rb", "php/openx-2.8.1-keywords.diff", diff --git a/lib/openx/invocation.rb b/lib/openx/invocation.rb index 9340b80..5ff1fb0 100644 --- a/lib/openx/invocation.rb +++ b/lib/openx/invocation.rb @@ -1,14 +1,27 @@ module OpenX class Invocation class << self + # Whatever + # banner = OpenX::Invocation.view("Plumber") # - # banner = OpenX::Invocation.view("Plumber") + # banners = OpenX::Invocation.view("Plumber", :count => 2, :exclude_by_campaignid => true) ;nil # - # banners = OpenX::Invocation.view("Plumber", :count => 2, :exclude_by_campaignid => true) ;nil - # banners.each do |banner| - # puts "Banner #{banner['bannerid']}" - # end; nil + # banners.each do |banner| + # puts "Banner #{banner['bannerid']}" + # end; nil # + # + # Defaults + # :count => 1, + # :campaignid => 0, + # :target => '', + # :source => '', + # :with_text => false, + # :exclusions => [], + # :inclusions => [], + # :exclude_by_campaignid => false, + # :exclude_by_bannerid => false + # def view(what, params = {}) defaults = { :count => 1, diff --git a/lib/openx/services/advertiser.rb b/lib/openx/services/advertiser.rb index 37148c8..eb378dd 100644 --- a/lib/openx/services/advertiser.rb +++ b/lib/openx/services/advertiser.rb @@ -1,6 +1,10 @@ module OpenX module Services class Advertiser < Base + + require 'openx/services/statistics' + include OpenX::Services::Statistics + openx_accessor :name => :advertiserName, :contact_name => :contactName, :email => :emailAddress, diff --git a/lib/openx/services/agency.rb b/lib/openx/services/agency.rb index 5157336..781c310 100644 --- a/lib/openx/services/agency.rb +++ b/lib/openx/services/agency.rb @@ -1,6 +1,10 @@ module OpenX module Services class Agency < Base + + require 'openx/services/statistics' + include OpenX::Services::Statistics + # Translate our property names to OpenX property names openx_accessor :name => :agencyName, :contact_name => :contactName, diff --git a/lib/openx/services/banner.rb b/lib/openx/services/banner.rb index 37e607d..7ad678c 100644 --- a/lib/openx/services/banner.rb +++ b/lib/openx/services/banner.rb @@ -3,6 +3,10 @@ module OpenX module Services class Banner < Base + + require 'openx/services/statistics' + include OpenX::Services::Statistics + LOCAL_SQL = 'sql' LOCAL_WEB = 'web' EXTERNAL = 'url' @@ -11,7 +15,7 @@ class Banner < Base RUNNING = 0 PAUSED = 1 - + class << self def find(id, *args) session = self.connection @@ -77,32 +81,29 @@ def initialize(params = {}) super(params) end - # Alias for daily_statistics method to keep consistency with OpenX API calls - # Originally it was call for ox.bannerDailyStatistics so it is kept for compatibility with the previous version - def statistics start_on = Date.today, end_on = Date.today - daily_statistics start_on, end_on + # Alias for daily_statistics method to keep consistency with OpenX API calls. + # Originally it was call for ox.bannerDailyStatistics so it is kept for compatibility with the previous version of the gem. + def statistics start_on = Date.today, end_on = Date.today, local_time_zone = true + daily_statistics start_on, end_on, local_time_zone end - # Returns statistics in Array of Hashes by day, which are: impressions, clicks, requests and revenue. + # Returns statistics in Array of Hashes by day, which are: impressions, clicks, requests and revenue. # Each day is represented by XMLRPC::DateTime which has instant variables: # @year, @month, @day, @hour, @min, @sec - def daily_statistics start_on = Date.today, end_on = Date.today - session = self.class.connection - @server.call('ox.bannerDailyStatistics', session, self.id, start_on, end_on) + def daily_statistics start_on = Date.today, end_on = Date.today, local_time_zone = true + self.get_statistics('ox.bannerDailyStatistics', start_on, end_on, local_time_zone) end # Returns statistics in Array of Hashes by publisher, which are: impression, clicks, requests and revenue. # Also returns publisherName and publisherId - def publisher_statistics start_on = Date.today, end_on = Date.today - session = self.class.connection - @server.call('ox.bannerPublisherStatistics', session, self.id, start_on, end_on) + def publisher_statistics start_on = Date.today, end_on = Date.today, local_time_zone = true + self.get_statistics('ox.bannerPublisherStatistics', start_on, end_on, local_time_zone) end # Returns statistics in Array of Hashes by zone, which are: impression, clicks, requests, conversions and revenue. # Also returns publisherName, publisherId, zoneName, zoneId - def zone_statistics start_on = Date.today, end_on = Date.today - session = self.class.connection - @server.call('ox.bannerZoneStatistics', session, self.id, start_on, end_on) + def zone_statistics start_on = Date.today, end_on = Date.today, local_time_zone = true + self.get_statistics('ox.bannerZoneStatistics', start_on, end_on, local_time_zone) end def targeting diff --git a/lib/openx/services/campaign.rb b/lib/openx/services/campaign.rb index 82ff56a..00af096 100644 --- a/lib/openx/services/campaign.rb +++ b/lib/openx/services/campaign.rb @@ -1,6 +1,10 @@ module OpenX module Services class Campaign < Base + + require 'openx/services/statistics' + include OpenX::Services::Statistics + # Translate our property names to OpenX property names openx_accessor :name => :campaignName, :advertiser_id => :advertiserId, @@ -27,7 +31,7 @@ class Campaign < Base self.find_all = 'ox.getCampaignListByAdvertiserId' # Revenue types - CPM = 1 + CPM = 1 CPC = 2 CPA = 3 MONTHLY_TENANCY = 4 @@ -37,12 +41,14 @@ class Campaign < Base HIGH = 2 EXCLUSIVE = 3 + # Creates new Campaign for the given Advertiser.id required in params[:advertiser_id] or params[:advertiser] def initialize(params = {}) raise ArgumentError.new("Missing advertiser_id") unless params[:advertiser_id] || params[:advertiser] params[:advertiser_id] ||= params[:advertiser].id super(params) end + # Return all banners for the Campaign def banners Banner.find(:all, self.id) end diff --git a/lib/openx/services/publisher.rb b/lib/openx/services/publisher.rb index ae97252..fa92779 100644 --- a/lib/openx/services/publisher.rb +++ b/lib/openx/services/publisher.rb @@ -1,6 +1,10 @@ module OpenX module Services class Publisher < Base + + require 'openx/services/statistics' + include OpenX::Services::Statistics + openx_accessor :name => :publisherName, :contact_name => :contactName, :email => :emailAddress, @@ -26,6 +30,18 @@ def initialize(params = {}) def zones Zone.find(:all, self.id) end + + # Returns statistics in Array of Hashes by day, which are: impression, clicks, requests and revenue. + def daily_statistics start_on = Date.today, end_on = Date.today, local_time_zone = true + self.get_statistics('ox.publisherDailyStatistics', start_on, end_on, local_time_zone) + end + + # Returns statistics in Array of Hashes by banner, which are: impression, clicks, requests and revenue. + # Also returns bannerName, bannerId, advertiserName, advertiserId, campaignName, campaignId + def banner_statistics start_on = Date.today, end_on = Date.today, local_time_zone = true + self.get_statistics('ox.publisherBannerStatistics', start_on, end_on, local_time_zone) + end + end end end diff --git a/lib/openx/services/zone.rb b/lib/openx/services/zone.rb index 358c61d..67a3b6a 100644 --- a/lib/openx/services/zone.rb +++ b/lib/openx/services/zone.rb @@ -1,6 +1,10 @@ module OpenX module Services class Zone < Base + + require 'openx/services/statistics' + include OpenX::Services::Statistics + # Delivery types BANNER = 'delivery-b' INTERSTITIAL = 'delivery-i' From b3d9c0725c7696078eca3daacda629db99648bb5 Mon Sep 17 00:00:00 2001 From: DoppioJP Date: Sun, 6 Feb 2011 00:56:23 -0800 Subject: [PATCH 36/36] config.gem changed to jjp-openx --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 4444dac..c5807fd 100644 --- a/README.rdoc +++ b/README.rdoc @@ -68,7 +68,7 @@ file something like openx_credentials.yml to be explicit about the content. Then, add your gem require line to the initialize block of the environment.rb: - config.gem "touchlocal-openx", + config.gem "jjp-openx", :lib => "openx", :source => "http://gemcutter.org" You will of course need to install the gem, either manually or via