zuck 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +4 -0
- data/VERSION +1 -1
- data/lib/zuck/facebook/targeting_spec.rb +33 -3
- data/spec/lib/zuck/facebook/targeting_spec_spec.rb +8 -0
- data/zuck.gemspec +2 -2
- metadata +3 -3
data/CHANGELOG.markdown
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
@@ -7,7 +7,29 @@ module Zuck
|
|
7
7
|
class InvalidGenderError < InvalidSpecError; end
|
8
8
|
class ParamsMissingError < InvalidSpecError; end
|
9
9
|
|
10
|
-
|
10
|
+
# FB ads api wants uppercase 2 digit iso country codes
|
11
|
+
ISO_COUNTRY_CODES = %w{ AX AF AL DZ AS AD AO AI AQ AG AR
|
12
|
+
AM AW AU AT AZ BS BH BD BB BY BE
|
13
|
+
BZ BJ BM BT BO BA BW BV BR IO BN
|
14
|
+
BG BF BI KH CM CA CV KY CF TD CL
|
15
|
+
CN CX CC CO KM CD CG CK CR CI HR
|
16
|
+
CU CY CZ DK DJ DM DO EC EG SV GQ
|
17
|
+
ER EE ET FK FO FJ FI FR GF PF TF
|
18
|
+
GA GM GE DE GH GI GR GL GD GP GU
|
19
|
+
GT GN GW GY HT HM HN HK HU IS IN
|
20
|
+
ID IR IQ IE IL IT JM JP JO KZ KE
|
21
|
+
KI KP KR KW KG LA LV LB LS LR LY
|
22
|
+
LI LT LU MO MK MG MW MY MV ML MT
|
23
|
+
MH MQ MR MU YT MX FM MD MC MN MS
|
24
|
+
MA MZ MM NA NR NP NL AN NC NZ NI
|
25
|
+
NE NG NU NF MP NO OM PK PW PS PA
|
26
|
+
PG PY PE PH PN PL PT PR QA RE RO
|
27
|
+
RU RW SH KN LC PM VC WS SM ST SA
|
28
|
+
SN CS SC SL SG SK SI SB SO ZA GS
|
29
|
+
ES LK SD SR SJ SZ SE CH SY TW TJ
|
30
|
+
TZ TH TL TG TK TO TT TN TR TM TC
|
31
|
+
TV UG UA AE GB US UM UY UZ VU VA
|
32
|
+
VE VN VG VI WF EH YE ZM ZW }
|
11
33
|
|
12
34
|
#
|
13
35
|
# Some helpers around https://developers.facebook.com/docs/reference/ads-api/targeting-specs/
|
@@ -56,7 +78,7 @@ module Zuck
|
|
56
78
|
build_spec
|
57
79
|
end
|
58
80
|
|
59
|
-
# @return [Hash] The reach for the options given in {#initialize}, see
|
81
|
+
# @return [Hash] The reach for the options given in {#initialize}, see
|
60
82
|
# https://developers.facebook.com/docs/reference/ads-api/reachestimate/
|
61
83
|
def fetch_reach
|
62
84
|
validate_spec
|
@@ -160,12 +182,20 @@ module Zuck
|
|
160
182
|
@spec[:countries] = normalize_countries(@spec[:countries])
|
161
183
|
@spec[:keywords] = normalize_array(@spec[:keywords])
|
162
184
|
@spec[:broad_age] ||= false
|
163
|
-
|
185
|
+
validate_countries
|
164
186
|
unless @spec[:keywords].present? or @spec[:connections].present?
|
165
187
|
raise(ParamsMissingError, "Need to set :keywords or :connections")
|
166
188
|
end
|
167
189
|
end
|
168
190
|
|
191
|
+
def validate_countries
|
192
|
+
raise(InvalidCountryError, "Need to set :countries") unless @spec[:countries].present?
|
193
|
+
raise(InvalidCountryError, "Must supply between 1 and 25 countries") if @spec[:countries].length > 25
|
194
|
+
invalid_countries = @spec[:countries] - Zuck::ISO_COUNTRY_CODES
|
195
|
+
return if invalid_countries.empty?
|
196
|
+
raise(InvalidCountryError, "Invalid countrie(s): #{invalid_countries}")
|
197
|
+
end
|
198
|
+
|
169
199
|
def build_spec
|
170
200
|
return unless @spec
|
171
201
|
age = @spec.delete(:age_class)
|
@@ -105,6 +105,14 @@ describe Zuck::TargetingSpec do
|
|
105
105
|
}.to raise_error("Gender can only be male or female")
|
106
106
|
end
|
107
107
|
|
108
|
+
it "does not accept invalid countries" do
|
109
|
+
expect{
|
110
|
+
z = Zuck::TargetingSpec.new(graph, ad_account, countries: ['XX'], keywords: ['foo'], gender: 'female')
|
111
|
+
z.send(:validate_spec)
|
112
|
+
}.to raise_error('Invalid countrie(s): ["XX"]')
|
113
|
+
end
|
114
|
+
|
115
|
+
|
108
116
|
it "does not accept targetings with neither :keywords nor :connections" do
|
109
117
|
expect{
|
110
118
|
ts = Zuck::TargetingSpec.new(graph, ad_account, countries: ['US'], gender: 'female')
|
data/zuck.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "zuck"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jannis Hermanns"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-07-01"
|
13
13
|
s.description = "This gem allows to easily access facebook's ads api in ruby. See https://developers.facebook.com/docs/reference/ads-api/"
|
14
14
|
s.email = "jannis@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: zuck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jannis Hermanns
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rvm
|
@@ -371,7 +371,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
371
371
|
- !ruby/object:Gem::Version
|
372
372
|
segments:
|
373
373
|
- 0
|
374
|
-
hash: -
|
374
|
+
hash: -4054154295877984613
|
375
375
|
version: '0'
|
376
376
|
none: false
|
377
377
|
required_rubygems_version: !ruby/object:Gem::Requirement
|