fleakr 0.7.0 → 0.7.1

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.
@@ -1,9 +1,9 @@
1
1
  module Fleakr
2
2
  module Objects # :nodoc:
3
-
3
+
4
4
  # = AuthenticationToken
5
5
  #
6
- # This class represents an authentication token used for API calls that
6
+ # This class represents an authentication token used for API calls that
7
7
  # require authentication before they can be used
8
8
  #
9
9
  # == Attributes
@@ -12,53 +12,53 @@ module Fleakr
12
12
  # [permissions] The permissions granted to this application (read / write / delete)
13
13
  #
14
14
  class AuthenticationToken
15
-
15
+
16
16
  include Fleakr::Support::Object
17
-
17
+
18
18
  flickr_attribute :value, :from => 'auth/token'
19
19
  flickr_attribute :permissions, :from => 'auth/perms'
20
20
  flickr_attribute :user_id, :from => 'auth/user@nsid'
21
- flickr_attribute :user_name, :from => 'auth/user@username'
21
+ flickr_attribute :user_name, :from => 'auth/user@username'
22
22
  flickr_attribute :full_name, :from => 'auth/user@fullname'
23
-
23
+
24
24
  # Retrieve a full authentication token from the supplied mini-token (e.g. 123-456-789)
25
25
  #
26
26
  def self.from_mini_token(mini_token)
27
27
  from :mini_token, mini_token
28
28
  end
29
-
29
+
30
30
  # Retrieve a full authentication token from the supplied auth_token string
31
31
  # (e.g. 45-76598454353455)
32
- #
32
+ #
33
33
  def self.from_auth_token(auth_token)
34
34
  from :auth_token, auth_token
35
35
  end
36
-
36
+
37
37
  # Retrieve a full authentication token from the supplied frob
38
38
  def self.from_frob(frob)
39
39
  from :frob, frob
40
40
  end
41
-
41
+
42
42
  def self.from(thing, value) # :nodoc:
43
43
  api_methods = {
44
44
  :mini_token => 'getFullToken',
45
45
  :auth_token => 'checkToken',
46
46
  :frob => 'getToken'
47
47
  }
48
-
48
+
49
49
  method = "auth.#{api_methods[thing]}"
50
-
50
+
51
51
  parameters = {thing => value, :authenticate? => false}
52
52
  response = Fleakr::Api::MethodRequest.with_response!(method, parameters)
53
-
53
+
54
54
  self.new(response.body)
55
55
  end
56
-
56
+
57
57
  def user
58
- User.find_by_id(user_id)
58
+ User.find_by_id(user_id, :auth_token => value)
59
59
  end
60
-
60
+
61
61
  end
62
-
62
+
63
63
  end
64
64
  end
@@ -3,7 +3,7 @@ module Fleakr
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 7
6
- TINY = 0
6
+ TINY = 1
7
7
 
8
8
  def self.to_s
9
9
  [MAJOR, MINOR, TINY].join('.')
@@ -44,8 +44,9 @@ module Fleakr::Objects
44
44
  should "have an associated user" do
45
45
  token = AuthenticationToken.new
46
46
  token.stubs(:user_id).with().returns('1')
47
+ token.stubs(:value).with().returns('auth_token')
47
48
 
48
- User.expects(:find_by_id).with('1').returns('user')
49
+ User.expects(:find_by_id).with('1', :auth_token => 'auth_token').returns('user')
49
50
 
50
51
  token.user.should == 'user'
51
52
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 0
9
- version: 0.7.0
8
+ - 1
9
+ version: 0.7.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Patrick Reagan
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-14 00:00:00 -07:00
17
+ date: 2011-01-16 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency