mogli 0.0.44 → 0.0.45

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.
@@ -62,7 +62,7 @@ module Mogli
62
62
  end
63
63
 
64
64
  def raise_exception_if_required(response)
65
- raise Mogli::Client::HTTPException if response.code != 200
65
+ raise Mogli::Client::HTTPException, response.body if response.code != 200
66
66
  end
67
67
 
68
68
  end
@@ -11,7 +11,7 @@ module Mogli
11
11
  include Mogli::Client::Event
12
12
  include Mogli::Client::User
13
13
 
14
- class ClientException < Exception; end
14
+ class ClientException < StandardError; end
15
15
  class UnrecognizeableClassError < ClientException; end
16
16
  class QueryParseException < ClientException; end
17
17
  class OAuthAccessTokenException < ClientException; end
@@ -1,10 +1,11 @@
1
1
  module Mogli
2
-
2
+
3
3
  # requires read_friendlists permission
4
4
  # https://developers.facebook.com/docs/reference/api/FriendList/
5
-
5
+
6
6
  class FriendList < Model
7
7
  define_properties :name, :list_type, :id
8
-
8
+
9
+ has_association :members, "User"
9
10
  end
10
- end
11
+ end
@@ -109,6 +109,7 @@ module Mogli
109
109
  end
110
110
 
111
111
  add_creation_method(method_name,klass)
112
+ (@populating_accessors ||= []) << method_name
112
113
  end
113
114
 
114
115
  def self.hash_populating_accessor_with_default_field(method_name,default_field,*klass)
@@ -121,6 +122,7 @@ module Mogli
121
122
  end
122
123
 
123
124
  add_creation_method(method_name,klass)
125
+ (@populating_accessors ||= []) << method_name
124
126
  end
125
127
 
126
128
  def self.add_creation_method(name,klass)
@@ -146,11 +148,12 @@ module Mogli
146
148
  end
147
149
 
148
150
  add_creation_method(name,klass)
151
+ (@associations ||= []) << name
149
152
  end
150
153
 
151
- def fetch()
154
+ def fetch(*fields)
152
155
  raise ArgumentError.new("You cannot fetch models without a populated id attribute") if id.nil?
153
- other = self.class.find(id,client)
156
+ other = self.class.find(id,client,fields)
154
157
  merge!(other) if other
155
158
  self
156
159
  end
@@ -161,6 +164,12 @@ module Mogli
161
164
 
162
165
  def merge!(other)
163
166
  @_values.merge!(other.instance_variable_get("@_values"))
167
+ # We need to copy not only root values, but, for example, user.location
168
+ ( (self.class.instance_variable_get("@populating_accessors") || []) +
169
+ (self.class.instance_variable_get("@associations") || [])).each do |var_name|
170
+
171
+ instance_variable_set("@#{var_name}", other.instance_variable_get("@#{var_name}"))
172
+ end
164
173
  end
165
174
 
166
175
  def self.recognize?(data)
@@ -30,7 +30,7 @@ module Mogli
30
30
  hash.has_key?("category")
31
31
  end
32
32
 
33
- class MissingAccessToken < Exception
33
+ class MissingAccessToken < StandardError
34
34
  end
35
35
 
36
36
  end
@@ -33,13 +33,14 @@ module Mogli
33
33
  has_association :home, "Post"
34
34
  has_association :accounts, "Page"
35
35
  has_association :apprequests, "AppRequest"
36
+ has_association :friendlists, "FriendList"
36
37
 
37
38
  has_association :events, "Event"
38
39
 
39
40
  attr_reader :extended_permissions
40
41
 
41
42
  # raised when asked to check for a permission that mogli doesn't know about
42
- class UnrecognizedExtendedPermissionException < Exception; end
43
+ class UnrecognizedExtendedPermissionException < StandardError; end
43
44
 
44
45
  # the entire list of extended permissions the user is able to grant the
45
46
  # application. the list should be kept in sync with
@@ -95,7 +95,8 @@ describe Mogli::Authenticator do
95
95
  it "raises an error if not a 200" do
96
96
  response = mock('HTTParty::Response',
97
97
  :parsed_response => "access_token=123456|3SDdfgdfgv0bbEvYjBH5tJtl-dcBdsfgo",
98
- :code => 500)
98
+ :code => 500,
99
+ :body => 'error')
99
100
 
100
101
  Mogli::Client.should_receive(:post).and_return(response)
101
102
  lambda do
@@ -114,7 +114,7 @@ describe Mogli::Client do
114
114
  Mogli::Client.should_receive(:get).with("url").and_return(mock_response)
115
115
  begin
116
116
  client = Mogli::Client.create_from_code_and_authenticator("code",mock("auth",:access_token_url=>"url"))
117
- rescue Exception => e
117
+ rescue => e
118
118
  e.message.should == "#{err_type}: #{err_msg}"
119
119
  end
120
120
  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.44
4
+ version: 0.0.45
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-30 00:00:00.000000000 Z
12
+ date: 2013-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie
@@ -64,23 +64,17 @@ dependencies:
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: 1.0.3
70
- - - <
67
+ - - ~>
71
68
  - !ruby/object:Gem::Version
72
- version: '1.4'
69
+ version: 1.7.8
73
70
  type: :runtime
74
71
  prerelease: false
75
72
  version_requirements: !ruby/object:Gem::Requirement
76
73
  none: false
77
74
  requirements:
78
- - - ! '>='
79
- - !ruby/object:Gem::Version
80
- version: 1.0.3
81
- - - <
75
+ - - ~>
82
76
  - !ruby/object:Gem::Version
83
- version: '1.4'
77
+ version: 1.7.8
84
78
  - !ruby/object:Gem::Dependency
85
79
  name: json
86
80
  requirement: !ruby/object:Gem::Requirement
@@ -212,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
206
  version: '0'
213
207
  requirements: []
214
208
  rubyforge_project:
215
- rubygems_version: 1.8.24
209
+ rubygems_version: 1.8.25
216
210
  signing_key:
217
211
  specification_version: 3
218
212
  summary: Open Graph Library for Ruby