fb_graph 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -11,6 +11,7 @@ A full-stack Facebook Graph API wrapper in Ruby.
11
11
  * View RDoc on RDoc.info (http://rdoc.info/github/nov/fb_graph)
12
12
  * View Source on GitHub (http://github.com/nov/fb_graph)
13
13
  * Report Issues on GitHub (http://github.com/nov/fb_graph/issues)
14
+ * Q&A on Google Groups (https://groups.google.com/group/fb_graph)
14
15
  * Facebook fan page (http://www.facebook.com/pages/FbGraph/117513961602338)
15
16
 
16
17
  == Examples
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.1.2
data/fb_graph.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fb_graph}
8
- s.version = "1.1.1"
8
+ s.version = "1.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["nov matake"]
12
- s.date = %q{2010-12-03}
12
+ s.date = %q{2010-12-13}
13
13
  s.description = %q{A full-stack Facebook Graph API wrapper in Ruby.}
14
14
  s.email = %q{nov@matake.jp}
15
15
  s.extra_rdoc_files = [
@@ -106,6 +106,8 @@ Gem::Specification.new do |s|
106
106
  "spec/fake_json/pages/checkins/gowalla_public.json",
107
107
  "spec/fake_json/pages/insights/FbGraph_private.json",
108
108
  "spec/fake_json/pages/insights/FbGraph_public.json",
109
+ "spec/fake_json/pages/insights/page_like_adds/FbGraph_private.json",
110
+ "spec/fake_json/pages/insights/page_like_adds/day/FbGraph_private.json",
109
111
  "spec/fake_json/pages/notes/post_with_valid_access_token.json",
110
112
  "spec/fake_json/pages/platform_private.json",
111
113
  "spec/fake_json/pages/platform_public.json",
@@ -4,11 +4,21 @@ module FbGraph
4
4
  def insights(options = {})
5
5
  options[:access_token] ||= self.access_token
6
6
  options[:access_token] ||= get_access_token(options[:secret]) if respond_to?(:get_access_token)
7
- insights = self.connection(:insights, options)
7
+ insights = self.connection(:insights, options.merge(:connection_scope => connection_scope(options)))
8
8
  insights.map! do |insight|
9
9
  Insight.new(insight.delete(:id), insight.merge(:access_token => options[:access_token]))
10
10
  end
11
11
  end
12
+
13
+ private
14
+
15
+ def connection_scope(options)
16
+ if metrics = options.delete(:metrics)
17
+ File.join([metrics, options.delete(:period)].compact)
18
+ else
19
+ nil
20
+ end
21
+ end
12
22
  end
13
23
  end
14
24
  end
data/lib/fb_graph/node.rb CHANGED
@@ -63,7 +63,7 @@ module FbGraph
63
63
 
64
64
  def build_endpoint(params = {})
65
65
  _endpoint_ = if params[:connection]
66
- File.join(self.endpoint, params.delete(:connection).to_s)
66
+ File.join([self.endpoint, params.delete(:connection).to_s, params.delete(:connection_scope)].compact)
67
67
  else
68
68
  self.endpoint.dup
69
69
  end
@@ -0,0 +1,28 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "id": "117513961602338/insights/page_like_adds/day",
5
+ "name": "page_like_adds",
6
+ "period": "day",
7
+ "values": [
8
+ {
9
+ "value": 0,
10
+ "end_time": "2010-12-09T08:00:00+0000"
11
+ },
12
+ {
13
+ "value": 0,
14
+ "end_time": "2010-12-10T08:00:00+0000"
15
+ },
16
+ {
17
+ "value": 0,
18
+ "end_time": "2010-12-11T08:00:00+0000"
19
+ }
20
+ ],
21
+ "description": "Daily Likes of your Page's content (Total Count)"
22
+ }
23
+ ],
24
+ "paging": {
25
+ "previous": "https://graph.facebook.com/fbgraph/insights/page_like_adds?access_token=134145643294322%7C9b95ab3141be69aff9766c90-579612276%7C9UA_-V98QdZDfoX4MSS-DdwTFFk&since=1291547309&until=1291806509",
26
+ "next": "https://graph.facebook.com/fbgraph/insights/page_like_adds?access_token=134145643294322%7C9b95ab3141be69aff9766c90-579612276%7C9UA_-V98QdZDfoX4MSS-DdwTFFk&since=1292065709&until=1292324909"
27
+ }
28
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "id": "117513961602338/insights/page_like_adds/day",
5
+ "name": "page_like_adds",
6
+ "period": "day",
7
+ "values": [
8
+ {
9
+ "value": 1,
10
+ "end_time": "2010-12-09T08:00:00+0000"
11
+ },
12
+ {
13
+ "value": 1,
14
+ "end_time": "2010-12-10T08:00:00+0000"
15
+ },
16
+ {
17
+ "value": 1,
18
+ "end_time": "2010-12-11T08:00:00+0000"
19
+ }
20
+ ],
21
+ "description": "Daily Likes of your Page's content (Total Count)"
22
+ }
23
+ ],
24
+ "paging": {
25
+ "previous": "https://graph.facebook.com/fbgraph/insights/page_like_adds?access_token=134145643294322%7C9b95ab3141be69aff9766c90-579612276%7C9UA_-V98QdZDfoX4MSS-DdwTFFk&since=1291547309&until=1291806509",
26
+ "next": "https://graph.facebook.com/fbgraph/insights/page_like_adds?access_token=134145643294322%7C9b95ab3141be69aff9766c90-579612276%7C9UA_-V98QdZDfoX4MSS-DdwTFFk&since=1292065709&until=1292324909"
27
+ }
28
+ }
@@ -36,6 +36,63 @@ describe FbGraph::Connections::Insights, '#insights' do
36
36
  end
37
37
  end
38
38
  end
39
+
40
+ context 'when metrics is given' do
41
+ before(:all) do
42
+ fake_json(:get, 'FbGraph/insights/page_like_adds?access_token=access_token', 'pages/insights/page_like_adds/FbGraph_private')
43
+ fake_json(:get, 'FbGraph/insights/page_like_adds/day?access_token=access_token', 'pages/insights/page_like_adds/day/FbGraph_private')
44
+ end
45
+
46
+ it 'should treat metrics as connection scope' do
47
+ insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token', :metrics => 'page_like_adds')
48
+ insights.options.should == {
49
+ :connection_scope => 'page_like_adds',
50
+ :access_token => 'access_token'
51
+ }
52
+ insights.first.should == FbGraph::Insight.new(
53
+ '117513961602338/insights/page_like_adds/day',
54
+ :access_token => 'access_token',
55
+ :name => 'page_like_adds',
56
+ :description => 'Daily Likes of your Page\'s content (Total Count)',
57
+ :period => 'day',
58
+ :values => [{
59
+ :value => 0,
60
+ :end_time => '2010-12-09T08:00:00+0000'
61
+ }, {
62
+ :value => 0,
63
+ :end_time => '2010-12-10T08:00:00+0000'
64
+ }, {
65
+ :value => 0,
66
+ :end_time => '2010-12-11T08:00:00+0000'
67
+ }]
68
+ )
69
+ end
70
+
71
+ it 'should support period also' do
72
+ insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token', :metrics => 'page_like_adds', :period => 'day')
73
+ insights.options.should == {
74
+ :connection_scope => 'page_like_adds/day',
75
+ :access_token => 'access_token'
76
+ }
77
+ insights.first.should == FbGraph::Insight.new(
78
+ '117513961602338/insights/page_like_adds/day',
79
+ :access_token => 'access_token',
80
+ :name => 'page_like_adds',
81
+ :description => 'Daily Likes of your Page\'s content (Total Count)',
82
+ :period => 'day',
83
+ :values => [{
84
+ :value => 1,
85
+ :end_time => '2010-12-09T08:00:00+0000'
86
+ }, {
87
+ :value => 1,
88
+ :end_time => '2010-12-10T08:00:00+0000'
89
+ }, {
90
+ :value => 1,
91
+ :end_time => '2010-12-11T08:00:00+0000'
92
+ }]
93
+ )
94
+ end
95
+ end
39
96
  end
40
97
 
41
98
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 1
10
- version: 1.1.1
9
+ - 2
10
+ version: 1.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - nov matake
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-03 00:00:00 +09:00
18
+ date: 2010-12-13 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -221,6 +221,8 @@ files:
221
221
  - spec/fake_json/pages/checkins/gowalla_public.json
222
222
  - spec/fake_json/pages/insights/FbGraph_private.json
223
223
  - spec/fake_json/pages/insights/FbGraph_public.json
224
+ - spec/fake_json/pages/insights/page_like_adds/FbGraph_private.json
225
+ - spec/fake_json/pages/insights/page_like_adds/day/FbGraph_private.json
224
226
  - spec/fake_json/pages/notes/post_with_valid_access_token.json
225
227
  - spec/fake_json/pages/platform_private.json
226
228
  - spec/fake_json/pages/platform_public.json