fb_graph 1.6.1 → 1.6.2

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/lib/fb_graph/work.rb CHANGED
@@ -2,9 +2,10 @@ module FbGraph
2
2
  class Work
3
3
  include Comparison
4
4
 
5
- attr_accessor :employer, :location, :position, :projects, :start_date, :end_date
5
+ attr_accessor :description, :employer, :location, :position, :projects, :with, :start_date, :end_date
6
6
 
7
7
  def initialize(attributes = {})
8
+ @description = attributes[:description]
8
9
  if (employer = attributes[:employer])
9
10
  @employer = Page.new(employer.delete(:id), employer)
10
11
  end
@@ -20,6 +21,12 @@ module FbGraph
20
21
  @projects << Project.new(project.delete(:id), project)
21
22
  end
22
23
  end
24
+ @with = []
25
+ if attributes[:with]
26
+ attributes[:with].each do |user|
27
+ @with << User.new(user.delete(:id), user)
28
+ end
29
+ end
23
30
  if attributes[:start_date] && attributes[:start_date] != '0000-00'
24
31
  year, month = attributes[:start_date].split('-').collect(&:to_i)
25
32
  @start_date = if month.blank? || month == 0
data/lib/fb_graph.rb CHANGED
@@ -75,7 +75,6 @@ require 'fb_graph/page'
75
75
  require 'fb_graph/photo'
76
76
  require 'fb_graph/place'
77
77
  require 'fb_graph/post'
78
- require 'fb_graph/project'
79
78
  require 'fb_graph/status'
80
79
  require 'fb_graph/tag'
81
80
  require 'fb_graph/thread'
@@ -83,4 +82,7 @@ require 'fb_graph/user'
83
82
  require 'fb_graph/test_user' # Load after FbGraph::User
84
83
  require 'fb_graph/video'
85
84
 
85
+ require 'fb_graph/klass'
86
+ require 'fb_graph/project'
87
+
86
88
  require 'fb_graph/query'
@@ -1,72 +1,40 @@
1
1
  {
2
- "attire":
3
- "Casual",
4
- "category":
5
- "Bar",
6
- "culinary_team":
7
- "Team FbGraph!",
8
- "general_manager":
9
- "Nov Matake",
10
- "hours":
11
- {
12
- "mon_1_open":
13
- 378000,
14
- "mon_2_close":
15
- 406800
2
+ "id": "196723247025808",
3
+ "name": "Local Business Sample",
4
+ "picture": "http:\/\/b.static.ak.fbcdn.net\/rsrc.php\/v1\/y0\/r\/XsEg9L6Ie5_.jpg",
5
+ "link": "http:\/\/www.facebook.com\/pages\/Local-Business-Sample\/196723247025808",
6
+ "category": "Bar",
7
+ "location": {
8
+ "street": "\u65b0\u7530\u8fba",
9
+ "city": "Kyoto",
10
+ "country": "Japan",
11
+ "zip": "513001"
16
12
  },
17
- "id":
18
- "196723247025808",
19
- "link":
20
- "http://www.facebook.com/pages/Local-Business-Sample/196723247025808",
21
- "location":
22
- {
23
- "city":
24
- "Kyoto",
25
- "country":
26
- "Japan",
27
- "street":
28
- "\u65b0\u7530\u8fba",
29
- "zip":
30
- "513001"
13
+ "parking": {
14
+ "street": 1,
15
+ "valet": 1
31
16
  },
32
- "name":
33
- "Local Business Sample",
34
- "parking":
35
- {
36
- "street":
37
- 1,
38
- "valet":
39
- 1
17
+ "public_transit": "30 min from Kyoto St.",
18
+ "hours": {
19
+ "mon_1_open": 378000,
20
+ "mon_2_close": 406800
40
21
  },
41
- "payment_options":
42
- {
43
- "amex":
44
- 1,
45
- "mastercard":
46
- 1,
47
- "visa":
48
- 1
22
+ "attire": "Casual",
23
+ "payment_options": {
24
+ "visa": 1,
25
+ "amex": 1,
26
+ "mastercard": 1
49
27
  },
50
- "phone":
51
- "1234567890",
52
- "picture":
53
- "http://b.static.ak.fbcdn.net/rsrc.php/v1/y0/r/XsEg9L6Ie5_.jpg",
54
- "price_range":
55
- "$ (0-10)",
56
- "public_transit":
57
- "30 min from Kyoto St.",
58
- "restaurant_services":
59
- {
60
- "groups":
61
- 1,
62
- "reserve":
63
- 1
28
+ "culinary_team": "Team FbGraph!",
29
+ "general_manager": "Nov Matake",
30
+ "price_range": "$ (0-10)",
31
+ "restaurant_services": {
32
+ "reserve": 1,
33
+ "groups": 1
64
34
  },
65
- "restaurant_specialties":
66
- {
67
- "dinner":
68
- 1,
69
- "drinks":
70
- 1
71
- }
35
+ "restaurant_specialties": {
36
+ "dinner": 1,
37
+ "drinks": 1
38
+ },
39
+ "phone": "1234567890"
72
40
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "id": "100473570038576",
3
+ "name": "Movie",
4
+ "picture": "http:\/\/b.static.ak.fbcdn.net\/rsrc.php\/v1\/y0\/r\/XsEg9L6Ie5_.jpg",
5
+ "link": "http:\/\/www.facebook.com\/pages\/Movie\/100473570038576",
6
+ "category": "Movie",
7
+ "genre": "Fiction",
8
+ "starring": "5 star",
9
+ "screenplay_by": "Nov Matake",
10
+ "directed_by": "Nov Matake",
11
+ "produced_by": "Nov Matake",
12
+ "studio": "Pikusaa",
13
+ "plot_outline": "Outline",
14
+ "written_by": "Nov Matake"
15
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "id": "100473570038576",
3
+ "name": "Movie",
4
+ "picture": "http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/y0\/r\/XsEg9L6Ie5_.jpg",
5
+ "link": "http:\/\/www.facebook.com\/pages\/Movie\/100473570038576",
6
+ "category": "Musician\/band",
7
+ "genre": "Rock",
8
+ "band_members": "Nov Matake",
9
+ "current_location": "Tokyo",
10
+ "record_label": "Sony",
11
+ "booking_agent": "Agent",
12
+ "press_contact": "Press contact",
13
+ "artists_we_like": "Also likes",
14
+ "influences": "Influences",
15
+ "band_interests": "Band interests"
16
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "id": "100473570038576",
3
+ "name": "Actor",
4
+ "picture": "http:\/\/b.static.ak.fbcdn.net\/rsrc.php\/v1\/y0\/r\/XsEg9L6Ie5_.jpg",
5
+ "link": "http:\/\/www.facebook.com\/pages\/Actor\/100473570038576",
6
+ "category": "Actor\/director",
7
+ "bio": "bio",
8
+ "birthday": "01/01/1980",
9
+ "affiliation": "affiliation",
10
+ "personal_info": "personal info",
11
+ "personal_interests": "personal interest"
12
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "id": "100473570038576",
3
+ "name": "Software Sample",
4
+ "picture": "http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/y0\/r\/XsEg9L6Ie5_.jpg",
5
+ "link": "http:\/\/www.facebook.com\/pages\/Organization-Sample\/100473570038576",
6
+ "category": "Software",
7
+ "founded": "1980",
8
+ "mission": "mission",
9
+ "products": "Super Car",
10
+ "release_date": "1980-10-1",
11
+ "awards": "award1\naward2",
12
+ "built": "Since 1980",
13
+ "features": "feature1\nfeature2",
14
+ "mpg": "MPG"
15
+ }
@@ -0,0 +1,60 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+
3
+ describe FbGraph::Page do
4
+ context 'for local_business category' do
5
+ before do
6
+ fake_json(:get, 'local_business', 'pages/categories/local_business')
7
+ end
8
+
9
+ let(:page) { FbGraph::Page.new('local_business').fetch }
10
+ subject { page }
11
+
12
+ [
13
+ :attire,
14
+ :culinary_team,
15
+ :general_manager,
16
+ :link,
17
+ :phone,
18
+ :price_range,
19
+ :public_transit
20
+ ].each do |key|
21
+ its(key) { should be_instance_of String }
22
+ end
23
+
24
+ [
25
+ :parking,
26
+ :payment_options,
27
+ :restaurant_services,
28
+ :restaurant_specialties
29
+ ].each do |key|
30
+ its(key) { should be_instance_of Array }
31
+ describe key do
32
+ it 'should be an Array of Symbol' do
33
+ page.send(key).should_not be_blank
34
+ page.send(key).all? do |value|
35
+ value.should be_instance_of Symbol
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ its(:hours) { should be_instance_of Hash }
42
+ its(:hours) do
43
+ should == {
44
+ :mon => [
45
+ {:open => Time.parse('Thu Jan 01 09:00:00 UTC 1970')},
46
+ {:close => Time.parse('Thu Jan 01 17:00:00 UTC 1970')}
47
+ ]
48
+ }
49
+ end
50
+
51
+ its(:location) do
52
+ should == FbGraph::Venue.new(
53
+ :street => '新田辺',
54
+ :city => 'Kyoto',
55
+ :country => 'Japan',
56
+ :zip => '513001'
57
+ )
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,25 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+
3
+ describe FbGraph::Page do
4
+ context 'for people category' do
5
+ before do
6
+ fake_json(:get, 'movie', 'pages/categories/movie')
7
+ end
8
+
9
+ let(:page) { FbGraph::Page.new('movie').fetch }
10
+ subject { page }
11
+
12
+ [
13
+ :directed_by,
14
+ :genre,
15
+ :plot_outline,
16
+ :produced_by,
17
+ :screenplay_by,
18
+ :starring,
19
+ :studio,
20
+ :written_by
21
+ ].each do |key|
22
+ its(key) { should be_instance_of String }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+
3
+ describe FbGraph::Page do
4
+ context 'for music category' do
5
+ before do
6
+ fake_json(:get, 'music', 'pages/categories/music')
7
+ end
8
+
9
+ let(:page) { FbGraph::Page.new('music').fetch }
10
+ subject { page }
11
+
12
+ [
13
+ :artists_we_like,
14
+ :band_interests,
15
+ :band_members,
16
+ :booking_agent,
17
+ :current_location,
18
+ :influences,
19
+ :press_contact,
20
+ :record_label
21
+ ].each do |key|
22
+ its(key) { should be_instance_of String }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+
3
+ describe FbGraph::Page do
4
+ context 'for person category' do
5
+ before do
6
+ fake_json(:get, 'person', 'pages/categories/person')
7
+ end
8
+
9
+ let(:page) { FbGraph::Page.new('person').fetch }
10
+ subject { page }
11
+
12
+ [
13
+ :affiliation,
14
+ :bio,
15
+ :personal_info,
16
+ :personal_interests
17
+ ].each do |key|
18
+ its(key) { should be_instance_of String }
19
+ end
20
+
21
+ its(:birthday) { should == Date.new(1980, 1, 1) }
22
+ end
23
+ end
@@ -0,0 +1,36 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+
3
+ describe FbGraph::Page do
4
+ context 'for product category' do
5
+ before do
6
+ fake_json(:get, 'product', 'pages/categories/product')
7
+ end
8
+
9
+ let(:page) { FbGraph::Page.new('product').fetch }
10
+ subject { page }
11
+
12
+ [
13
+ :awards,
14
+ :features,
15
+ :link,
16
+ :mission,
17
+ :mpg,
18
+ :picture,
19
+ :products
20
+ ].each do |key|
21
+ its(key) { should be_instance_of String }
22
+ end
23
+
24
+ its(:built) { should == 'Since 1980' }
25
+ its(:founded) { should == '1980' }
26
+ its(:release_date) { should == Date.parse('Wed, 01 Oct 1980') }
27
+
28
+ context 'when valid date format' do
29
+ subject do
30
+ FbGraph::Page.new('12345', :built => 'May 1980', :founded => 'Oct 1980')
31
+ end
32
+ its(:built) { should == Date.parse('Thu, 01 May 1980') }
33
+ its(:founded) { should == Date.parse('Wed, 01 Oct 1980') }
34
+ end
35
+ end
36
+ end
@@ -1,60 +1,42 @@
1
1
  require File.join(File.dirname(__FILE__), '../spec_helper')
2
2
 
3
- describe FbGraph::Page, '.new' do
4
- it 'should setup all supported attributes' do
5
- attributes = {
6
- :id => '19292868552',
7
- :name => 'Facebook Platform',
8
- :founded => 'May 2007',
3
+ describe FbGraph::Page do
4
+ let(:attributes) do
5
+ {
6
+ :id => '19292868552',
9
7
  :category => 'Technology',
10
- :username => 'platform',
11
- :mission => 'To make the web more open and social.',
12
- :products => "Facebook Application Programming Interface (API)\nFacebook Query Language (FQL)\nFacebook Markup Language (FBML)\nFacebook JavaScript (FBJS)\nFacebook Connect\n",
13
- :likes => 578246,
14
- :company_overview => 'Facebook Platform enables anyone to build social applications on Facebook and the web.',
15
- :link => 'http://www.facebook.com/platform',
16
- :picture => 'http://profile.ak.fbcdn.net/profile-ak-snc1/object3/1566/8/s19292868552_1660.jpg',
17
- :website => 'http://developers.facebook.com'
8
+ :likes => 578246,
9
+ :name => 'Facebook Platform',
10
+ :username => 'platform'
18
11
  }
19
- page = FbGraph::Page.new(attributes.delete(:id), attributes)
20
- page.identifier.should == '19292868552'
21
- page.name.should == 'Facebook Platform'
22
- page.founded.should == Date.new(2007, 5)
23
- page.category.should == 'Technology'
24
- page.username.should == 'platform'
25
- page.mission.should == 'To make the web more open and social.'
26
- page.products.should == "Facebook Application Programming Interface (API)\nFacebook Query Language (FQL)\nFacebook Markup Language (FBML)\nFacebook JavaScript (FBJS)\nFacebook Connect\n"
27
- page.like_count.should == 578246
28
- page.company_overview.should == 'Facebook Platform enables anyone to build social applications on Facebook and the web.'
29
- page.link.should == 'http://www.facebook.com/platform'
30
- page.picture.should == 'https://graph.facebook.com/19292868552/picture' # use connection
31
- page.website.should == 'http://developers.facebook.com'
32
- page.websites.should == ['http://developers.facebook.com']
33
12
  end
34
-
35
- it 'should allow invalid date as founded' do
36
- page = FbGraph::Page.new(12345, :founded => "2004")
37
- page.founded.should == Date.new(2004, 1, 1)
13
+ subject do
14
+ FbGraph::Page.new(attributes[:id], attributes)
38
15
  end
39
16
 
40
- it 'should allow invalid date as release_date' do
41
- page1 = FbGraph::Page.new(12345, :release_date => "2010-04-23")
42
- page1.release_date.should == Date.new(2010, 4, 23)
43
- page2 = FbGraph::Page.new(12345, :release_date => "someday")
44
- page2.release_date.should == 'someday'
45
- end
46
- end
17
+ its(:identifier) { should == attributes[:id] }
18
+ its(:category) { should == attributes[:category] }
19
+ its(:like_count) { should == attributes[:likes] }
20
+ its(:name) { should == attributes[:name] }
21
+ its(:username) { should == attributes[:username] }
47
22
 
48
- describe FbGraph::Page, '.fetch' do
49
- before do
50
- fake_json(:get, 'platform', 'pages/platform_public')
51
- fake_json(:get, 'platform?access_token=access_token', 'pages/platform_private')
52
- end
23
+ describe '.fetch' do
24
+ before do
25
+ fake_json(:get, 'platform', 'pages/platform_public')
26
+ fake_json(:get, 'platform?access_token=access_token', 'pages/platform_private')
27
+ end
28
+
29
+ context 'when access_token is given' do
30
+ subject { FbGraph::Page.fetch('platform') }
31
+ its(:identifier) { should == '19292868552' }
32
+ its(:name) { should == 'Facebook Platform' }
33
+ its(:category) { should == 'Technology' }
34
+ its(:like_count) { should == 578214 }
35
+ end
53
36
 
54
- it 'should get page attributes' do
55
- page = FbGraph::Page.fetch('platform')
56
- page.identifier.should == '19292868552'
57
- page.name.should == 'Facebook Platform'
58
- page.category.should == 'Technology'
37
+ context 'otherwise' do
38
+ subject { FbGraph::Page.fetch('platform', :access_token => 'access_token') }
39
+ its(:like_count) { should == 578214 }
40
+ end
59
41
  end
60
42
  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: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 6
9
- - 1
10
- version: 1.6.1
9
+ - 2
10
+ version: 1.6.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - nov matake
@@ -204,14 +204,14 @@ files:
204
204
  - lib/fb_graph/friend_list.rb
205
205
  - lib/fb_graph/group.rb
206
206
  - lib/fb_graph/insight.rb
207
+ - lib/fb_graph/klass.rb
207
208
  - lib/fb_graph/link.rb
208
209
  - lib/fb_graph/location.rb
209
210
  - lib/fb_graph/message.rb
210
211
  - lib/fb_graph/node.rb
211
212
  - lib/fb_graph/note.rb
212
213
  - lib/fb_graph/page.rb
213
- - lib/fb_graph/page/categories.rb
214
- - lib/fb_graph/page/categories/local_business.rb
214
+ - lib/fb_graph/page/category_attributes.rb
215
215
  - lib/fb_graph/photo.rb
216
216
  - lib/fb_graph/place.rb
217
217
  - lib/fb_graph/post.rb
@@ -249,6 +249,10 @@ files:
249
249
  - spec/fake_json/events/noreply/smartday_private.json
250
250
  - spec/fake_json/groups/members/emacs_private.json
251
251
  - spec/fake_json/pages/categories/local_business.json
252
+ - spec/fake_json/pages/categories/movie.json
253
+ - spec/fake_json/pages/categories/music.json
254
+ - spec/fake_json/pages/categories/person.json
255
+ - spec/fake_json/pages/categories/product.json
252
256
  - spec/fake_json/pages/checkins/gowalla_private.json
253
257
  - spec/fake_json/pages/checkins/gowalla_public.json
254
258
  - spec/fake_json/pages/insights/FbGraph_private.json
@@ -400,7 +404,11 @@ files:
400
404
  - spec/fb_graph/message_spec.rb
401
405
  - spec/fb_graph/node_spec.rb
402
406
  - spec/fb_graph/note_spec.rb
403
- - spec/fb_graph/page/categories/local_business_spec.rb
407
+ - spec/fb_graph/page/local_business_spec.rb
408
+ - spec/fb_graph/page/movie_spec.rb
409
+ - spec/fb_graph/page/music_spec.rb
410
+ - spec/fb_graph/page/person_spec.rb
411
+ - spec/fb_graph/page/product_spec.rb
404
412
  - spec/fb_graph/page_spec.rb
405
413
  - spec/fb_graph/photo_spec.rb
406
414
  - spec/fb_graph/place_spec.rb
@@ -521,7 +529,11 @@ test_files:
521
529
  - spec/fb_graph/message_spec.rb
522
530
  - spec/fb_graph/node_spec.rb
523
531
  - spec/fb_graph/note_spec.rb
524
- - spec/fb_graph/page/categories/local_business_spec.rb
532
+ - spec/fb_graph/page/local_business_spec.rb
533
+ - spec/fb_graph/page/movie_spec.rb
534
+ - spec/fb_graph/page/music_spec.rb
535
+ - spec/fb_graph/page/person_spec.rb
536
+ - spec/fb_graph/page/product_spec.rb
525
537
  - spec/fb_graph/page_spec.rb
526
538
  - spec/fb_graph/photo_spec.rb
527
539
  - spec/fb_graph/place_spec.rb
@@ -1,38 +0,0 @@
1
- module FbGraph
2
- class Page
3
- module Categories
4
- module LocalBusiness
5
- attr_accessor :attire, :culinary_team, :general_manager, :hours, :parking, :payment_options, :phone, :price_range, :public_transit, :restaurant_services, :restaurant_specialties
6
-
7
- def self.included(klass)
8
- klass.alias_method_chain :initialize, :category_specific_attributes
9
- end
10
-
11
- def initialize_with_category_specific_attributes(identifier, attributes = {})
12
- initialize_without_category_specific_attributes identifier, attributes
13
- [:attire, :culinary_team, :general_manager, :phone, :price_range, :public_transit].each do |key|
14
- self.send :"#{key}=", attributes[key]
15
- end
16
- [:parking, :payment_options, :restaurant_services, :restaurant_specialties].each do |key|
17
- self.send :"#{key}=", []
18
- if attributes[key]
19
- self.send :"#{key}=", attributes[key].keys.collect(&:to_sym)
20
- end
21
- end
22
- @hours = {}
23
- if attributes[:hours]
24
- utc_beginning_of_day = Time.now.utc.beginning_of_day
25
- attributes[:hours].each do |key, value|
26
- date, index, mode = key.split('_')
27
- index = index.to_i - 1
28
- date, mode = date.to_sym, mode.to_sym
29
- @hours[date] ||= []
30
- @hours[date][index] ||= {}
31
- @hours[date][index][mode] = value.since(utc_beginning_of_day)
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,9 +0,0 @@
1
- Dir[File.dirname(__FILE__) + '/categories/*.rb'].each do |file|
2
- require file
3
- end
4
-
5
- module FbGraph
6
- class Page
7
- include Categories::LocalBusiness
8
- end
9
- end
@@ -1,34 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../../spec_helper')
2
-
3
- describe FbGraph::Page::Categories::LocalBusiness do
4
- before do
5
- fake_json(:get, 'local_business', 'pages/categories/local_business')
6
- end
7
- let(:page) { FbGraph::Page.new('local_business').fetch }
8
- subject { page }
9
-
10
- [:attire, :culinary_team, :general_manager, :phone, :price_range, :public_transit].each do |key|
11
- its(key) { should be_instance_of String }
12
- end
13
-
14
- [:parking, :payment_options, :restaurant_services, :restaurant_specialties].each do |key|
15
- its(key) { should be_instance_of Array }
16
- describe key do
17
- it 'should be an Array of Symbol' do
18
- page.send(key).all? do |value|
19
- value.should be_instance_of Symbol
20
- end
21
- end
22
- end
23
- end
24
-
25
- its(:hours) { should be_instance_of Hash }
26
- its(:hours) do
27
- should == {
28
- :mon => [
29
- {:open => Time.parse('Wed Mar 23 09:00:00 UTC 2011')},
30
- {:close => Time.parse('Wed Mar 23 17:00:00 UTC 2011')}
31
- ]
32
- }
33
- end
34
- end