rpx_now 0.6.17 → 0.6.18

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -1,23 +1,19 @@
1
- Problem
2
- =======
3
- - OpenID is complex, limited and hard to use for users
4
- - Facebook / Twitter / Myspace / Google / MS-LiveId / AOL connections require different libraries and knowledge
5
- - Multiple heterogenouse providers are hard to map to a single user
1
+ [RPX](http://rpxnow.com) allows users to login to your page through Facebook / Twitter / Myspace / Google / OpenId / MS-LiveId / AOL / ...
6
2
 
7
- Solution
8
- ========
9
- - Use [RPX](http://rpxnow.com) for universal and usable user login
10
- - Use view/controller helpers for easy integration
3
+ - Simpler then OpenId/OAuth/xxx for developers AND users
4
+ - Publish user activity to facebook/twitter/myspace/.../-stream
5
+ - Returning users are greeted by their provider
11
6
 
12
- ![Single Interface for all providers](https://rpxnow.com/images/how_diagram.png)
13
- ![Visitors choose from providers they already have](https://rpxnow.com/images/6providers.png?2)
7
+ ![Single Interface for all providers](https://s3.amazonaws.com/static.rpxnow.com/rel/img/a481ed2afccd255350cccd738050f873.png)
8
+ ![Share comments and activities](https://s3.amazonaws.com/static.rpxnow.com/rel/img/50bdccdb32b6ae68d46908a531492b28.png)
9
+ ![Visitors choose from providers they already have](https://s3.amazonaws.com/static.rpxnow.com/rel/img/f4a6e65808eefcf8754588c71f84c142.png)
14
10
 
15
11
  Usage
16
12
  =====
17
13
  - Get an API key @ [RPX](http://rpxnow.com)
18
14
  - run [MIGRATION](http://github.com/grosser/rpx_now/raw/master/MIGRATION)
19
15
  - Build login view
20
- - Communicate with RPX API in controller to create or login User
16
+ - Receive user-data from RPX to create or login User
21
17
  - for more advanced features have a look at the [RPX API Docs](https://rpxnow.com/docs)
22
18
 
23
19
  Install
@@ -71,25 +67,25 @@ Controller
71
67
  redirect_to '/'
72
68
  end
73
69
 
74
- # getting additional fields (these fields are rarely filled)
70
+ # getting additional profile fields (these fields are rarely filled)
75
71
  # all possibilities: https://rpxnow.com/docs#profile_data
76
72
  data = RPXNow.user_data(params[:token], :additional => [:gender, :birthday, :photo, :providerName, ...])
77
73
 
78
- # including raw profile data
79
- RPXNow.user_data(params[:token], :additional => [:raw])[:raw]['verifiedEmail']
74
+ # normal + raw data
75
+ RPXNow.user_data(params[:token], :additional => [:raw_response])[:raw_response]['profile]['verifiedEmail']
80
76
 
81
- # raw request processing
82
- RPXNow.user_data(params[:token]){|raw| {:email=>raw['profile']['verifiedEmail']} }
77
+ # only raw data
78
+ email = RPXNow.user_data(params[:token], :raw_response => true)['profile']['verifiedEmail']
83
79
 
84
- # raw request with extended parameters (most users and APIs do not supply them)
85
- RPXNow.user_data(params[:token], :extended=>'true'){|raw| ...have a look at the RPX API DOCS...}
80
+ # raw response with extended parameters (most users and APIs do not supply them)
81
+ RPXNow.user_data(params[:token], :extended => true, :raw_response => true)[ ...have a look at the RPX API DOCS... ]
86
82
 
87
83
  Advanced
88
84
  --------
89
- ###Versions
85
+ ### Versions
90
86
  RPXNow.api_version = 2
91
87
 
92
- ###Mappings
88
+ ### Mappings (PRX Plus/Pro)
93
89
  You can map your primary keys (e.g. user.id) to identifiers, so that
94
90
  users can login to the same account with multiple identifiers.
95
91
  RPXNow.map(identifier, primary_key) #add a mapping
@@ -101,7 +97,7 @@ After a primary key is mapped to an identifier, when a user logs in with this id
101
97
  `RPXNow.user_data` will contain his `primaryKey` as `:id`.
102
98
  A identifyer can only belong to one user (in doubt the last one it was mapped to)
103
99
 
104
- ###User integration (e.g. ActiveRecord)
100
+ ### User integration (e.g. ActiveRecord)
105
101
  class User < ActiveRecord::Base
106
102
  include RPXNow::UserIntegration
107
103
  end
@@ -110,17 +106,22 @@ A identifyer can only belong to one user (in doubt the last one it was mapped to
110
106
  user.rpx.map(identifier) == RPXNow.map(identifier, user.id)
111
107
  user.rpx.unmap(identifier) == RPXNow.unmap(identifier, user.id)
112
108
 
113
- ###Contacts (PRX Pro)
109
+ ### Contacts (PRX Pro)
114
110
  Retrieve all contacts for a given user:
115
111
  RPXNow.contacts(identifier).each {|c| puts "#{c['displayName']}: #{c['emails']}}
116
112
 
117
- ###Status updates (PRX Pro)
113
+ ### Status updates (PRX Plus/Pro)
118
114
  Send a status update to provider (a tweet/facebook-status/...) :
119
115
  RPXNow.set_status(identifier, "I just registered at yourdomain.com ...")
120
116
 
121
- TODO
122
- ====
123
- - add provider / credentials helpers ?
117
+ ### Activity (RPX Plus/Pro)
118
+ Post a users activity, on their e.g. Facebook profile, complete with images, titels, rating, additional media, customized links and so on ...
119
+ RPXNow.activity( identifier,
120
+ :url=>href, :action=>'Im loving my new', :user_generated_content=>'Im loving my new ... ',
121
+ :title=>product.title, :description=>product.description,
122
+ :action_links=>[{:text=>'view >>', :href=>product_url(product, :only_path => false)}],
123
+ :media=>[{:type=>:image, :src=>product.image_url, :href=>product_url(product, :only_path => false)}]
124
+ }
124
125
 
125
126
 
126
127
  Author
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.17
1
+ 0.6.18
data/lib/rpx_now.rb CHANGED
@@ -16,14 +16,18 @@ module RPXNow
16
16
  # - complete/unclean response when block was given user_data{|response| ...; return hash }
17
17
  # - nil when token was invalid / data was not found
18
18
  def user_data(token, options={})
19
- begin
20
- data = Api.call("auth_info", options.merge(:token => token))
21
- result = (block_given? ? yield(data) : parse_user_data(data, options))
22
- result.respond_to?(:with_indifferent_access) ? result.with_indifferent_access : result
19
+ options = options.dup
20
+ return_raw = options.delete(:raw_response)
21
+
22
+ data = begin
23
+ Api.call("auth_info", options.merge(:token => token))
23
24
  rescue ServerError
24
25
  return nil if $!.to_s=~/Data not found/
25
26
  raise
26
27
  end
28
+
29
+ result = (block_given? ? yield(data) : (return_raw ? data : parse_user_data(data, options)))
30
+ result.respond_to?(:with_indifferent_access) ? result.with_indifferent_access : result
27
31
  end
28
32
 
29
33
  # set the users status
@@ -137,7 +141,10 @@ module RPXNow
137
141
  data[:id] = user_data['primaryKey'] unless user_data['primaryKey'].to_s.empty?
138
142
  (options[:additional] || []).each do |key|
139
143
  if key == :raw
144
+ warn "RPXNow :raw is deprecated, please use :raw_response + e.g. data['raw_response']['profile']['verifiedEmail']"
140
145
  data[key] = user_data
146
+ elsif key == :raw_response
147
+ data[key] = response
141
148
  else
142
149
  data[key] = user_data[key.to_s]
143
150
  end
data/rpx_now.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rpx_now}
8
- s.version = "0.6.17"
8
+ s.version = "0.6.18"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2010-03-07}
12
+ s.date = %q{2010-04-10}
13
13
  s.email = %q{grosser.michael@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.markdown"
data/spec/rpx_now_spec.rb CHANGED
@@ -222,10 +222,16 @@ describe RPXNow do
222
222
  RPXNow.user_data('').should == expected
223
223
  end
224
224
 
225
- it "adds raw if i want it" do
225
+ it "deprecated: adds raw profile data if i want it" do
226
226
  RPXNow::Api.should_receive(:request).and_return @response
227
+ RPXNow.should_receive(:warn)
227
228
  RPXNow.user_data('',:additional => [:raw])[:raw]["verifiedEmail"].should == "grosser.michael@googlemail.com"
228
229
  end
230
+
231
+ it "adds raw data if i want it" do
232
+ RPXNow::Api.should_receive(:request).and_return @response
233
+ RPXNow.user_data('',:additional => [:raw_response])[:raw_response]['profile']["verifiedEmail"].should == "grosser.michael@googlemail.com"
234
+ end
229
235
 
230
236
  it "adds a :id when primaryKey was returned" do
231
237
  @response_body['profile']['primaryKey'] = "2"
@@ -263,9 +269,21 @@ describe RPXNow do
263
269
 
264
270
  it "can send additional parameters" do
265
271
  RPXNow::Api.should_receive(:request).
266
- with(anything, hash_including(:extended => 'true')).
272
+ with(anything, hash_including(:extended => true)).
273
+ and_return @response
274
+ RPXNow.user_data('', :extended=>true)
275
+ end
276
+
277
+ it "does not pass raw_response to RPX" do
278
+ RPXNow::Api.should_receive(:request).
279
+ with(anything, hash_not_including(:raw_response => true)).
267
280
  and_return @response
268
- RPXNow.user_data('',:extended=>'true')
281
+ RPXNow.user_data('', :raw_response=>true)
282
+ end
283
+
284
+ it "can return a raw_response" do
285
+ RPXNow::Api.should_receive(:request).and_return @response
286
+ RPXNow.user_data('', :raw_response=>true).should == @response_body.merge('stat' => 'ok')
269
287
  end
270
288
 
271
289
  # these 2 tests are kind of duplicates of the api_version/key tests,
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 17
9
- version: 0.6.17
8
+ - 18
9
+ version: 0.6.18
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Grosser
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-07 00:00:00 +01:00
17
+ date: 2010-04-10 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency