francois-ad_gear_client 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/ad_gear_client.gemspec +5 -2
- data/lib/ad_gear/ad_unit.rb +3 -1
- data/lib/ad_gear/base.rb +9 -8
- data/lib/ad_gear/core_ext.rb +1 -1
- data/lib/ad_gear/has_many_array.rb +29 -3
- data/lib/ad_gear/web_campaign.rb +1 -0
- metadata +12 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/ad_gear_client.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{ad_gear_client}
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.6"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Fran\303\247ois Beausoleil"]
|
9
|
-
s.date = %q{2009-09-
|
9
|
+
s.date = %q{2009-09-25}
|
10
10
|
s.email = %q{francois@teksol.info}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
@@ -90,16 +90,19 @@ Gem::Specification.new do |s|
|
|
90
90
|
s.add_development_dependency(%q<mocha>, [">= 0.9.5"])
|
91
91
|
s.add_runtime_dependency(%q<activeresource>, ["> 2.0"])
|
92
92
|
s.add_runtime_dependency(%q<francois-rest-client>, ["~> 1"])
|
93
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
93
94
|
else
|
94
95
|
s.add_dependency(%q<lsegal-yard>, [">= 0.2.3"])
|
95
96
|
s.add_dependency(%q<mocha>, [">= 0.9.5"])
|
96
97
|
s.add_dependency(%q<activeresource>, ["> 2.0"])
|
97
98
|
s.add_dependency(%q<francois-rest-client>, ["~> 1"])
|
99
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
98
100
|
end
|
99
101
|
else
|
100
102
|
s.add_dependency(%q<lsegal-yard>, [">= 0.2.3"])
|
101
103
|
s.add_dependency(%q<mocha>, [">= 0.9.5"])
|
102
104
|
s.add_dependency(%q<activeresource>, ["> 2.0"])
|
103
105
|
s.add_dependency(%q<francois-rest-client>, ["~> 1"])
|
106
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
104
107
|
end
|
105
108
|
end
|
data/lib/ad_gear/ad_unit.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module AdGear
|
2
2
|
class AdUnit < AdGear::Base
|
3
3
|
has_many :ad_unit_files, :ad_unit_clicks, :ad_unit_interactions, :ad_unit_variables
|
4
|
-
|
4
|
+
has_many :placement_memberships
|
5
|
+
belongs_to :web_campaign, :as => :campaign
|
6
|
+
belongs_to :format
|
5
7
|
|
6
8
|
def active?
|
7
9
|
state == "active"
|
data/lib/ad_gear/base.rb
CHANGED
@@ -13,16 +13,17 @@ module AdGear
|
|
13
13
|
# class AdGear::AdSpot < AdGear::Base
|
14
14
|
# belongs_to :format
|
15
15
|
# belongs_to :bookable, :polymorphic => true
|
16
|
+
# belongs_to :web_campaign, :as => :campaign
|
16
17
|
# end
|
17
18
|
#
|
18
19
|
# include AdGear
|
19
|
-
# AdSpot.new(:format => Format.find(1), :bookable => Publisher.find(2)).attributes
|
20
|
-
# #=> {"format_id" => 1, "bookable_id" => 2, "bookable_type" => "Publisher"}
|
20
|
+
# AdSpot.new(:format => Format.find(1), :bookable => Publisher.find(2), :web_campaign => WebCampaign.find(3)).attributes
|
21
|
+
# #=> {"format_id" => 1, "bookable_id" => 2, "bookable_type" => "Publisher", "campaign_id" => 3}
|
21
22
|
def self.belongs_to(*attributes)
|
22
23
|
options = attributes.extract_options!
|
23
24
|
attributes.each do |attribute|
|
24
25
|
attribute_name = attribute.to_s
|
25
|
-
belongs_to_associations[attribute_name] = options
|
26
|
+
belongs_to_associations[attribute_name] = options.reverse_merge(:as => attribute_name)
|
26
27
|
|
27
28
|
if options[:polymorphic] then
|
28
29
|
polymorphic_belongs_to_attribute_writer_for(attribute_name)
|
@@ -138,8 +139,8 @@ module AdGear
|
|
138
139
|
|
139
140
|
def self.polymorphic_belongs_to_attribute_reader_for(attribute_name) #:nodoc:
|
140
141
|
define_method(attribute_name) do
|
141
|
-
klass = @attributes[belongs_to_attribute_name_for_class(attribute_name)]
|
142
|
-
id = @attributes[belongs_to_attribute_name_for_id(attribute_name)]
|
142
|
+
klass = @attributes[self.class.belongs_to_attribute_name_for_class(attribute_name)]
|
143
|
+
id = @attributes[self.class.belongs_to_attribute_name_for_id(attribute_name)]
|
143
144
|
id.blank? ? nil : AdGear.const_get(AdGear.const_get(klass)).find(id)
|
144
145
|
end
|
145
146
|
end
|
@@ -152,17 +153,17 @@ module AdGear
|
|
152
153
|
|
153
154
|
def self.belongs_to_attribute_reader_for(attribute_name) #:nodoc:
|
154
155
|
define_method(attribute_name) do
|
155
|
-
id = @attributes[belongs_to_attribute_name_for_id(attribute_name)]
|
156
|
+
id = @attributes[self.class.belongs_to_attribute_name_for_id(attribute_name)]
|
156
157
|
id.blank? ? nil : AdGear.const_get(attribute_name.classify).find(id)
|
157
158
|
end
|
158
159
|
end
|
159
160
|
|
160
161
|
def self.belongs_to_attribute_name_for_class(association_name)
|
161
|
-
"
|
162
|
+
"%s_type" % belongs_to_associations[association_name][:as]
|
162
163
|
end
|
163
164
|
|
164
165
|
def self.belongs_to_attribute_name_for_id(association_name)
|
165
|
-
"
|
166
|
+
"%s_id" % belongs_to_associations[association_name][:as]
|
166
167
|
end
|
167
168
|
end
|
168
169
|
end
|
data/lib/ad_gear/core_ext.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
#
|
9
9
|
class Array
|
10
10
|
def to_xml_with_module_prefixing(options = {})
|
11
|
-
raise "Not all elements respond to to_xml" unless all? { |e| e.respond_to? :to_xml }
|
11
|
+
raise "Not all elements respond to to_xml in #{self.inspect}" unless all? { |e| e.respond_to? :to_xml }
|
12
12
|
root = all? { |e| e.is_a?(first.class) && first.class.to_s != "Hash" } ?
|
13
13
|
ActiveSupport::Inflector.pluralize(ActiveSupport::Inflector.underscore(first.class.to_s.split("::").last)) : "records"
|
14
14
|
to_xml_without_module_prefixing({ :root => root }.merge(options))
|
@@ -14,9 +14,14 @@ module AdGear
|
|
14
14
|
|
15
15
|
def <<(object)
|
16
16
|
root = if object.kind_of?(Hash) then
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
if object.has_key?("id") || object.has_key?(:id) then
|
18
|
+
object = @klass.new(object)
|
19
|
+
@saved
|
20
|
+
else
|
21
|
+
# Instantiate an object from the Hash, which will obviously be a new object
|
22
|
+
object = @klass.new(object)
|
23
|
+
@new
|
24
|
+
end
|
20
25
|
elsif object.respond_to?(:new_record?) && object.new_record?
|
21
26
|
@new
|
22
27
|
else
|
@@ -36,6 +41,22 @@ module AdGear
|
|
36
41
|
|
37
42
|
alias_method :size, :length
|
38
43
|
|
44
|
+
def empty?
|
45
|
+
combined.empty?
|
46
|
+
end
|
47
|
+
|
48
|
+
def [](*args)
|
49
|
+
combined[*args]
|
50
|
+
end
|
51
|
+
|
52
|
+
def first
|
53
|
+
combined.first
|
54
|
+
end
|
55
|
+
|
56
|
+
def last
|
57
|
+
combined.last
|
58
|
+
end
|
59
|
+
|
39
60
|
def to_xml(options={})
|
40
61
|
xml = options[:builder] || Builder::XmlMarkup.new
|
41
62
|
xml.__send__(@name) do
|
@@ -54,5 +75,10 @@ module AdGear
|
|
54
75
|
end
|
55
76
|
end
|
56
77
|
end
|
78
|
+
|
79
|
+
private
|
80
|
+
def combined
|
81
|
+
@new + @saved
|
82
|
+
end
|
57
83
|
end
|
58
84
|
end
|
data/lib/ad_gear/web_campaign.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: francois-ad_gear_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Fran\xC3\xA7ois Beausoleil"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-25 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -52,6 +52,16 @@ dependencies:
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: "1"
|
54
54
|
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
type: :runtime
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
55
65
|
description:
|
56
66
|
email: francois@teksol.info
|
57
67
|
executables: []
|