facebook_events 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -5
- data/lib/facebook_events.rb +19 -15
- data/lib/facebook_events/version.rb +1 -1
- data/spec/facebook_events_spec.rb +9 -18
- metadata +7 -8
- data/lib/facebook_events/event.rb +0 -15
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# FacebookEvents
|
2
2
|
|
3
|
-
FacebookEvents pulls Event data from the Facebook graph for a particular user or page id. Events are returned as an array.
|
3
|
+
FacebookEvents pulls Event data from the Facebook graph for a particular user or page id. Events are returned as an array of hashes.
|
4
4
|
|
5
5
|
## Setup
|
6
6
|
|
@@ -16,11 +16,9 @@ FacebookEvents::FACEBOOK_SECRET = '###'
|
|
16
16
|
## Use
|
17
17
|
|
18
18
|
```
|
19
|
-
events = FacebookEvents.
|
20
|
-
events.list
|
21
|
-
events.list.first
|
19
|
+
events = FacebookEvents.list(facebook_id)
|
22
20
|
```
|
23
|
-
Returns an array of
|
21
|
+
Returns an array of hashes – with attributes for id, name, start_time, end_time, location, description, updated_time.
|
24
22
|
|
25
23
|
### Dependencies
|
26
24
|
|
data/lib/facebook_events.rb
CHANGED
@@ -1,20 +1,31 @@
|
|
1
1
|
class FacebookEvents
|
2
2
|
|
3
3
|
require 'mini_fb'
|
4
|
-
require 'facebook_events/event'
|
5
4
|
require "facebook_events/version"
|
6
5
|
|
7
|
-
|
8
|
-
# Requires environment variables for Facebook APP ID and APP Secret:
|
9
|
-
# FacebookEvents::FACEBOOK_APP_ID = ...
|
10
|
-
# FacebookEvents::FACEBOOK_SECRET = ...
|
11
|
-
|
12
|
-
attr_reader :facebook_id, :auth_token, :list
|
6
|
+
attr_reader :facebook_id
|
13
7
|
|
14
8
|
def initialize(facebook_id)
|
15
9
|
@facebook_id = facebook_id
|
16
10
|
@auth_token = get_auth_token
|
17
|
-
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.list(facebook_id)
|
14
|
+
facebook_resource = new(facebook_id)
|
15
|
+
events = []
|
16
|
+
event_list = facebook_resource.get_events_list(facebook_id)
|
17
|
+
event_list.each do |event|
|
18
|
+
events << facebook_resource.get_event_details(event.id)
|
19
|
+
end
|
20
|
+
events
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_events_list(facebook_id)
|
24
|
+
MiniFB.get(@auth_token, @facebook_id, :type => 'events').data
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_event_details(facebook_id)
|
28
|
+
MiniFB.get(@auth_token, facebook_id).to_hash
|
18
29
|
end
|
19
30
|
|
20
31
|
private
|
@@ -23,11 +34,4 @@ class FacebookEvents
|
|
23
34
|
MiniFB.authenticate_as_app(FACEBOOK_APP_ID, FACEBOOK_SECRET)['access_token']
|
24
35
|
end
|
25
36
|
|
26
|
-
def get_events
|
27
|
-
list = MiniFB.get(@auth_token, @facebook_id, :type => 'events').data
|
28
|
-
list.map do |e|
|
29
|
-
FacebookEvents::Event.new(MiniFB.get(@auth_token, e.id))
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
37
|
end
|
@@ -1,21 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
FACEBOOK_ID = 'AlMacInnisSportsCentre'
|
4
4
|
|
5
5
|
describe FacebookEvents do
|
6
6
|
|
7
|
-
a = FacebookEvents.new(ID)
|
8
|
-
|
9
|
-
it "has a facebook id" do
|
10
|
-
a.facebook_id.should == ID
|
11
|
-
end
|
12
|
-
|
13
|
-
it "sets up authorization" do
|
14
|
-
a.auth_token.class.should == String
|
15
|
-
end
|
16
|
-
|
17
7
|
describe "list" do
|
18
|
-
|
8
|
+
|
9
|
+
l = FacebookEvents.list(FACEBOOK_ID)
|
19
10
|
|
20
11
|
it "returns an array" do
|
21
12
|
l.class.should == Array
|
@@ -25,27 +16,27 @@ describe FacebookEvents do
|
|
25
16
|
f = l.first
|
26
17
|
|
27
18
|
it "is an Event" do
|
28
|
-
f.class.should ==
|
19
|
+
f.class.should == Hash
|
29
20
|
end
|
30
21
|
|
31
22
|
it "has a facebook id" do
|
32
|
-
f.
|
23
|
+
f['id'].should == '348500465212758'
|
33
24
|
end
|
34
25
|
|
35
26
|
it "has a name" do
|
36
|
-
f
|
27
|
+
f['name'].should == "Father's Day Fundraiser"
|
37
28
|
end
|
38
29
|
|
39
30
|
it "has a start_time" do
|
40
|
-
f
|
31
|
+
f['start_time'].should == "2012-06-16T16:00:00"
|
41
32
|
end
|
42
33
|
|
43
34
|
it "has a description" do
|
44
|
-
f
|
35
|
+
f['description'].should == "The Al MacInnis Sports Centre is hosting a fundraiser on Saturday, June 16th from 8pm - 12am. Live entertainment, hot & cold hors d\u2019oeuvres, game tables, horse shoes, door prizes. All of this will take place in heated tents with an ambience that will set the stage. Entertainment by Billy Spears, Gary Trenholm & Stephen Doiron.\n\nTickets are $40 each and can be purchased by contacting Shannon MacDougall at 631-1401. Visa & M/C accepted."
|
45
36
|
end
|
46
37
|
|
47
38
|
it "has an updated_time" do
|
48
|
-
f
|
39
|
+
f['updated_time'].should == "2012-04-27T12:13:07+0000"
|
49
40
|
end
|
50
41
|
|
51
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebook_events
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-05-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mini_fb
|
16
|
-
requirement: &
|
16
|
+
requirement: &70126897235000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.1.7
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70126897235000
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70126897234240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70126897234240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: guard-rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70126897233760 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70126897233760
|
47
47
|
description: Given a Facebook page or user id, this gem will return an array of its
|
48
48
|
events.
|
49
49
|
email:
|
@@ -60,7 +60,6 @@ files:
|
|
60
60
|
- Rakefile
|
61
61
|
- facebook_events.gemspec
|
62
62
|
- lib/facebook_events.rb
|
63
|
-
- lib/facebook_events/event.rb
|
64
63
|
- lib/facebook_events/version.rb
|
65
64
|
- spec/facebook_events_spec.rb
|
66
65
|
- spec/spec_helper.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class FacebookEvents::Event
|
2
|
-
|
3
|
-
attr_reader :facebook_id, :name, :start_time, :end_time, :location, :description, :updated_time
|
4
|
-
|
5
|
-
def initialize(event)
|
6
|
-
@facebook_id = event.id
|
7
|
-
@name = event.name
|
8
|
-
@start_time = event.start_time
|
9
|
-
@end_time = event.end_time
|
10
|
-
@location = event.location
|
11
|
-
@description = event.description
|
12
|
-
@updated_time = event.updated_time
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|