mogli 0.0.37 → 0.0.38
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/app_client.rb +0 -4
- data/lib/mogli/application.rb +1 -1
- data/lib/mogli/client.rb +9 -1
- data/lib/mogli/fetching_array.rb +1 -1
- data/lib/mogli/fql_multiquery.rb +5 -2
- data/lib/mogli/model.rb +1 -1
- data/lib/mogli/photo.rb +1 -1
- data/lib/mogli/subscription.rb +5 -0
- data/lib/mogli/user.rb +4 -2
- data/spec/user_spec.rb +4 -3
- metadata +16 -38
data/lib/mogli/app_client.rb
CHANGED
data/lib/mogli/application.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Mogli
|
2
2
|
class Application < Model
|
3
3
|
|
4
|
-
define_properties :id, :name, :description, :category, :subcategory, :link, :canvas_name, :namespace, :icon_url, :logo_url, :weekly_active_users, :monthly_active_users
|
4
|
+
define_properties :id, :name, :description, :category, :subcategory, :link, :canvas_name, :namespace, :icon_url, :logo_url, :weekly_active_users, :monthly_active_users, :daily_active_users
|
5
5
|
|
6
6
|
has_association :feed, "Post"
|
7
7
|
has_association :posts, "Post"
|
data/lib/mogli/client.rb
CHANGED
@@ -159,12 +159,16 @@ module Mogli
|
|
159
159
|
def extract_hash_or_array(hash_or_array,klass)
|
160
160
|
hash_or_array = hash_or_array.parsed_response if hash_or_array.respond_to?(:parsed_response)
|
161
161
|
return nil if hash_or_array == false
|
162
|
+
return [] if hash_or_array == {"count" => 0}
|
162
163
|
return hash_or_array if hash_or_array.nil? or hash_or_array.kind_of?(Array)
|
163
164
|
return extract_fetching_array(hash_or_array,klass) if is_fetching_array?(hash_or_array)
|
165
|
+
# Facebook doesn't return numbers or booleans in an object or list
|
166
|
+
# container; this will catch the number, "true" and "false" response case
|
164
167
|
return hash_or_array
|
165
168
|
end
|
166
169
|
|
167
170
|
def is_fetching_array?(hash)
|
171
|
+
return false unless hash.respond_to? :has_key?
|
168
172
|
hash.has_key?("data") and hash["data"].instance_of?(Array)
|
169
173
|
end
|
170
174
|
|
@@ -173,6 +177,7 @@ module Mogli
|
|
173
177
|
f.concat(hash["data"])
|
174
178
|
f.client = self
|
175
179
|
f.classes = Array(klass)
|
180
|
+
f.total_count = hash["count"]
|
176
181
|
if paging=hash["paging"]
|
177
182
|
f.next_url = URI.encode paging["next"] unless paging["next"].nil?
|
178
183
|
f.previous_url = URI.encode paging["previous"] unless paging["previous"].nil?
|
@@ -206,7 +211,10 @@ module Mogli
|
|
206
211
|
end
|
207
212
|
|
208
213
|
def determine_class(klass_or_klasses,data)
|
209
|
-
|
214
|
+
if data.respond_to?(:has_key?) && data.has_key?('type') &&
|
215
|
+
klass_or_klasses == Mogli::Model
|
216
|
+
return constantize_string(data['type'])
|
217
|
+
end
|
210
218
|
klasses = Array(klass_or_klasses).map { |k| constantize_string(k)}
|
211
219
|
klasses.detect {|klass| klass.recognize?(data)} || klasses.first
|
212
220
|
end
|
data/lib/mogli/fetching_array.rb
CHANGED
data/lib/mogli/fql_multiquery.rb
CHANGED
@@ -32,7 +32,10 @@ module Mogli
|
|
32
32
|
# Default value is empty array
|
33
33
|
res[query] = []
|
34
34
|
# Find subquery by name in response
|
35
|
-
vals = response.find{|r|
|
35
|
+
vals = response.find{|r|
|
36
|
+
return false unless r.is_a? Hash
|
37
|
+
r['name'] == query.to_s
|
38
|
+
}
|
36
39
|
if vals && vals.has_key?('fql_result_set')
|
37
40
|
res[query] = @client.map_to_class(vals['fql_result_set'], @queries[query][1])
|
38
41
|
end
|
@@ -40,4 +43,4 @@ module Mogli
|
|
40
43
|
end
|
41
44
|
end
|
42
45
|
end
|
43
|
-
end
|
46
|
+
end
|
data/lib/mogli/model.rb
CHANGED
@@ -116,7 +116,7 @@ module Mogli
|
|
116
116
|
|
117
117
|
def self.has_association(name,klass)
|
118
118
|
define_method name do |*fields|
|
119
|
-
body_args = fields.empty? ? {} : {:fields => fields}
|
119
|
+
body_args = fields.empty? ? {} : {:fields => fields.join(',')}
|
120
120
|
if (ret=instance_variable_get("@#{name}")).nil?
|
121
121
|
ret = client.get_and_map("#{id}/#{name}",klass, body_args)
|
122
122
|
instance_variable_set("@#{name}",ret)
|
data/lib/mogli/photo.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Mogli
|
2
2
|
class Photo < Model
|
3
3
|
define_properties :id, :name, :tags, :picture, :source, :height, :width, :images, :link, :icon,
|
4
|
-
:created_time, :updated_time, :position, :comments
|
4
|
+
:created_time, :updated_time, :position, :comments, :likes
|
5
5
|
creation_properties :message
|
6
6
|
|
7
7
|
hash_populating_accessor :from, "User","Page"
|
data/lib/mogli/user.rb
CHANGED
@@ -4,8 +4,8 @@ module Mogli
|
|
4
4
|
|
5
5
|
define_properties :username, :first_name, :last_name, :link, :about, :birthday, :gender,
|
6
6
|
:email, :website, :timezone, :updated_time, :verified, :political, :bio,
|
7
|
-
:relationship_status, :locale, :religion, :quotes, :third_party_id,
|
8
|
-
:inspirational_people, :sports, :with, :middle_name, :category
|
7
|
+
:interested_in, :relationship_status, :locale, :religion, :quotes, :third_party_id,
|
8
|
+
:inspirational_people, :sports, :with, :middle_name, :category, :installed
|
9
9
|
|
10
10
|
def self.recognize?(hash)
|
11
11
|
!hash.has_key?("category")
|
@@ -34,6 +34,8 @@ module Mogli
|
|
34
34
|
has_association :accounts, "Page"
|
35
35
|
has_association :apprequests, "AppRequest"
|
36
36
|
|
37
|
+
has_association :events, "Event"
|
38
|
+
|
37
39
|
attr_reader :extended_permissions
|
38
40
|
|
39
41
|
# raised when asked to check for a permission that mogli doesn't know about
|
data/spec/user_spec.rb
CHANGED
@@ -25,15 +25,16 @@ describe Mogli::User do
|
|
25
25
|
|
26
26
|
it "finds optional fields for a user" do
|
27
27
|
Mogli::Client.should_receive(:get).with("https://graph.facebook.com/1",
|
28
|
-
:query=>{:fields => "birthday,gender"}).and_return({:id=>1, :birthday=>'09/15', :gender => 'male'})
|
29
|
-
user = Mogli::User.find(1, nil, :birthday, :gender)
|
28
|
+
:query=>{:fields => "birthday,gender,installed"}).and_return({:id=>1, :birthday=>'09/15', :gender => 'male', :installed => true})
|
29
|
+
user = Mogli::User.find(1, nil, :birthday, :gender, :installed)
|
30
30
|
user.birthday.should == '09/15'
|
31
31
|
user.gender.should == 'male'
|
32
|
+
user.installed.should == true
|
32
33
|
end
|
33
34
|
|
34
35
|
it "finds a user's friends with optional fields" do
|
35
36
|
mock_client.should_receive(:get_and_map).with(
|
36
|
-
"1/friends", "User", {:fields =>
|
37
|
+
"1/friends", "User", {:fields => 'birthday,gender'}).and_return(
|
37
38
|
[Mogli::User.new(:id=>2, :birthday=>'09/15', :gender => 'male')])
|
38
39
|
friends = user_1.friends(:birthday, :gender)
|
39
40
|
friends.size.should == 1
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mogli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
8
|
+
- 38
|
9
|
+
version: 0.0.38
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Mike Mangino
|
@@ -15,17 +14,16 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date:
|
17
|
+
date: 2012-06-12 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: hashie
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
24
|
requirements:
|
26
|
-
- -
|
25
|
+
- - ">="
|
27
26
|
- !ruby/object:Gem::Version
|
28
|
-
hash: 19
|
29
27
|
segments:
|
30
28
|
- 1
|
31
29
|
- 1
|
@@ -37,11 +35,9 @@ dependencies:
|
|
37
35
|
name: httmultiparty
|
38
36
|
prerelease: false
|
39
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
38
|
requirements:
|
42
39
|
- - ">="
|
43
40
|
- !ruby/object:Gem::Version
|
44
|
-
hash: 31
|
45
41
|
segments:
|
46
42
|
- 0
|
47
43
|
- 3
|
@@ -53,11 +49,9 @@ dependencies:
|
|
53
49
|
name: httparty
|
54
50
|
prerelease: false
|
55
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
52
|
requirements:
|
58
53
|
- - ">="
|
59
54
|
- !ruby/object:Gem::Version
|
60
|
-
hash: 9
|
61
55
|
segments:
|
62
56
|
- 0
|
63
57
|
- 4
|
@@ -69,27 +63,29 @@ dependencies:
|
|
69
63
|
name: multi_json
|
70
64
|
prerelease: false
|
71
65
|
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
66
|
requirements:
|
74
|
-
- -
|
67
|
+
- - ">="
|
75
68
|
- !ruby/object:Gem::Version
|
76
|
-
hash: 17
|
77
69
|
segments:
|
78
70
|
- 1
|
79
71
|
- 0
|
80
72
|
- 3
|
81
73
|
version: 1.0.3
|
74
|
+
- - <
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
segments:
|
77
|
+
- 1
|
78
|
+
- 4
|
79
|
+
version: "1.4"
|
82
80
|
type: :runtime
|
83
81
|
version_requirements: *id004
|
84
82
|
- !ruby/object:Gem::Dependency
|
85
83
|
name: json
|
86
84
|
prerelease: false
|
87
85
|
requirement: &id005 !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
86
|
requirements:
|
90
87
|
- - ">="
|
91
88
|
- !ruby/object:Gem::Version
|
92
|
-
hash: 3
|
93
89
|
segments:
|
94
90
|
- 0
|
95
91
|
version: "0"
|
@@ -99,11 +95,9 @@ dependencies:
|
|
99
95
|
name: rake
|
100
96
|
prerelease: false
|
101
97
|
requirement: &id006 !ruby/object:Gem::Requirement
|
102
|
-
none: false
|
103
98
|
requirements:
|
104
99
|
- - ">="
|
105
100
|
- !ruby/object:Gem::Version
|
106
|
-
hash: 3
|
107
101
|
segments:
|
108
102
|
- 0
|
109
103
|
version: "0"
|
@@ -113,11 +107,9 @@ dependencies:
|
|
113
107
|
name: rspec
|
114
108
|
prerelease: false
|
115
109
|
requirement: &id007 !ruby/object:Gem::Requirement
|
116
|
-
none: false
|
117
110
|
requirements:
|
118
111
|
- - ">="
|
119
112
|
- !ruby/object:Gem::Version
|
120
|
-
hash: 3
|
121
113
|
segments:
|
122
114
|
- 0
|
123
115
|
version: "0"
|
@@ -167,24 +159,14 @@ files:
|
|
167
159
|
- lib/mogli/post.rb
|
168
160
|
- lib/mogli/profile.rb
|
169
161
|
- lib/mogli/status.rb
|
162
|
+
- lib/mogli/subscription.rb
|
170
163
|
- lib/mogli/television.rb
|
171
164
|
- lib/mogli/test_user.rb
|
172
165
|
- lib/mogli/user.rb
|
173
166
|
- lib/mogli/video.rb
|
174
167
|
- lib/mogli/work.rb
|
175
168
|
- lib/mogli.rb
|
176
|
-
|
177
|
-
- spec/authenticator_spec.rb
|
178
|
-
- spec/client/client_event_spec.rb
|
179
|
-
- spec/client/client_user_spec.rb
|
180
|
-
- spec/client_spec.rb
|
181
|
-
- spec/fetching_array_spec.rb
|
182
|
-
- spec/model_spec.rb
|
183
|
-
- spec/page_spec.rb
|
184
|
-
- spec/profile_spec.rb
|
185
|
-
- spec/spec_helper.rb
|
186
|
-
- spec/test_user_spec.rb
|
187
|
-
- spec/user_spec.rb
|
169
|
+
has_rdoc: true
|
188
170
|
homepage: http://developers.facebook.com/docs/api
|
189
171
|
licenses: []
|
190
172
|
|
@@ -194,27 +176,23 @@ rdoc_options: []
|
|
194
176
|
require_paths:
|
195
177
|
- lib
|
196
178
|
required_ruby_version: !ruby/object:Gem::Requirement
|
197
|
-
none: false
|
198
179
|
requirements:
|
199
180
|
- - ">="
|
200
181
|
- !ruby/object:Gem::Version
|
201
|
-
hash: 3
|
202
182
|
segments:
|
203
183
|
- 0
|
204
184
|
version: "0"
|
205
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
|
-
none: false
|
207
186
|
requirements:
|
208
187
|
- - ">="
|
209
188
|
- !ruby/object:Gem::Version
|
210
|
-
hash: 3
|
211
189
|
segments:
|
212
190
|
- 0
|
213
191
|
version: "0"
|
214
192
|
requirements: []
|
215
193
|
|
216
194
|
rubyforge_project:
|
217
|
-
rubygems_version: 1.
|
195
|
+
rubygems_version: 1.3.6
|
218
196
|
signing_key:
|
219
197
|
specification_version: 3
|
220
198
|
summary: Open Graph Library for Ruby
|