fb_graph 1.2.1 → 1.2.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.
Files changed (42) hide show
  1. data/VERSION +1 -1
  2. data/fb_graph.gemspec +1 -1
  3. data/lib/fb_graph/album.rb +3 -3
  4. data/lib/fb_graph/application.rb +1 -1
  5. data/lib/fb_graph/auth.rb +4 -4
  6. data/lib/fb_graph/checkin.rb +6 -6
  7. data/lib/fb_graph/comment.rb +2 -2
  8. data/lib/fb_graph/connection.rb +1 -1
  9. data/lib/fb_graph/connections/accounts.rb +1 -1
  10. data/lib/fb_graph/connections/activities.rb +1 -1
  11. data/lib/fb_graph/connections/albums.rb +1 -1
  12. data/lib/fb_graph/connections/attending.rb +1 -1
  13. data/lib/fb_graph/connections/checkins.rb +9 -2
  14. data/lib/fb_graph/connections/comments.rb +3 -3
  15. data/lib/fb_graph/connections/declined.rb +1 -1
  16. data/lib/fb_graph/connections/events.rb +1 -1
  17. data/lib/fb_graph/connections/feed.rb +1 -1
  18. data/lib/fb_graph/connections/links.rb +1 -1
  19. data/lib/fb_graph/connections/maybe.rb +1 -1
  20. data/lib/fb_graph/connections/notes.rb +1 -1
  21. data/lib/fb_graph/connections/photos.rb +1 -1
  22. data/lib/fb_graph/connections/subscriptions.rb +2 -2
  23. data/lib/fb_graph/education.rb +4 -4
  24. data/lib/fb_graph/event.rb +2 -2
  25. data/lib/fb_graph/group.rb +2 -2
  26. data/lib/fb_graph/insight.rb +1 -1
  27. data/lib/fb_graph/link.rb +3 -3
  28. data/lib/fb_graph/node.rb +6 -6
  29. data/lib/fb_graph/note.rb +3 -3
  30. data/lib/fb_graph/page.rb +2 -2
  31. data/lib/fb_graph/photo.rb +5 -5
  32. data/lib/fb_graph/post.rb +6 -6
  33. data/lib/fb_graph/query.rb +1 -1
  34. data/lib/fb_graph/searchable/result.rb +1 -1
  35. data/lib/fb_graph/searchable.rb +5 -5
  36. data/lib/fb_graph/status.rb +4 -4
  37. data/lib/fb_graph/subscription.rb +1 -1
  38. data/lib/fb_graph/user.rb +4 -4
  39. data/lib/fb_graph/video.rb +3 -3
  40. data/lib/fb_graph/work.rb +3 -3
  41. data/lib/fb_graph.rb +3 -3
  42. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.2.2
data/fb_graph.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fb_graph}
8
- s.version = "1.2.1"
8
+ s.version = "1.2.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"]
@@ -104,9 +104,9 @@ module FbGraph
104
104
  super
105
105
  @from = if (from = attributes[:from])
106
106
  if from[:category]
107
- FbGraph::Page.new(from.delete(:id), from)
107
+ Page.new(from.delete(:id), from)
108
108
  else
109
- FbGraph::User.new(from.delete(:id), from)
109
+ User.new(from.delete(:id), from)
110
110
  end
111
111
  end
112
112
  @name = attributes[:name]
@@ -130,7 +130,7 @@ module FbGraph
130
130
  end
131
131
 
132
132
  # cached connection
133
- @_comments_ = FbGraph::Collection.new(attributes[:comments])
133
+ @_comments_ = Collection.new(attributes[:comments])
134
134
  end
135
135
  end
136
136
  end
@@ -45,7 +45,7 @@ module FbGraph
45
45
  # # => Array of FbGraph::Subscription
46
46
  def get_access_token(secret = nil)
47
47
  self.secret ||= secret
48
- auth = FbGraph::Auth.new(self.identifier, self.secret)
48
+ auth = Auth.new(self.identifier, self.secret)
49
49
  response_string = auth.client.request(:post, auth.client.access_token_url, {
50
50
  :client_id => self.identifier,
51
51
  :client_secret => self.secret,
data/lib/fb_graph/auth.rb CHANGED
@@ -15,13 +15,13 @@ module FbGraph
15
15
  # auth = FbGraph::Auth.new(APP_ID, APP_SECRET, :cookie => {..})
16
16
  # auth.access_token # already parsed
17
17
  class Auth
18
- class VerificationFailed < FbGraph::Exception; end
18
+ class VerificationFailed < Exception; end
19
19
 
20
20
  attr_accessor :client, :access_token, :user
21
21
 
22
22
  def initialize(client_id, client_secret, options = {})
23
23
  @client = OAuth2::Client.new(client_id, client_secret, options.merge(
24
- :site => FbGraph::ROOT_URL
24
+ :site => ROOT_URL
25
25
  ))
26
26
  if options[:cookie].present?
27
27
  from_cookie(options[:cookie])
@@ -29,7 +29,7 @@ module FbGraph
29
29
  end
30
30
 
31
31
  def from_cookie(cookie)
32
- cookie = FbGraph::Auth::Cookie.parse(self.client, cookie)
32
+ cookie = Auth::Cookie.parse(self.client, cookie)
33
33
  expires_in = unless cookie[:expires].zero?
34
34
  cookie[:expires] - Time.now.to_i
35
35
  end
@@ -39,7 +39,7 @@ module FbGraph
39
39
  cookie[:refresh_token],
40
40
  expires_in
41
41
  )
42
- self.user = FbGraph::User.new(cookie[:uid], :access_token => self.access_token)
42
+ self.user = User.new(cookie[:uid], :access_token => self.access_token)
43
43
  self
44
44
  end
45
45
  end
@@ -7,24 +7,24 @@ module FbGraph
7
7
  def initialize(identifier, attributes = {})
8
8
  super
9
9
  if (from = attributes[:from])
10
- @from = FbGraph::User.new(from.delete(:id), from)
10
+ @from = User.new(from.delete(:id), from)
11
11
  end
12
12
  @tags = []
13
13
  if (tags = attributes[:tags])
14
- FbGraph::Collection.new(tags).each do |user|
15
- @tags << FbGraph::User.new(user.delete(:id), user)
14
+ Collection.new(tags).each do |user|
15
+ @tags << User.new(user.delete(:id), user)
16
16
  end
17
17
  end
18
18
  if (place = attributes[:place])
19
- @place = FbGraph::Page.new(place.delete(:id), place)
19
+ @place = Page.new(place.delete(:id), place)
20
20
  end
21
21
  @message = attributes[:message]
22
22
  if (coordinates = attributes[:coordinates])
23
23
  # NOTE: it seems this attributes isn't used now
24
- @coordinates = FbGraph::Venue.new(location)
24
+ @coordinates = Venue.new(location)
25
25
  end
26
26
  if (application = attributes[:application])
27
- @application = FbGraph::Application.new(application.delete(:id), application)
27
+ @application = Application.new(application.delete(:id), application)
28
28
  end
29
29
  if (created_time = attributes.delete(:created_time))
30
30
  @created_time = Time.parse(created_time).utc
@@ -8,9 +8,9 @@ module FbGraph
8
8
  super
9
9
  if (from = attributes[:from])
10
10
  @from = if from[:category]
11
- FbGraph::Page.new(from.delete(:id), from)
11
+ Page.new(from.delete(:id), from)
12
12
  else
13
- FbGraph::User.new(from.delete(:id), from)
13
+ User.new(from.delete(:id), from)
14
14
  end
15
15
  end
16
16
  @message = attributes[:message]
@@ -6,7 +6,7 @@ module FbGraph
6
6
  @owner = owner
7
7
  @options = options
8
8
  @connection = connection
9
- @collection = options.delete(:collection) || FbGraph::Collection.new
9
+ @collection = options.delete(:collection) || Collection.new
10
10
  replace collection
11
11
  end
12
12
 
@@ -50,7 +50,7 @@ module FbGraph
50
50
  accounts = self.connection(:accounts, options)
51
51
  accounts.map! do |account|
52
52
  account[:access_token] ||= options[:access_token] || self.access_token
53
- FbGraph::Page.new(account.delete(:id), account)
53
+ Page.new(account.delete(:id), account)
54
54
  end
55
55
  end
56
56
  end
@@ -4,7 +4,7 @@ module FbGraph
4
4
  def activities(options = {})
5
5
  activities = self.connection(:activities, options)
6
6
  activities.map! do |activity|
7
- FbGraph::Page.new(activity.delete(:id), activity.merge(
7
+ Page.new(activity.delete(:id), activity.merge(
8
8
  :access_token => options[:access_token] || self.access_token
9
9
  ))
10
10
  end
@@ -86,7 +86,7 @@ module FbGraph
86
86
  end
87
87
 
88
88
  def album!(options = {})
89
- album = post(options.merge(:connection => 'albums'))
89
+ album = post(options.merge(:connection => :albums))
90
90
  Album.new(album.delete(:id), options.merge(album).merge(
91
91
  :access_token => options[:access_token] || self.access_token
92
92
  ))
@@ -11,7 +11,7 @@ module FbGraph
11
11
  end
12
12
 
13
13
  def attending!(options = {})
14
- post(options.merge(:connection => 'attending'))
14
+ post(options.merge(:connection => :attending))
15
15
  end
16
16
  end
17
17
  end
@@ -12,11 +12,18 @@ module FbGraph
12
12
  def checkins(options = {})
13
13
  checkins = self.connection(:checkins, options)
14
14
  checkins.map! do |checkin|
15
- FbGraph::Checkin.new(checkin.delete(:id), checkin.merge(
15
+ Checkin.new(checkin.delete(:id), checkin.merge(
16
16
  :access_token => options[:access_token] || self.access_token
17
17
  ))
18
18
  end
19
19
  end
20
+
21
+ def checkin!(options = {})
22
+ checkin = post(options.merge(:connection => :checkins))
23
+ Checkin.new(checkin.delete(:id), options.merge(checkin).merge(
24
+ :access_token => options[:access_token] || self.access_token
25
+ ))
26
+ end
20
27
  end
21
28
  end
22
- end
29
+ end
@@ -15,7 +15,7 @@ module FbGraph
15
15
  end
16
16
 
17
17
  def comment!(options = {})
18
- comment = post(options.merge(:connection => 'comments'))
18
+ comment = post(options.merge(:connection => :comments))
19
19
  Comment.new(comment.delete(:id), options.merge(comment).merge(
20
20
  :access_token => options[:access_token] || self.access_token
21
21
  ))
@@ -25,11 +25,11 @@ module FbGraph
25
25
  # the context of getting likes is User, but the context of posting like is not user.
26
26
  # posting like is always in same context with comment!
27
27
  def like!(options = {})
28
- post(options.merge(:connection => 'likes'))
28
+ post(options.merge(:connection => :likes))
29
29
  end
30
30
 
31
31
  def unlike!(options = {})
32
- destroy(options.merge(:connection => 'likes'))
32
+ destroy(options.merge(:connection => :likes))
33
33
  end
34
34
  end
35
35
  end
@@ -11,7 +11,7 @@ module FbGraph
11
11
  end
12
12
 
13
13
  def declined!(options = {})
14
- post(options.merge(:connection => 'declined'))
14
+ post(options.merge(:connection => :declined))
15
15
  end
16
16
  end
17
17
  end
@@ -11,7 +11,7 @@ module FbGraph
11
11
  end
12
12
 
13
13
  def event!(options = {})
14
- event = post(options.merge(:connection => 'events'))
14
+ event = post(options.merge(:connection => :events))
15
15
  Event.new(event.delete(:id), options.merge(event).merge(
16
16
  :access_token => options[:access_token] || self.access_token
17
17
  ))
@@ -80,7 +80,7 @@ module FbGraph
80
80
  # :message => 'Updating via FbGraph'
81
81
  # )
82
82
  def feed!(options = {})
83
- post = post(options.merge(:connection => 'feed'))
83
+ post = post(options.merge(:connection => :feed))
84
84
  Post.new(post.delete(:id), options.merge(post).merge(
85
85
  :access_token => options[:access_token] || self.access_token
86
86
  ))
@@ -11,7 +11,7 @@ module FbGraph
11
11
  end
12
12
 
13
13
  def link!(options = {})
14
- link = post(options.merge(:connection => 'links'))
14
+ link = post(options.merge(:connection => :links))
15
15
  Link.new(link.delete(:id), options.merge(link).merge(
16
16
  :access_token => options[:access_token] || self.access_token
17
17
  ))
@@ -11,7 +11,7 @@ module FbGraph
11
11
  end
12
12
 
13
13
  def maybe!(options = {})
14
- post(options.merge(:connection => 'maybe'))
14
+ post(options.merge(:connection => :maybe))
15
15
  end
16
16
  end
17
17
  end
@@ -11,7 +11,7 @@ module FbGraph
11
11
  end
12
12
 
13
13
  def note!(options = {})
14
- note = post(options.merge(:connection => 'notes'))
14
+ note = post(options.merge(:connection => :notes))
15
15
  Note.new(note.delete(:id), options.merge(note).merge(
16
16
  :access_token => options[:access_token] || self.access_token
17
17
  ))
@@ -11,7 +11,7 @@ module FbGraph
11
11
  end
12
12
 
13
13
  def photo!(options = {})
14
- photo = post(options.merge(:connection => 'photos'))
14
+ photo = post(options.merge(:connection => :photos))
15
15
  Photo.new(photo.delete(:id), options.merge(photo).merge(
16
16
  :access_token => options[:access_token] || self.access_token
17
17
  ))
@@ -30,7 +30,7 @@ module FbGraph
30
30
  # => Array of FbGraph::Subscriptions
31
31
  def subscribe!(options = {})
32
32
  options[:access_token] ||= self.access_token || get_access_token(options[:secret])
33
- post(options.merge(:connection => 'subscriptions'))
33
+ post(options.merge(:connection => :subscriptions))
34
34
  end
35
35
 
36
36
  # == Subscribe
@@ -46,7 +46,7 @@ module FbGraph
46
46
  # => Array of FbGraph::Subscriptions
47
47
  def unsubscribe!(options = {})
48
48
  options[:access_token] ||= self.access_token || get_access_token(options[:secret])
49
- destroy(options.merge(:connection => 'subscriptions'))
49
+ destroy(options.merge(:connection => :subscriptions))
50
50
  end
51
51
  end
52
52
  end
@@ -6,18 +6,18 @@ module FbGraph
6
6
 
7
7
  def initialize(attributes = {})
8
8
  if (school = attributes[:school])
9
- @school = FbGraph::Page.new(school.delete(:id), school)
9
+ @school = Page.new(school.delete(:id), school)
10
10
  end
11
11
  if (degree = attributes[:degree])
12
- @degree = FbGraph::Page.new(degree.delete(:id), degree)
12
+ @degree = Page.new(degree.delete(:id), degree)
13
13
  end
14
14
  if (year = attributes[:year])
15
- @year = FbGraph::Page.new(year.delete(:id), year)
15
+ @year = Page.new(year.delete(:id), year)
16
16
  end
17
17
  @concentration = []
18
18
  if attributes[:concentration]
19
19
  attributes[:concentration].each do |concentration|
20
- @concentration << FbGraph::Page.new(concentration.delete(:id), concentration)
20
+ @concentration << Page.new(concentration.delete(:id), concentration)
21
21
  end
22
22
  end
23
23
  end
@@ -14,7 +14,7 @@ module FbGraph
14
14
  def initialize(identifier, attributes = {})
15
15
  super
16
16
  if (owner = attributes[:owner])
17
- @owner = FbGraph::User.new(owner.delete(:id), owner)
17
+ @owner = User.new(owner.delete(:id), owner)
18
18
  end
19
19
  @name = attributes[:name]
20
20
  @description = attributes[:description]
@@ -37,7 +37,7 @@ module FbGraph
37
37
  end
38
38
  end
39
39
  if attributes[:venue]
40
- @venue = FbGraph::Venue.new(attributes[:venue])
40
+ @venue = Venue.new(attributes[:venue])
41
41
  end
42
42
  if attributes[:updated_time]
43
43
  @updated_time = Time.parse(attributes[:updated_time]).utc
@@ -10,14 +10,14 @@ module FbGraph
10
10
  def initialize(identifier, attributes = {})
11
11
  super
12
12
  if (owner = attributes[:owner])
13
- @owner = FbGraph::User.new(owner.delete(:id), owner)
13
+ @owner = User.new(owner.delete(:id), owner)
14
14
  end
15
15
  @name = attributes[:name]
16
16
  @description = attributes[:description]
17
17
  @link = attributes[:link]
18
18
  @privacy = attributes[:privacy]
19
19
  if attributes[:venue]
20
- @venue = FbGraph::Venue.new(attributes[:venue])
20
+ @venue = Venue.new(attributes[:venue])
21
21
  end
22
22
  if attributes[:updated_time]
23
23
  @updated_time = Time.parse(attributes[:updated_time]).utc
@@ -1,6 +1,6 @@
1
1
  module FbGraph
2
2
  class Insight < Node
3
- include FbGraph::Comparison
3
+ include Comparison
4
4
 
5
5
  attr_accessor :name, :period, :values, :description
6
6
 
data/lib/fb_graph/link.rb CHANGED
@@ -8,9 +8,9 @@ module FbGraph
8
8
  super
9
9
  if (from = attributes[:from])
10
10
  @from = if from[:category]
11
- FbGraph::Page.new(from.delete(:id), from)
11
+ Page.new(from.delete(:id), from)
12
12
  else
13
- FbGraph::User.new(from.delete(:id), from)
13
+ User.new(from.delete(:id), from)
14
14
  end
15
15
  end
16
16
  @name = attributes[:name]
@@ -25,7 +25,7 @@ module FbGraph
25
25
  end
26
26
 
27
27
  # cached connection
28
- @_comments_ = FbGraph::Collection.new(attributes[:comments])
28
+ @_comments_ = Collection.new(attributes[:comments])
29
29
  end
30
30
  end
31
31
  end
data/lib/fb_graph/node.rb CHANGED
@@ -6,7 +6,7 @@ module FbGraph
6
6
 
7
7
  def initialize(identifier, options = {})
8
8
  @identifier = identifier
9
- @endpoint = File.join(FbGraph::ROOT_URL, identifier.to_s)
9
+ @endpoint = File.join(ROOT_URL, identifier.to_s)
10
10
  @access_token = options[:access_token]
11
11
  end
12
12
 
@@ -21,7 +21,7 @@ module FbGraph
21
21
  end
22
22
 
23
23
  def connection(connection, options = {})
24
- collection = options[:cached_collection] || FbGraph::Collection.new(get(options.merge(:connection => connection)))
24
+ collection = options[:cached_collection] || Collection.new(get(options.merge(:connection => connection)))
25
25
  Connection.new(self, connection, options.merge(:collection => collection))
26
26
  end
27
27
 
@@ -93,7 +93,7 @@ module FbGraph
93
93
  # This is an undocumented behaviour, so facebook might chaange it without any announcement.
94
94
  # I've posted this issue on their forum, so hopefully I'll get a document about Graph API error responses.
95
95
  # ref) http://forum.developers.facebook.com/viewtopic.php?pid=228256#p228256
96
- raise FbGraph::NotFound.new('Graph API returned false, so probably it means your requested object is not found.')
96
+ raise NotFound.new('Graph API returned false, so probably it means your requested object is not found.')
97
97
  when 'null'
98
98
  nil
99
99
  else
@@ -106,9 +106,9 @@ module FbGraph
106
106
  if _response_[:error]
107
107
  case _response_[:error][:type]
108
108
  when 'OAuthAccessTokenException', 'QueryParseException', 'OAuthInvalidRequestException', 'OAuthInvalidTokenException', 'OAuthException'
109
- raise FbGraph::Unauthorized.new(_response_[:error][:message])
109
+ raise Unauthorized.new(_response_[:error][:message])
110
110
  else
111
- raise FbGraph::BadRequest.new("#{_response_[:error][:type]} :: #{_response_[:error][:message]}")
111
+ raise BadRequest.new("#{_response_[:error][:type]} :: #{_response_[:error][:message]}")
112
112
  end
113
113
  else
114
114
  _response_
@@ -116,7 +116,7 @@ module FbGraph
116
116
  end
117
117
  end
118
118
  rescue RestClient::Exception => e
119
- raise FbGraph::Exception.new(e.http_code, e.message, e.http_body)
119
+ raise Exception.new(e.http_code, e.message, e.http_body)
120
120
  end
121
121
  end
122
122
  end
data/lib/fb_graph/note.rb CHANGED
@@ -9,9 +9,9 @@ module FbGraph
9
9
  super
10
10
  if (from = attributes[:from])
11
11
  @from = if from[:category]
12
- FbGraph::Page.new(from.delete(:id), from)
12
+ Page.new(from.delete(:id), from)
13
13
  else
14
- FbGraph::User.new(from.delete(:id), from)
14
+ User.new(from.delete(:id), from)
15
15
  end
16
16
  end
17
17
  @subject = attributes[:subject]
@@ -25,7 +25,7 @@ module FbGraph
25
25
  @icon = attributes[:icon]
26
26
 
27
27
  # cached connection
28
- @_comments_ = FbGraph::Collection.new(attributes[:comments])
28
+ @_comments_ = Collection.new(attributes[:comments])
29
29
  end
30
30
  end
31
31
  end
data/lib/fb_graph/page.rb CHANGED
@@ -16,7 +16,7 @@ module FbGraph
16
16
  include Connections::Videos
17
17
  extend Searchable
18
18
 
19
- attr_accessor :name, :username, :link, :category, :founded, :company_overview, :mission, :products, :fan_count, :location, :website, :like_count
19
+ attr_accessor :name, :username, :link, :category, :founded, :company_overview, :mission, :products, :fan_count, :location, :website, :like_count, :venue
20
20
 
21
21
  def initialize(identifier, attributes = {})
22
22
  super
@@ -34,7 +34,7 @@ module FbGraph
34
34
  end
35
35
  @fan_count = attributes[:fan_count]
36
36
  if (location = attributes[:location])
37
- @venue = FbGraph::Venue.new(location)
37
+ @venue = Venue.new(location)
38
38
  end
39
39
  @website = attributes[:website]
40
40
  @like_count = attributes[:likes]
@@ -9,15 +9,15 @@ module FbGraph
9
9
  super
10
10
  if (from = attributes[:from])
11
11
  @from = if from[:category]
12
- FbGraph::Page.new(from.delete(:id), from)
12
+ Page.new(from.delete(:id), from)
13
13
  else
14
- FbGraph::User.new(from.delete(:id), from)
14
+ User.new(from.delete(:id), from)
15
15
  end
16
16
  end
17
17
  @tags = []
18
18
  if attributes[:tags]
19
- FbGraph::Collection.new(attributes[:tags]).each do |tag|
20
- @tags << FbGraph::Tag.new(tag.delete(:id), tag)
19
+ Collection.new(attributes[:tags]).each do |tag|
20
+ @tags << Tag.new(tag.delete(:id), tag)
21
21
  end
22
22
  end
23
23
  # NOTE:
@@ -38,7 +38,7 @@ module FbGraph
38
38
  end
39
39
 
40
40
  # cached connection
41
- @_comments_ = FbGraph::Collection.new(attributes[:comments])
41
+ @_comments_ = Collection.new(attributes[:comments])
42
42
  end
43
43
  end
44
44
  end
data/lib/fb_graph/post.rb CHANGED
@@ -10,18 +10,18 @@ module FbGraph
10
10
  super
11
11
  if (from = attributes[:from])
12
12
  @from = if from[:category]
13
- FbGraph::Page.new(from.delete(:id), from)
13
+ Page.new(from.delete(:id), from)
14
14
  else
15
- FbGraph::User.new(from.delete(:id), from)
15
+ User.new(from.delete(:id), from)
16
16
  end
17
17
  end
18
18
  @to = []
19
19
  if attributes[:to]
20
- FbGraph::Collection.new(attributes[:to]).each do |to|
20
+ Collection.new(attributes[:to]).each do |to|
21
21
  @to << if to[:category]
22
- FbGraph::Page.new(to.delete(:id), to)
22
+ Page.new(to.delete(:id), to)
23
23
  else
24
- FbGraph::User.new(to.delete(:id), to)
24
+ User.new(to.delete(:id), to)
25
25
  end
26
26
  end
27
27
  end
@@ -44,7 +44,7 @@ module FbGraph
44
44
  end
45
45
 
46
46
  # cached connection
47
- @_comments_ = FbGraph::Collection.new(attributes[:comments])
47
+ @_comments_ = Collection.new(attributes[:comments])
48
48
  end
49
49
  end
50
50
  end
@@ -33,7 +33,7 @@ module FbGraph
33
33
  case response
34
34
  when Hash
35
35
  if response[:error_code]
36
- raise FbGraph::Exception.new(response[:error_code], response[:error_msg])
36
+ raise Exception.new(response[:error_code], response[:error_msg])
37
37
  else
38
38
  response
39
39
  end
@@ -7,7 +7,7 @@ module FbGraph
7
7
  @klass = klass
8
8
  @query = query
9
9
  @options = options
10
- @collection = options.delete(:collection) || FbGraph::Collection.new
10
+ @collection = options.delete(:collection) || Collection.new
11
11
  replace @collection
12
12
  end
13
13
 
@@ -1,17 +1,17 @@
1
1
  module FbGraph
2
2
  module Searchable
3
3
  def self.search(query, options = {})
4
- klass = options.delete(:class) || FbGraph::Searchable
5
- collection = FbGraph::Collection.new(
6
- FbGraph::Node.new(:search).send(:get, options.merge(:q => query))
4
+ klass = options.delete(:class) || Searchable
5
+ collection = Collection.new(
6
+ Node.new(:search).send(:get, options.merge(:q => query))
7
7
  )
8
8
  yield collection if block_given?
9
- FbGraph::Searchable::Result.new(query, klass, options.merge(:collection => collection))
9
+ Searchable::Result.new(query, klass, options.merge(:collection => collection))
10
10
  end
11
11
 
12
12
  def search(query, options = {})
13
13
  type = self.to_s.underscore.split('/').last
14
- FbGraph::Searchable.search(query, options.merge(:type => type, :class => self)) do |collection|
14
+ Searchable.search(query, options.merge(:type => type, :class => self)) do |collection|
15
15
  collection.map! do |obj|
16
16
  self.new(obj.delete(:id), obj.merge(
17
17
  :access_token => options[:access_token]
@@ -9,9 +9,9 @@ module FbGraph
9
9
  super
10
10
  if (from = attributes[:from])
11
11
  @from = if from[:category]
12
- FbGraph::Page.new(from.delete(:id), from)
12
+ Page.new(from.delete(:id), from)
13
13
  else
14
- FbGraph::User.new(from.delete(:id), from)
14
+ User.new(from.delete(:id), from)
15
15
  end
16
16
  end
17
17
  @message = attributes[:message]
@@ -20,8 +20,8 @@ module FbGraph
20
20
  end
21
21
 
22
22
  # cached connection
23
- @_comments_ = FbGraph::Collection.new(attributes[:comments])
24
- @_likes_ = FbGraph::Collection.new(attributes[:likes])
23
+ @_comments_ = Collection.new(attributes[:comments])
24
+ @_likes_ = Collection.new(attributes[:likes])
25
25
  end
26
26
  end
27
27
  end
@@ -1,6 +1,6 @@
1
1
  module FbGraph
2
2
  class Subscription
3
- include FbGraph::Comparison
3
+ include Comparison
4
4
 
5
5
  attr_accessor :object, :fields, :callback_url, :active
6
6
 
data/lib/fb_graph/user.rb CHANGED
@@ -49,22 +49,22 @@ module FbGraph
49
49
  @work = []
50
50
  if attributes[:work]
51
51
  attributes[:work].each do |work|
52
- @work << FbGraph::Work.new(work)
52
+ @work << Work.new(work)
53
53
  end
54
54
  end
55
55
  @education = []
56
56
  if attributes[:education]
57
57
  attributes[:education].each do |education|
58
- @education << FbGraph::Education.new(education)
58
+ @education << Education.new(education)
59
59
  end
60
60
  end
61
61
  @email = attributes[:email]
62
62
  @website = attributes[:website].to_s.split("\n")
63
63
  if (hometown = attributes[:hometown])
64
- @hometown = FbGraph::Page.new(hometown.delete(:id), hometown)
64
+ @hometown = Page.new(hometown.delete(:id), hometown)
65
65
  end
66
66
  if (location = attributes[:location])
67
- @location = FbGraph::Page.new(location.delete(:id), location)
67
+ @location = Page.new(location.delete(:id), location)
68
68
  end
69
69
  @bio = attributes[:bio]
70
70
  @quotes = attributes[:quotes]
@@ -9,9 +9,9 @@ module FbGraph
9
9
  super
10
10
  if (from = attributes[:from])
11
11
  @from = if from[:category]
12
- FbGraph::Page.new(from.delete(:id), from)
12
+ Page.new(from.delete(:id), from)
13
13
  else
14
- FbGraph::User.new(from.delete(:id), from)
14
+ User.new(from.delete(:id), from)
15
15
  end
16
16
  end
17
17
  @message = attributes[:message]
@@ -25,7 +25,7 @@ module FbGraph
25
25
  end
26
26
 
27
27
  # cached connection
28
- @_comments_ = FbGraph::Collection.new(attributes[:comments])
28
+ @_comments_ = Collection.new(attributes[:comments])
29
29
  end
30
30
  end
31
31
  end
data/lib/fb_graph/work.rb CHANGED
@@ -6,13 +6,13 @@ module FbGraph
6
6
 
7
7
  def initialize(attributes = {})
8
8
  if (employer = attributes[:employer])
9
- @employer = FbGraph::Page.new(employer.delete(:id), employer)
9
+ @employer = Page.new(employer.delete(:id), employer)
10
10
  end
11
11
  if (location = attributes[:location])
12
- @location = FbGraph::Page.new(location.delete(:id), location)
12
+ @location = Page.new(location.delete(:id), location)
13
13
  end
14
14
  if (position = attributes[:position])
15
- @position = FbGraph::Page.new(position.delete(:id), position)
15
+ @position = Page.new(position.delete(:id), position)
16
16
  end
17
17
  if attributes[:start_date] && attributes[:start_date] != '0000-00'
18
18
  year, month = attributes[:start_date].split('-').collect(&:to_i)
data/lib/fb_graph.rb CHANGED
@@ -25,19 +25,19 @@ module FbGraph
25
25
  end
26
26
  end
27
27
 
28
- class BadRequest < FbGraph::Exception
28
+ class BadRequest < Exception
29
29
  def initialize(message, body = '')
30
30
  super 400, message, body
31
31
  end
32
32
  end
33
33
 
34
- class Unauthorized < FbGraph::Exception
34
+ class Unauthorized < Exception
35
35
  def initialize(message, body = '')
36
36
  super 401, message, body
37
37
  end
38
38
  end
39
39
 
40
- class NotFound < FbGraph::Exception
40
+ class NotFound < Exception
41
41
  def initialize(message, body = '')
42
42
  super 404, message, body
43
43
  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: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 1
10
- version: 1.2.1
9
+ - 2
10
+ version: 1.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - nov matake