fb_graph 2.4.11 → 2.4.12

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,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fb_graph (2.4.10)
4
+ fb_graph (2.4.11)
5
5
  httpclient (>= 2.2.0.2)
6
6
  rack-oauth2 (>= 0.14.4)
7
7
  tzinfo
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.4.11
1
+ 2.4.12
@@ -26,15 +26,52 @@ module FbGraph
26
26
  :name,
27
27
  :namespace,
28
28
  :description,
29
+ :canvas_name,
29
30
  :category,
30
- :company,
31
- :icon_url,
32
31
  :subcategory,
33
32
  :link,
33
+ :company,
34
+ :icon_url,
34
35
  :logo_url,
35
36
  :daily_active_users,
36
37
  :weekly_active_users,
37
38
  :monthly_active_users,
39
+ :migrations,
40
+ :namespace,
41
+ :restrictions,
42
+ :app_domains,
43
+ :auth_dialog_data_help_url,
44
+ :auth_dialog_description,
45
+ :auth_dialog_headline,
46
+ :auth_dialog_perms_explanation,
47
+ :auth_referral_user_perms,
48
+ :auth_referral_friend_perms,
49
+ :auth_referral_default_activity_privacy,
50
+ :auth_referral_enabled,
51
+ :auth_referral_extended_perms,
52
+ :auth_referral_response_type,
53
+ :canvas_fluid_height,
54
+ :canvas_fluid_width,
55
+ :canvas_url,
56
+ :contact_email,
57
+ :created_time,
58
+ :creator_uid,
59
+ :deauth_callback_url,
60
+ :iphone_app_store_id,
61
+ :hosting_url,
62
+ :mobile_web_url,
63
+ :page_tab_default_name,
64
+ :page_tab_url,
65
+ :privacy_policy_url,
66
+ :secure_canvas_url,
67
+ :secure_page_tab_url,
68
+ :server_ip_whitelist,
69
+ :social_discovery,
70
+ :terms_of_service_url,
71
+ :user_support_email,
72
+ :user_support_url,
73
+ :website_url,
74
+ :type,
38
75
  :secret
39
76
  ]
40
77
  attr_accessor *@@attributes
@@ -46,6 +83,15 @@ module FbGraph
46
83
  # For some reason, Graph API returns daily_active_users, weekly_active_users, monthly_active_users as JSON string.
47
84
  value = if [:daily_active_users, :weekly_active_users, :monthly_active_users].include?(key)
48
85
  attributes[key].to_i
86
+ # Boolean fields may be returned as 1 for true or 0 for false
87
+ elsif [:auth_referral_enabled, :canvas_fluid_height, :canvas_fluid_width, :social_discovery]
88
+ if attributes[key] == 1
89
+ true
90
+ elsif attributes[key] == 0
91
+ false
92
+ else
93
+ attributes[key]
94
+ end
49
95
  else
50
96
  attributes[key]
51
97
  end
@@ -66,4 +112,4 @@ module FbGraph
66
112
  alias_method_chain :access_token, :auto_fetch
67
113
 
68
114
  end
69
- end
115
+ end
@@ -2,7 +2,11 @@ module FbGraph
2
2
  module Comparison
3
3
  def ==(other)
4
4
  instance_variables.all? do |key|
5
- instance_variable_get(key) == other.instance_variable_get(key)
5
+ if key.to_s == '@raw_attributes'
6
+ :ignore_difference!
7
+ else
8
+ instance_variable_get(key) == other.instance_variable_get(key)
9
+ end
6
10
  end
7
11
  end
8
12
  end
@@ -9,6 +9,9 @@ module FbGraph
9
9
  )
10
10
  end
11
11
  end
12
+ def invite!(options = {})
13
+ post options.merge(:connection => :invited)
14
+ end
12
15
  end
13
16
  end
14
- end
17
+ end
data/lib/fb_graph/node.rb CHANGED
@@ -4,12 +4,13 @@ module FbGraph
4
4
  class Node
5
5
  include Comparison
6
6
 
7
- attr_accessor :identifier, :endpoint, :access_token
7
+ attr_accessor :identifier, :endpoint, :access_token, :raw_attributes
8
8
 
9
- def initialize(identifier, options = {})
9
+ def initialize(identifier, attributes = {})
10
10
  @identifier = identifier
11
11
  @endpoint = File.join(ROOT_URL, identifier.to_s)
12
- @access_token = options[:access_token]
12
+ @access_token = attributes[:access_token]
13
+ @raw_attributes = attributes
13
14
  @cached_collections = {}
14
15
  end
15
16
 
@@ -71,6 +71,9 @@ module FbGraph
71
71
  @@attributes[:raw].each do |key|
72
72
  self.send :"#{key}=", attributes[key]
73
73
  end
74
+
75
+ self.link ||= "https://www.facebook.com/#{username || identifier}"
76
+
74
77
  @@attributes[:symbols].each do |key|
75
78
  self.send :"#{key}=", []
76
79
  if attributes[key]
@@ -9,19 +9,151 @@ describe FbGraph::Application do
9
9
  :id => '12345',
10
10
  :name => 'FbGraph',
11
11
  :description => 'Owsome Facebook Graph Wrapper',
12
+ :canvas_name => 'fb_graph',
12
13
  :category => 'Programming',
14
+ :subcategory => 'Ruby',
13
15
  :link => 'http://github.com/nov/fb_graph',
16
+ :company => 'FbGraph',
14
17
  :secret => 'sec sec',
15
- :daily_active_users => '10'
18
+ :icon_url => 'http://example.com/icon.gif',
19
+ :logo_url => 'http://example.com/logo.gif',
20
+ :daily_active_users => '10',
21
+ :weekly_active_users => '5',
22
+ :monthly_active_users => '1',
23
+ :migrations => {
24
+ 'secure_stream_urls' => false,
25
+ 'expiring_offline_access_tokens' => true,
26
+ 'december_rollup' => true,
27
+ 'requires_login_secret' => false,
28
+ 'gdp_v2' => true,
29
+ 'page_hours_format' => true,
30
+ 'graph_batch_api_exception_format' => true,
31
+ 'status_checkin_perm_migration' => false
32
+ },
33
+ :namespace => 'fb_graph',
34
+ :restrictions => {
35
+ 'age_distribution' => {
36
+ 'CA,US' => '16-25'
37
+ }
38
+ },
39
+ :app_domains => [
40
+ 'example.com',
41
+ 'example.org'
42
+ ],
43
+ :auth_dialog_data_help_url => 'http://example.com/help/',
44
+ :auth_dialog_description => 'Authorize this app',
45
+ :auth_dialog_headline => "Don't think, just click",
46
+ :auth_dialog_perms_explanation => 'Trust me',
47
+ :auth_referral_user_perms => [
48
+ 'user_hometown',
49
+ 'user_activities',
50
+ 'user_online_presence'
51
+ ],
52
+ :auth_referral_default_activity_privacy => 'NONE',
53
+ :auth_referral_enabled => 1,
54
+ :auth_referral_extended_perms => [
55
+ 'status_update',
56
+ 'video_upload',
57
+ 'publish_stream'
58
+ ],
59
+ :auth_referral_response_type => 'code',
60
+ :canvas_fluid_height => false,
61
+ :canvas_fluid_width => 1,
62
+ :canvas_url => 'http://example.com/canvas/',
63
+ :contact_email => 'fb_graph@example.com',
64
+ :created_time => 1328798126,
65
+ :creator_uid => 98765,
66
+ :deauth_callback_url => 'http://example.com/death/',
67
+ :iphone_app_store_id => '4567',
68
+ :hosting_url => 'http://fb_graph.heroku.com',
69
+ :mobile_web_url => 'http://m.example.com',
70
+ :page_tab_default_name => 'fb_graph Page',
71
+ :page_tab_url => 'http://example.com/page/',
72
+ :privacy_policy_url => 'http://example.com/privacy/',
73
+ :secure_canvas_url => 'https://example.com/canvas/',
74
+ :secure_page_tab_url => 'https://example.com/page/',
75
+ :server_ip_whitelist => '127.0.0.1',
76
+ :social_discovery => 0,
77
+ :terms_of_service_url => 'http://example.com/terms/',
78
+ :user_support_email => 'fb_graph@example.org',
79
+ :user_support_url => 'http://example.com/support/',
80
+ :website_url => 'http://example.com',
81
+ :type => 'application'
16
82
  }
83
+
17
84
  app = FbGraph::Application.new(attributes.delete(:id), attributes)
18
85
  app.identifier.should == '12345'
19
86
  app.name.should == 'FbGraph'
20
87
  app.description.should == 'Owsome Facebook Graph Wrapper'
88
+ app.canvas_name.should == 'fb_graph'
21
89
  app.category.should == 'Programming'
90
+ app.subcategory.should == 'Ruby'
22
91
  app.link.should == 'http://github.com/nov/fb_graph'
92
+ app.company.should == 'FbGraph'
93
+ app.icon_url.should == 'http://example.com/icon.gif'
94
+ app.logo_url.should == 'http://example.com/logo.gif'
23
95
  app.secret.should == 'sec sec'
24
96
  app.daily_active_users.should == 10
97
+ app.weekly_active_users.should == 5
98
+ app.monthly_active_users.should == 1
99
+ app.migrations.should == {
100
+ 'secure_stream_urls' => false,
101
+ 'expiring_offline_access_tokens' => true,
102
+ 'december_rollup' => true,
103
+ 'requires_login_secret' => false,
104
+ 'gdp_v2' => true,
105
+ 'page_hours_format' => true,
106
+ 'graph_batch_api_exception_format' => true,
107
+ 'status_checkin_perm_migration' => false
108
+ }
109
+ app.namespace.should == 'fb_graph'
110
+ app.restrictions.should == {
111
+ 'age_distribution' => {
112
+ 'CA,US' => '16-25'
113
+ }
114
+ }
115
+ app.app_domains.should == [
116
+ 'example.com',
117
+ 'example.org'
118
+ ]
119
+ app.auth_dialog_data_help_url.should == 'http://example.com/help/'
120
+ app.auth_dialog_description.should == 'Authorize this app'
121
+ app.auth_dialog_headline.should == "Don't think, just click"
122
+ app.auth_dialog_perms_explanation.should == 'Trust me'
123
+ app.auth_referral_user_perms.should == [
124
+ 'user_hometown',
125
+ 'user_activities',
126
+ 'user_online_presence'
127
+ ]
128
+ app.auth_referral_default_activity_privacy.should == 'NONE'
129
+ app.auth_referral_enabled.should == true
130
+ app.auth_referral_extended_perms.should == [
131
+ 'status_update',
132
+ 'video_upload',
133
+ 'publish_stream'
134
+ ]
135
+ app.auth_referral_response_type.should == 'code'
136
+ app.canvas_fluid_height.should == false
137
+ app.canvas_fluid_width.should == true
138
+ app.canvas_url.should == 'http://example.com/canvas/'
139
+ app.contact_email.should == 'fb_graph@example.com'
140
+ app.created_time.should == 1328798126
141
+ app.creator_uid.should == 98765
142
+ app.deauth_callback_url.should == 'http://example.com/death/'
143
+ app.iphone_app_store_id.should == '4567'
144
+ app.hosting_url.should == 'http://fb_graph.heroku.com'
145
+ app.mobile_web_url.should == 'http://m.example.com'
146
+ app.page_tab_default_name.should == 'fb_graph Page'
147
+ app.page_tab_url.should == 'http://example.com/page/'
148
+ app.privacy_policy_url.should == 'http://example.com/privacy/'
149
+ app.secure_canvas_url.should == 'https://example.com/canvas/'
150
+ app.secure_page_tab_url.should == 'https://example.com/page/'
151
+ app.server_ip_whitelist.should == '127.0.0.1'
152
+ app.social_discovery.should == false
153
+ app.user_support_email.should == 'fb_graph@example.org'
154
+ app.user_support_url.should == 'http://example.com/support/'
155
+ app.website_url.should == 'http://example.com'
156
+ app.type.should == 'application'
25
157
  end
26
158
  end
27
159
 
@@ -63,4 +195,4 @@ describe FbGraph::Application do
63
195
  end
64
196
  end
65
197
  end
66
- end
198
+ end
@@ -1,12 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe FbGraph::Connections::Invited, '#invited' do
4
- it 'should return invited users as FbGraph::User' do
5
- mock_graph :get, 'smartday/invited', 'events/invited/smartday_private', :access_token => 'access_token' do
6
- users = FbGraph::Event.new('smartday', :access_token => 'access_token').invited
7
- users.each do |user|
8
- user.should be_instance_of(FbGraph::User)
3
+ describe FbGraph::Connections::Invited do
4
+ describe '#invited' do
5
+ it 'should return invited users as FbGraph::User' do
6
+ mock_graph :get, 'smartday/invited', 'events/invited/smartday_private', :access_token => 'access_token' do
7
+ users = FbGraph::Event.new('smartday', :access_token => 'access_token').invited
8
+ users.each do |user|
9
+ user.should be_instance_of(FbGraph::User)
10
+ end
9
11
  end
10
12
  end
11
13
  end
12
- end
14
+
15
+ describe '#invite!' do
16
+ let(:event) { FbGraph::Event.new('smartday', :access_token => 'access_token') }
17
+ it 'should invite a single user to an event' do
18
+ mock_graph :post, 'smartday/invited', 'true', :access_token => 'access_token', :params => {
19
+ :users => "user_id" } do
20
+ event.invite!(:users => "user_id").should be_true
21
+ end
22
+ end
23
+ end
24
+ end
@@ -10,6 +10,11 @@ describe FbGraph::Node do
10
10
  it 'should support access_token option' do
11
11
  FbGraph::Node.new('matake', :access_token => 'access_token').access_token.should == 'access_token'
12
12
  end
13
+
14
+ it 'should store raw attributes' do
15
+ attributes = {:key => :value}
16
+ FbGraph::Node.new(12345, attributes).raw_attributes.should == attributes
17
+ end
13
18
  end
14
19
 
15
20
  describe '#build_params' do
@@ -22,6 +22,18 @@ describe FbGraph::Page do
22
22
  its(:username) { should == attributes[:username] }
23
23
  its(:talking_about_count) { should == attributes[:talking_about_count] }
24
24
 
25
+ describe 'link' do
26
+ context 'when username exists' do
27
+ subject { FbGraph::Page.new(attributes[:id], attributes) }
28
+ its(:link) { should == "https://www.facebook.com/#{attributes[:username]}" }
29
+ end
30
+
31
+ context 'otherwise' do
32
+ subject { FbGraph::Page.new(attributes[:id]) }
33
+ its(:link) { should == "https://www.facebook.com/#{attributes[:id]}" }
34
+ end
35
+ end
36
+
25
37
  describe '.fetch' do
26
38
  subject do
27
39
  mock_graph :get, 'platform', 'pages/platform_public' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.11
4
+ version: 2.4.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-23 00:00:00.000000000 Z
12
+ date: 2012-05-05 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httpclient
16
- requirement: &70120463031880 !ruby/object:Gem::Requirement
16
+ requirement: &70308890886500 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.2.0.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70120463031880
24
+ version_requirements: *70308890886500
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rack-oauth2
27
- requirement: &70120458748700 !ruby/object:Gem::Requirement
27
+ requirement: &70308890885560 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.14.4
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70120458748700
35
+ version_requirements: *70308890885560
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: tzinfo
38
- requirement: &70120458748320 !ruby/object:Gem::Requirement
38
+ requirement: &70308890885020 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70120458748320
46
+ version_requirements: *70308890885020
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70120458747780 !ruby/object:Gem::Requirement
49
+ requirement: &70308890884480 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0.8'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70120458747780
57
+ version_requirements: *70308890884480
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: cover_me
60
- requirement: &70120458747260 !ruby/object:Gem::Requirement
60
+ requirement: &70308890883820 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.2.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70120458747260
68
+ version_requirements: *70308890883820
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70120458746800 !ruby/object:Gem::Requirement
71
+ requirement: &70308890883160 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '2'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70120458746800
79
+ version_requirements: *70308890883160
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: webmock
82
- requirement: &70120458746340 !ruby/object:Gem::Requirement
82
+ requirement: &70308890882480 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.6.2
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70120458746340
90
+ version_requirements: *70308890882480
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: actionpack
93
- requirement: &70120458745880 !ruby/object:Gem::Requirement
93
+ requirement: &70308890881760 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: 3.0.6
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70120458745880
101
+ version_requirements: *70308890881760
102
102
  description: A full-stack Facebook Graph API wrapper in Ruby.
103
103
  email: nov@matake.jp
104
104
  executables: []
@@ -641,7 +641,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
641
641
  version: '0'
642
642
  requirements: []
643
643
  rubyforge_project:
644
- rubygems_version: 1.8.17
644
+ rubygems_version: 1.8.12
645
645
  signing_key:
646
646
  specification_version: 3
647
647
  summary: A full-stack Facebook Graph API wrapper in Ruby.