mogli 0.0.14 → 0.0.15
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/mogli.rb +2 -2
- data/lib/mogli/album.rb +3 -3
- data/lib/mogli/checkin.rb +1 -1
- data/lib/mogli/client.rb +8 -1
- data/lib/mogli/education.rb +3 -3
- data/lib/mogli/event.rb +4 -3
- data/lib/mogli/group.rb +4 -3
- data/lib/mogli/link.rb +3 -2
- data/lib/mogli/model.rb +11 -2
- data/lib/mogli/model/search.rb +21 -0
- data/lib/mogli/page.rb +13 -12
- data/lib/mogli/photo.rb +2 -2
- data/lib/mogli/post.rb +1 -1
- data/lib/mogli/status.rb +3 -3
- data/lib/mogli/user.rb +9 -8
- data/lib/mogli/video.rb +7 -6
- metadata +3 -2
data/lib/mogli.rb
CHANGED
data/lib/mogli/album.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Mogli
|
2
2
|
class Album < Model
|
3
3
|
|
4
|
-
define_properties :id, :name, :description, :link, :count, :created_time, :updated_time
|
5
|
-
creation_properties :name, :
|
4
|
+
define_properties :id, :name, :description, :location, :privacy, :link, :count, :created_time, :updated_time
|
5
|
+
creation_properties :name, :description
|
6
6
|
|
7
7
|
hash_populating_accessor :from, "User","Page"
|
8
8
|
has_association :photos, "Photo"
|
9
9
|
has_association :comments, "Comment"
|
10
10
|
|
11
11
|
end
|
12
|
-
end
|
12
|
+
end
|
data/lib/mogli/checkin.rb
CHANGED
data/lib/mogli/client.rb
CHANGED
@@ -10,7 +10,11 @@ module Mogli
|
|
10
10
|
include HTTParty
|
11
11
|
include Mogli::Client::Event
|
12
12
|
include Mogli::Client::User
|
13
|
+
|
13
14
|
class UnrecognizeableClassError < Exception; end
|
15
|
+
class QueryParseException < Exception; end
|
16
|
+
class OAuthAccessTokenException < Exception; end
|
17
|
+
class OAuthUnauthorizedClientException < Exception; end
|
14
18
|
|
15
19
|
def api_path(path)
|
16
20
|
"https://graph.facebook.com/#{path}"
|
@@ -37,7 +41,7 @@ module Mogli
|
|
37
41
|
parts = post_data.split("&")
|
38
42
|
hash = {}
|
39
43
|
parts.each do |p| (k,v) = p.split("=")
|
40
|
-
hash[k]=v
|
44
|
+
hash[k]=CGI.unescape(v)
|
41
45
|
end
|
42
46
|
new(hash["access_token"],hash["expires"].to_s.to_i)
|
43
47
|
end
|
@@ -66,6 +70,7 @@ module Mogli
|
|
66
70
|
|
67
71
|
def get_and_map(path,klass=nil,body_args = {})
|
68
72
|
data = self.class.get(api_path(path),:query=>default_params.merge(body_args))
|
73
|
+
data = data.values if body_args.key?(:ids) && !data.key?('error')
|
69
74
|
map_data(data,klass)
|
70
75
|
end
|
71
76
|
|
@@ -124,6 +129,7 @@ module Mogli
|
|
124
129
|
end
|
125
130
|
|
126
131
|
def determine_class(klass_or_klasses,data)
|
132
|
+
return constantize_string(data['type']) if data.key?('type') && klass_or_klasses == Mogli::Model
|
127
133
|
klasses = Array(klass_or_klasses).map { |k| constantize_string(k)}
|
128
134
|
klasses.detect {|klass| klass.recognize?(data)} || klasses.first
|
129
135
|
end
|
@@ -133,6 +139,7 @@ module Mogli
|
|
133
139
|
if data.keys.size == 1 and data["error"]
|
134
140
|
type = data["error"]["type"]
|
135
141
|
message = data["error"]["message"]
|
142
|
+
raise Mogli::Client.const_get(type).new(message) if Mogli::Client.const_defined?(type)
|
136
143
|
raise Exception.new("#{type}: #{message}")
|
137
144
|
end
|
138
145
|
end
|
data/lib/mogli/education.rb
CHANGED
data/lib/mogli/event.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
module Mogli
|
2
2
|
class Event < Model
|
3
|
+
set_search_type
|
3
4
|
define_properties :id, :name, :description, :start_time, :end_time, :location, :privacy, :updated_time
|
4
5
|
creation_properties :start_time, :end_time, :link, :name, :description, :privacy
|
5
|
-
|
6
|
+
|
6
7
|
hash_populating_accessor :venue, "Address"
|
7
8
|
hash_populating_accessor :owner, "User", "Page"
|
8
9
|
has_association :noreply, "User"
|
9
|
-
has_association :
|
10
|
+
has_association :maybe, "User"
|
10
11
|
has_association :invited, "User"
|
11
12
|
has_association :attending, "User"
|
12
13
|
has_association :declined, "User"
|
13
14
|
has_association :feed, "Post"
|
14
15
|
end
|
15
|
-
end
|
16
|
+
end
|
data/lib/mogli/group.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Mogli
|
2
2
|
class Group < Model
|
3
|
+
set_search_type
|
3
4
|
define_properties :id, :name, :description, :link, :privacy, :updated_time
|
4
|
-
|
5
|
+
|
5
6
|
hash_populating_accessor :owner, "User", "Page"
|
6
7
|
hash_populating_accessor :venue, "Address"
|
7
|
-
|
8
|
+
|
8
9
|
has_association :feed, "Post"
|
9
10
|
has_association :members, "User"
|
10
11
|
end
|
11
|
-
end
|
12
|
+
end
|
data/lib/mogli/link.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module Mogli
|
2
2
|
class Link < Model
|
3
|
-
define_properties :link, :message, :id, :name, :page, :created_time, :
|
3
|
+
define_properties :link, :message, :id, :name, :page, :created_time, :updated_time,
|
4
|
+
:icon, :picture, :description, :caption
|
4
5
|
creation_properties :link, :message
|
5
6
|
|
6
7
|
hash_populating_accessor :comments, "Comment"
|
7
8
|
hash_populating_accessor :from, "User"
|
8
9
|
end
|
9
|
-
end
|
10
|
+
end
|
data/lib/mogli/model.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
require 'mogli/model/search'
|
2
|
+
|
1
3
|
module Mogli
|
2
4
|
class Model < Hashie::Dash
|
3
|
-
|
5
|
+
extend Mogli::Model::Search
|
6
|
+
|
7
|
+
set_search_type :all
|
8
|
+
|
4
9
|
attr_accessor :type
|
5
|
-
|
10
|
+
|
6
11
|
def client=(val)
|
7
12
|
@client=val
|
8
13
|
end
|
@@ -105,7 +110,11 @@ module Mogli
|
|
105
110
|
|
106
111
|
def self.find(id,client=nil, *fields)
|
107
112
|
body_args = fields.empty? ? {} : {:fields => fields}
|
113
|
+
(id, body_args[:ids] = "", id.join(',')) if id.is_a?(Array)
|
108
114
|
(client||Mogli::Client.new).get_and_map(id,self, body_args)
|
109
115
|
end
|
116
|
+
|
110
117
|
end
|
111
118
|
end
|
119
|
+
|
120
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Mogli
|
2
|
+
class Model < Hashie::Dash
|
3
|
+
module Search
|
4
|
+
attr_reader :search_type
|
5
|
+
|
6
|
+
def search(pattern="", client=nil, args={})
|
7
|
+
raise(NoMethodError.new("Can't search for #{self.to_s}")) unless search_type
|
8
|
+
args.merge!({:q => pattern})
|
9
|
+
args.merge!(:type => self.search_type) unless search_type == 'all'
|
10
|
+
(client||Mogli::Client.new).get_and_map('search', self, args)
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def set_search_type(type=nil)
|
16
|
+
@search_type = type.nil? ? self.to_s.gsub('Mogli::','').downcase : type.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/mogli/page.rb
CHANGED
@@ -1,34 +1,35 @@
|
|
1
1
|
module Mogli
|
2
2
|
class Page < Profile
|
3
|
-
|
3
|
+
set_search_type
|
4
|
+
|
4
5
|
define_properties :id, :name, :category, :username, :access_token
|
5
|
-
|
6
|
+
|
6
7
|
# General
|
7
8
|
define_properties :fan_count, :link, :picture, :has_added_app
|
8
9
|
|
9
10
|
# Retail
|
10
11
|
define_properties :founded, :products, :mission, :company_overview
|
11
|
-
|
12
|
+
|
12
13
|
# Musicians
|
13
14
|
define_properties :record_label, :hometown, :band_members, :genre
|
14
|
-
|
15
|
-
# As a like
|
15
|
+
|
16
|
+
# As a like
|
16
17
|
define_properties :created_time
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
|
19
|
+
def client_for_page
|
20
|
+
if access_token.blank?
|
21
|
+
raise MissingAccessToken.new("You can only get a client for this page if an access_token has been provided. i.e. via /me/accounts")
|
21
22
|
end
|
22
23
|
Client.new(access_token)
|
23
24
|
end
|
24
|
-
|
25
|
+
|
25
26
|
def self.recognize?(hash)
|
26
27
|
hash.has_key?("category")
|
27
28
|
end
|
28
29
|
|
29
30
|
class MissingAccessToken < Exception
|
30
31
|
end
|
31
|
-
|
32
|
+
|
32
33
|
end
|
33
|
-
|
34
|
+
|
34
35
|
end
|
data/lib/mogli/photo.rb
CHANGED
data/lib/mogli/post.rb
CHANGED
@@ -8,7 +8,7 @@ module Mogli
|
|
8
8
|
creation_properties :message, :picture, :link, :name, :description, :caption, :source
|
9
9
|
|
10
10
|
hash_populating_accessor :actions, "Action"
|
11
|
-
|
11
|
+
has_association :comments, "Comment"
|
12
12
|
hash_populating_accessor :from, "User"
|
13
13
|
|
14
14
|
def likes_create
|
data/lib/mogli/status.rb
CHANGED
data/lib/mogli/user.rb
CHANGED
@@ -1,21 +1,22 @@
|
|
1
|
-
|
2
1
|
module Mogli
|
3
2
|
class User < Profile
|
4
|
-
|
3
|
+
set_search_type
|
4
|
+
|
5
5
|
define_properties :first_name, :last_name, :link, :about, :birthday, :gender,
|
6
|
-
:email, :website, :timezone, :updated_time, :verified, :political,
|
7
|
-
|
6
|
+
:email, :website, :timezone, :updated_time, :verified, :political,
|
7
|
+
:relationship_status, :locale, :religion, :quotes
|
8
|
+
|
8
9
|
def self.recognize?(hash)
|
9
10
|
!hash.has_key?("category")
|
10
11
|
end
|
11
|
-
|
12
|
+
|
12
13
|
hash_populating_accessor :work, "Work"
|
13
14
|
hash_populating_accessor :education, "Education"
|
14
|
-
|
15
|
+
|
15
16
|
hash_populating_accessor :location, "Page"
|
16
17
|
hash_populating_accessor :hometown, "Page"
|
17
18
|
|
18
|
-
has_association :activities,"Activity"
|
19
|
+
has_association :activities, "Activity"
|
19
20
|
has_association :friends, "User"
|
20
21
|
has_association :interests, "Interest"
|
21
22
|
has_association :music, "Music"
|
@@ -26,4 +27,4 @@ module Mogli
|
|
26
27
|
has_association :home, "Post"
|
27
28
|
has_association :accounts, "Page"
|
28
29
|
end
|
29
|
-
end
|
30
|
+
end
|
data/lib/mogli/video.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Mogli
|
2
2
|
class Video < Model
|
3
|
-
|
4
|
-
define_properties :id, :message, :name, :description, :length, :created_time,
|
5
|
-
|
3
|
+
|
4
|
+
define_properties :id, :message, :name, :description, :length, :created_time,
|
5
|
+
:updated_time, :icon, :picture, :embed_html, :caption, :link, :source, :likes
|
6
|
+
|
6
7
|
hash_populating_accessor :from, "User", "Page"
|
7
|
-
|
8
|
+
|
8
9
|
has_association :comments, "Comment"
|
9
|
-
|
10
|
+
|
10
11
|
end
|
11
|
-
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mogli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Mangino
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-10-05 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/mogli/interest.rb
|
60
60
|
- lib/mogli/link.rb
|
61
61
|
- lib/mogli/location.rb
|
62
|
+
- lib/mogli/model/search.rb
|
62
63
|
- lib/mogli/model.rb
|
63
64
|
- lib/mogli/movie.rb
|
64
65
|
- lib/mogli/music.rb
|