fb_graph 2.2.5 → 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,34 +1,33 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fb_graph (2.2.3)
4
+ fb_graph (2.2.5)
5
5
  httpclient (>= 2.2.0.2)
6
6
  rack-oauth2 (>= 0.9.4)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- actionpack (3.1.3)
12
- activemodel (= 3.1.3)
13
- activesupport (= 3.1.3)
11
+ actionpack (3.2.0)
12
+ activemodel (= 3.2.0)
13
+ activesupport (= 3.2.0)
14
14
  builder (~> 3.0.0)
15
15
  erubis (~> 2.7.0)
16
- i18n (~> 0.6)
17
- rack (~> 1.3.5)
16
+ journey (~> 1.0.0)
17
+ rack (~> 1.4.0)
18
18
  rack-cache (~> 1.1)
19
- rack-mount (~> 0.8.2)
20
19
  rack-test (~> 0.6.1)
21
- sprockets (~> 2.0.3)
22
- activemodel (3.1.3)
23
- activesupport (= 3.1.3)
20
+ sprockets (~> 2.1.2)
21
+ activemodel (3.2.0)
22
+ activesupport (= 3.2.0)
24
23
  builder (~> 3.0.0)
24
+ activesupport (3.2.0)
25
25
  i18n (~> 0.6)
26
- activesupport (3.1.3)
27
26
  multi_json (~> 1.0)
28
27
  addressable (2.2.6)
29
28
  attr_required (0.0.3)
30
29
  builder (3.0.0)
31
- configatron (2.8.4)
30
+ configatron (2.9.0)
32
31
  yamler (>= 0.1.0)
33
32
  cover_me (1.2.0)
34
33
  configatron
@@ -38,15 +37,14 @@ GEM
38
37
  erubis (2.7.0)
39
38
  hashie (1.2.0)
40
39
  hike (1.2.1)
41
- httpclient (2.2.3)
40
+ httpclient (2.2.4)
42
41
  i18n (0.6.0)
43
- json (1.6.1)
44
- multi_json (1.0.3)
45
- rack (1.3.5)
42
+ journey (1.0.0)
43
+ json (1.6.5)
44
+ multi_json (1.0.4)
45
+ rack (1.4.0)
46
46
  rack-cache (1.1)
47
47
  rack (>= 0.4)
48
- rack-mount (0.8.3)
49
- rack (>= 1.0.0)
50
48
  rack-oauth2 (0.11.0)
51
49
  activesupport (>= 2.3)
52
50
  attr_required (>= 0.0.3)
@@ -57,20 +55,20 @@ GEM
57
55
  rack-test (0.6.1)
58
56
  rack (>= 1.0)
59
57
  rake (0.9.2.2)
60
- rspec (2.7.0)
61
- rspec-core (~> 2.7.0)
62
- rspec-expectations (~> 2.7.0)
63
- rspec-mocks (~> 2.7.0)
64
- rspec-core (2.7.1)
65
- rspec-expectations (2.7.0)
58
+ rspec (2.8.0)
59
+ rspec-core (~> 2.8.0)
60
+ rspec-expectations (~> 2.8.0)
61
+ rspec-mocks (~> 2.8.0)
62
+ rspec-core (2.8.0)
63
+ rspec-expectations (2.8.0)
66
64
  diff-lcs (~> 1.1.2)
67
- rspec-mocks (2.7.0)
68
- sprockets (2.0.3)
65
+ rspec-mocks (2.8.0)
66
+ sprockets (2.1.2)
69
67
  hike (~> 1.2)
70
68
  rack (~> 1.0)
71
69
  tilt (~> 1.1, != 1.3.0)
72
70
  tilt (1.3.3)
73
- webmock (1.7.8)
71
+ webmock (1.7.10)
74
72
  addressable (~> 2.2, > 2.2.5)
75
73
  crack (>= 0.1.7)
76
74
  yamler (0.1.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.5
1
+ 2.2.6
@@ -7,6 +7,18 @@ module FbGraph
7
7
  /invalid_request/ => "InvalidRequest"
8
8
  }
9
9
 
10
+ ERROR_EXCEPTION_MATCHERS = {
11
+ /Could\snot\ssave\screative/ => "CreativeNotSaved",
12
+ /QueryLockTimeoutException/ => "QueryLockTimeout",
13
+ /Could\snot\screate\stargeting\sspec/ => "TargetingSpecNotSaved",
14
+ /Could\snot\sfetch\sadgroups/ => "AdgroupFetchFailure",
15
+ /Failed\sto\sopen\sprocess/ => "OpenProcessFailure",
16
+ /Could\snot\scommit\stransaction/ => "TransactionCommitFailure",
17
+ /QueryErrorException/ => "QueryError",
18
+ /QueryConnectionException/ => "QueryConnection",
19
+ /QueryDuplicateKeyException/ => "QueryDuplicateKey"
20
+ }
21
+
10
22
  def self.handle_httpclient_error(response, headers)
11
23
  return nil unless response[:error]
12
24
 
@@ -31,7 +43,15 @@ module FbGraph
31
43
  when /OAuth/
32
44
  raise Unauthorized.new("#{response[:error][:type]} :: #{response[:error][:message]}")
33
45
  else
34
- raise BadRequest.new("#{response[:error][:type]} :: #{response[:error][:message]}")
46
+ exception_class = nil
47
+ ERROR_EXCEPTION_MATCHERS.keys.each do |matcher|
48
+ exception_class = FbGraph::const_get(ERROR_EXCEPTION_MATCHERS[matcher]) if matcher =~ response[:error][:message]
49
+ end
50
+ if exception_class
51
+ raise exception_class.new("#{response[:error][:type]} :: #{response[:error][:message]}")
52
+ else
53
+ raise BadRequest.new("#{response[:error][:type]} :: #{response[:error][:message]}")
54
+ end
35
55
  end
36
56
  end
37
57
 
@@ -65,9 +85,33 @@ module FbGraph
65
85
  end
66
86
  end
67
87
 
88
+ class InternalServerError < Exception
89
+ def initialize(message, body = '')
90
+ super 500, message, body
91
+ end
92
+ end
93
+
68
94
  class InvalidToken < Unauthorized; end
69
95
 
70
96
  class InvalidSession < InvalidToken; end
71
97
 
72
98
  class InvalidRequest < BadRequest; end
99
+
100
+ class CreativeNotSaved < InternalServerError; end
101
+
102
+ class QueryLockTimeout < InternalServerError; end
103
+
104
+ class TargetingSpecNotSaved < InternalServerError; end
105
+
106
+ class AdgroupFetchFailure < InternalServerError; end
107
+
108
+ class OpenProcessFailure < InternalServerError; end
109
+
110
+ class TransactionCommitFailure < InternalServerError; end
111
+
112
+ class QueryError < InternalServerError; end
113
+
114
+ class QueryConnection < InternalServerError; end
115
+
116
+ class QueryDuplicateKey < InternalServerError; end
73
117
  end
data/lib/fb_graph/user.rb CHANGED
@@ -43,10 +43,10 @@ module FbGraph
43
43
  include OpenGraph::UserContext
44
44
  extend Searchable
45
45
 
46
- attr_accessor :name, :first_name, :middle_name, :last_name, :gender, :locale, :languages, :link, :username, :third_party_id, :timezone, :updated_time, :verified, :about, :bio, :birthday, :education, :email, :hometown, :interested_in, :location, :political, :favorite_teams, :quotes, :relationship_status, :religion, :significant_other, :video_upload_limits, :website, :work
46
+ attr_accessor :name, :first_name, :middle_name, :last_name, :gender, :locale, :languages, :link, :username, :third_party_id, :timezone, :updated_time, :verified, :about, :bio, :birthday, :education, :email, :hometown, :interested_in, :location, :political, :favorite_teams, :quotes, :relationship, :relationship_status, :religion, :significant_other, :video_upload_limits, :website, :work
47
47
 
48
48
  # NOTE: below are non-documented
49
- attr_accessor :sports, :favorite_athletes, :inspirational_people, :address, :mobile_phone
49
+ attr_accessor :sports, :favorite_athletes, :inspirational_people, :address, :mobile_phone, :installed
50
50
 
51
51
  def initialize(identifier, attributes = {})
52
52
  super
@@ -104,6 +104,8 @@ module FbGraph
104
104
  if (significant_other = attributes[:significant_other])
105
105
  @significant_other = User.new(significant_other[:id], significant_other)
106
106
  end
107
+ # If this user was build from the family connection, set the relationship type
108
+ @relationship = attributes[:relationship]
107
109
  # NOTE: couldn't find "video_upload_limits" in the response..
108
110
  # @video_upload_limits = ??
109
111
  @website = attributes[:website]
@@ -137,6 +139,7 @@ module FbGraph
137
139
  @address = Venue.new(attributes[:address])
138
140
  end
139
141
  @mobile_phone = attributes[:mobile_phone]
142
+ @installed = attributes[:installed]
140
143
  end
141
144
 
142
145
  def self.me(access_token)
@@ -135,9 +135,146 @@ describe FbGraph::Exception, ".handle_httpclient_error" do
135
135
  }
136
136
  end
137
137
 
138
- it "should raise a BadRequst exception" do
138
+ it "should raise a BadRequest exception" do
139
139
  lambda {FbGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(FbGraph::BadRequest)
140
140
  end
141
+
142
+ context "with an Ads API Exception" do
143
+ context "of Could not save creative" do
144
+ let(:parsed_response) do
145
+ {
146
+ :error => {
147
+ :message => 'Could not save creative',
148
+ :type => "Exception"
149
+ }
150
+ }
151
+ end
152
+
153
+ it "should raise a CreativeNotSaved exception" do
154
+ lambda {FbGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(FbGraph::CreativeNotSaved)
155
+ end
156
+ end
157
+
158
+ context "of QueryLockTimeout" do
159
+ let(:parsed_response) do
160
+ {
161
+ :error => {
162
+ :message => 'QueryLockTimeoutException',
163
+ :type => "Exception"
164
+ }
165
+ }
166
+ end
167
+
168
+ it "should raise a QueryLockTimeout exception" do
169
+ lambda {FbGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(FbGraph::QueryLockTimeout)
170
+ end
171
+ end
172
+
173
+ context "of Could not create targeting spec" do
174
+ let(:parsed_response) do
175
+ {
176
+ :error => {
177
+ :message => 'Could not create targeting spec',
178
+ :type => "Exception"
179
+ }
180
+ }
181
+ end
182
+
183
+ it "should raise a TargetingSpecNotSaved exception" do
184
+ lambda {FbGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(FbGraph::TargetingSpecNotSaved)
185
+ end
186
+ end
187
+
188
+ context "of Could not fetch adgroups" do
189
+ let(:parsed_response) do
190
+ {
191
+ :error => {
192
+ :message => 'Could not fetch adgroups',
193
+ :type => "Exception"
194
+ }
195
+ }
196
+ end
197
+
198
+ it "should raise a AdgroupFetchFailure exception" do
199
+ lambda {FbGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(FbGraph::AdgroupFetchFailure)
200
+ end
201
+ end
202
+
203
+ context "of Failed to open process" do
204
+ let(:parsed_response) do
205
+ {
206
+ :error => {
207
+ :message => 'Failed to open process',
208
+ :type => "Exception"
209
+ }
210
+ }
211
+ end
212
+
213
+ it "should raise a OpenProcessFailure exception" do
214
+ lambda {FbGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(FbGraph::OpenProcessFailure)
215
+ end
216
+ end
217
+
218
+ context "of Could not commit transaction" do
219
+ let(:parsed_response) do
220
+ {
221
+ :error => {
222
+ :message => 'Could not commit transaction',
223
+ :type => "Exception"
224
+ }
225
+ }
226
+ end
227
+
228
+ it "should raise a TransactionCommitFailure exception" do
229
+ lambda {FbGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(FbGraph::TransactionCommitFailure)
230
+ end
231
+ end
232
+
233
+ context "of QueryErrorException" do
234
+ let(:parsed_response) do
235
+ {
236
+ :error => {
237
+ :message => 'DB Error: QueryErrorException',
238
+ :type => "Exception"
239
+ }
240
+ }
241
+ end
242
+
243
+ it "should raise a QueryError exception" do
244
+ lambda {FbGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(FbGraph::QueryError)
245
+ end
246
+ end
247
+
248
+ context "of QueryConnectionException" do
249
+ let(:parsed_response) do
250
+ {
251
+ :error => {
252
+ :message => 'QueryConnectionException',
253
+ :type => "Exception"
254
+ }
255
+ }
256
+ end
257
+
258
+ it "should raise a QueryConnection exception" do
259
+ lambda {FbGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(FbGraph::QueryConnection)
260
+ end
261
+ end
262
+
263
+ context "of QueryDuplicateKeyException" do
264
+ let(:parsed_response) do
265
+ {
266
+ :error => {
267
+ :message => 'QueryDuplicateKeyException',
268
+ :type => "Exception"
269
+ }
270
+ }
271
+ end
272
+
273
+ it "should raise a QueryDuplicateKey exception" do
274
+ lambda {FbGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(FbGraph::QueryDuplicateKey)
275
+ end
276
+ end
277
+ end
141
278
  end
142
279
  end
143
280
  end
@@ -9,11 +9,13 @@ describe FbGraph::User, '.new' do
9
9
  :state => "Kanagawa",
10
10
  :country => "Japan"
11
11
  },
12
- :mobile_phone => '810000000000'
12
+ :mobile_phone => '810000000000',
13
+ :installed => true
13
14
  }
14
15
  user = FbGraph::User.new(attributes.delete(:id), attributes)
15
16
  user.address.should == FbGraph::Venue.new(attributes[:address])
16
17
  user.mobile_phone.should == '810000000000'
18
+ user.installed.should be_true
17
19
  end
18
20
 
19
21
  it 'should support year-hidden birthday' do
@@ -4,7 +4,6 @@
4
4
  "category": "Games",
5
5
  "subcategory": "Virtual World",
6
6
  "link": "http:\/\/www.facebook.com\/apps\/application.php?id=134145643294322",
7
- "canvas_name": "fbgraphsample",
8
7
  "namespace": "fbgraphsample",
9
8
  "icon_url": "http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yT\/r\/4QVMqOjUhcd.gif",
10
9
  "logo_url": "http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yq\/r\/IobSBNz4FuT.gif",
@@ -7,7 +7,6 @@
7
7
  "score": 10,
8
8
  "application": {
9
9
  "name": "gem sample",
10
- "canvas_name": "fbgraphsample",
11
10
  "namespace": "fbgraphsample",
12
11
  "id": "134145643294322"
13
12
  }
metadata CHANGED
@@ -1,141 +1,101 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fb_graph
3
- version: !ruby/object:Gem::Version
4
- hash: 13
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.2.6
5
5
  prerelease:
6
- segments:
7
- - 2
8
- - 2
9
- - 5
10
- version: 2.2.5
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - nov matake
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-01-05 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-01-23 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: httpclient
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70181080284940 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 123
29
- segments:
30
- - 2
31
- - 2
32
- - 0
33
- - 2
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 2.2.0.2
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: rack-oauth2
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70181080284940
25
+ - !ruby/object:Gem::Dependency
26
+ name: rack-oauth2
27
+ requirement: &70181080283820 !ruby/object:Gem::Requirement
41
28
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 51
46
- segments:
47
- - 0
48
- - 9
49
- - 4
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
50
32
  version: 0.9.4
51
33
  type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: rake
55
34
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70181080283820
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70181080283240 !ruby/object:Gem::Requirement
57
39
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 27
62
- segments:
63
- - 0
64
- - 8
65
- version: "0.8"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0.8'
66
44
  type: :development
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- name: rcov
70
45
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70181080283240
47
+ - !ruby/object:Gem::Dependency
48
+ name: cover_me
49
+ requirement: &70181080282560 !ruby/object:Gem::Requirement
72
50
  none: false
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- hash: 25
77
- segments:
78
- - 0
79
- - 9
80
- version: "0.9"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.0
81
55
  type: :development
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
- name: rspec
85
56
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *70181080282560
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: &70181080281640 !ruby/object:Gem::Requirement
87
61
  none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 7
92
- segments:
93
- - 2
94
- version: "2"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '2'
95
66
  type: :development
96
- version_requirements: *id005
97
- - !ruby/object:Gem::Dependency
98
- name: webmock
99
67
  prerelease: false
100
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *70181080281640
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: &70181080280640 !ruby/object:Gem::Requirement
101
72
  none: false
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- hash: 11
106
- segments:
107
- - 1
108
- - 6
109
- - 2
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
110
76
  version: 1.6.2
111
77
  type: :development
112
- version_requirements: *id006
113
- - !ruby/object:Gem::Dependency
114
- name: actionpack
115
78
  prerelease: false
116
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *70181080280640
80
+ - !ruby/object:Gem::Dependency
81
+ name: actionpack
82
+ requirement: &70181080279640 !ruby/object:Gem::Requirement
117
83
  none: false
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- hash: 11
122
- segments:
123
- - 3
124
- - 0
125
- - 6
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
126
87
  version: 3.0.6
127
88
  type: :development
128
- version_requirements: *id007
89
+ prerelease: false
90
+ version_requirements: *70181080279640
129
91
  description: A full-stack Facebook Graph API wrapper in Ruby.
130
92
  email: nov@matake.jp
131
93
  executables: []
132
-
133
94
  extensions: []
134
-
135
- extra_rdoc_files:
95
+ extra_rdoc_files:
136
96
  - LICENSE
137
97
  - README.rdoc
138
- files:
98
+ files:
139
99
  - .document
140
100
  - .gitignore
141
101
  - .rspec
@@ -628,38 +588,30 @@ files:
628
588
  - spec/spec_helper.rb
629
589
  homepage: http://github.com/nov/fb_graph
630
590
  licenses: []
631
-
632
591
  post_install_message:
633
- rdoc_options:
592
+ rdoc_options:
634
593
  - --charset=UTF-8
635
- require_paths:
594
+ require_paths:
636
595
  - lib
637
- required_ruby_version: !ruby/object:Gem::Requirement
596
+ required_ruby_version: !ruby/object:Gem::Requirement
638
597
  none: false
639
- requirements:
640
- - - ">="
641
- - !ruby/object:Gem::Version
642
- hash: 3
643
- segments:
644
- - 0
645
- version: "0"
646
- required_rubygems_version: !ruby/object:Gem::Requirement
598
+ requirements:
599
+ - - ! '>='
600
+ - !ruby/object:Gem::Version
601
+ version: '0'
602
+ required_rubygems_version: !ruby/object:Gem::Requirement
647
603
  none: false
648
- requirements:
649
- - - ">="
650
- - !ruby/object:Gem::Version
651
- hash: 3
652
- segments:
653
- - 0
654
- version: "0"
604
+ requirements:
605
+ - - ! '>='
606
+ - !ruby/object:Gem::Version
607
+ version: '0'
655
608
  requirements: []
656
-
657
609
  rubyforge_project:
658
- rubygems_version: 1.8.6
610
+ rubygems_version: 1.8.12
659
611
  signing_key:
660
612
  specification_version: 3
661
613
  summary: A full-stack Facebook Graph API wrapper in Ruby.
662
- test_files:
614
+ test_files:
663
615
  - spec/fb_graph/achievement_spec.rb
664
616
  - spec/fb_graph/ad_account_spec.rb
665
617
  - spec/fb_graph/ad_campaign_spec.rb