login_radius 0.0.1 → 1.0.0

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.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/lib/hash.rb +12 -12
  3. data/lib/login_radius.rb +12 -11
  4. data/lib/login_radius/exception.rb +4 -4
  5. data/lib/login_radius/messages.rb +41 -102
  6. data/lib/login_radius/related.rb +34 -0
  7. data/lib/login_radius/user_profile.rb +101 -102
  8. data/lib/login_radius/user_profile_getters.rb +151 -105
  9. data/lib/login_radius/version.rb +3 -3
  10. data/lib/string.rb +7 -8
  11. metadata +20 -91
  12. data/.DS_Store +0 -0
  13. data/.gitignore +0 -18
  14. data/Gemfile +0 -25
  15. data/LICENSE +0 -22
  16. data/LoginRadiusTestApp/.gitignore +0 -15
  17. data/LoginRadiusTestApp/Gemfile +0 -42
  18. data/LoginRadiusTestApp/Gemfile.lock +0 -136
  19. data/LoginRadiusTestApp/README.rdoc +0 -261
  20. data/LoginRadiusTestApp/Rakefile +0 -7
  21. data/LoginRadiusTestApp/app/assets/images/rails.png +0 -0
  22. data/LoginRadiusTestApp/app/assets/javascripts/application.js +0 -15
  23. data/LoginRadiusTestApp/app/assets/stylesheets/application.css +0 -13
  24. data/LoginRadiusTestApp/app/controllers/application_controller.rb +0 -17
  25. data/LoginRadiusTestApp/app/helpers/application_helper.rb +0 -2
  26. data/LoginRadiusTestApp/app/mailers/.gitkeep +0 -0
  27. data/LoginRadiusTestApp/app/models/.gitkeep +0 -0
  28. data/LoginRadiusTestApp/app/views/application/callback.html.erb +0 -1
  29. data/LoginRadiusTestApp/app/views/application/index.html.erb +0 -7
  30. data/LoginRadiusTestApp/app/views/layouts/application.html.erb +0 -14
  31. data/LoginRadiusTestApp/config.ru +0 -4
  32. data/LoginRadiusTestApp/config/application.rb +0 -62
  33. data/LoginRadiusTestApp/config/boot.rb +0 -6
  34. data/LoginRadiusTestApp/config/database.yml +0 -25
  35. data/LoginRadiusTestApp/config/environment.rb +0 -5
  36. data/LoginRadiusTestApp/config/environments/development.rb +0 -37
  37. data/LoginRadiusTestApp/config/environments/production.rb +0 -67
  38. data/LoginRadiusTestApp/config/environments/test.rb +0 -37
  39. data/LoginRadiusTestApp/config/initializers/backtrace_silencers.rb +0 -7
  40. data/LoginRadiusTestApp/config/initializers/inflections.rb +0 -15
  41. data/LoginRadiusTestApp/config/initializers/mime_types.rb +0 -5
  42. data/LoginRadiusTestApp/config/initializers/secret_token.rb +0 -7
  43. data/LoginRadiusTestApp/config/initializers/session_store.rb +0 -8
  44. data/LoginRadiusTestApp/config/initializers/wrap_parameters.rb +0 -14
  45. data/LoginRadiusTestApp/config/locales/en.yml +0 -5
  46. data/LoginRadiusTestApp/config/routes.rb +0 -61
  47. data/LoginRadiusTestApp/db/seeds.rb +0 -7
  48. data/LoginRadiusTestApp/lib/assets/.gitkeep +0 -0
  49. data/LoginRadiusTestApp/lib/tasks/.gitkeep +0 -0
  50. data/LoginRadiusTestApp/log/.gitkeep +0 -0
  51. data/LoginRadiusTestApp/public/404.html +0 -26
  52. data/LoginRadiusTestApp/public/422.html +0 -26
  53. data/LoginRadiusTestApp/public/500.html +0 -25
  54. data/LoginRadiusTestApp/public/favicon.ico +0 -0
  55. data/LoginRadiusTestApp/public/robots.txt +0 -5
  56. data/LoginRadiusTestApp/script/rails +0 -6
  57. data/LoginRadiusTestApp/test/fixtures/.gitkeep +0 -0
  58. data/LoginRadiusTestApp/test/functional/.gitkeep +0 -0
  59. data/LoginRadiusTestApp/test/integration/.gitkeep +0 -0
  60. data/LoginRadiusTestApp/test/performance/browsing_test.rb +0 -12
  61. data/LoginRadiusTestApp/test/test_helper.rb +0 -13
  62. data/LoginRadiusTestApp/test/unit/.gitkeep +0 -0
  63. data/LoginRadiusTestApp/vendor/assets/javascripts/.gitkeep +0 -0
  64. data/LoginRadiusTestApp/vendor/assets/stylesheets/.gitkeep +0 -0
  65. data/LoginRadiusTestApp/vendor/plugins/.gitkeep +0 -0
  66. data/README.md +0 -417
  67. data/Rakefile +0 -2
  68. data/login_radius.gemspec +0 -20
  69. data/test/.DS_Store +0 -0
  70. data/test/basic_async_test.rb +0 -29
  71. data/test/unit/.DS_Store +0 -0
  72. data/test/unit/base_test.rb +0 -11
  73. data/test/unit/user_profile_test.rb +0 -68
@@ -1,7 +0,0 @@
1
- # This file should contain all the record creation needed to seed the database with its default values.
2
- # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
- #
4
- # Examples:
5
- #
6
- # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
- # Mayor.create(name: 'Emanuel', city: cities.first)
File without changes
File without changes
File without changes
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/422.html -->
21
- <div class="dialog">
22
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/500.html -->
21
- <div class="dialog">
22
- <h1>We're sorry, but something went wrong.</h1>
23
- </div>
24
- </body>
25
- </html>
File without changes
@@ -1,5 +0,0 @@
1
- # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
- #
3
- # To ban all spiders from the entire site uncomment the next two lines:
4
- # User-Agent: *
5
- # Disallow: /
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'
File without changes
File without changes
File without changes
@@ -1,12 +0,0 @@
1
- require 'test_helper'
2
- require 'rails/performance_test_help'
3
-
4
- class BrowsingTest < ActionDispatch::PerformanceTest
5
- # Refer to the documentation for all available options
6
- # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
7
- # :output => 'tmp/performance', :formats => [:flat] }
8
-
9
- def test_homepage
10
- get '/'
11
- end
12
- end
@@ -1,13 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
- require File.expand_path('../../config/environment', __FILE__)
3
- require 'rails/test_help'
4
-
5
- class ActiveSupport::TestCase
6
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7
- #
8
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
- # -- they do not yet inherit this setting
10
- fixtures :all
11
-
12
- # Add more helper methods to be used by all tests here...
13
- end
File without changes
File without changes
data/README.md DELETED
@@ -1,417 +0,0 @@
1
- # LoginRadius
2
-
3
- Ruby wrapper for the LoginRadius API. Get social graph information and send messages using LoginRadius'
4
- many social network clients!
5
-
6
- Optional Asynchronous EventMachine friendly option!
7
-
8
- ## Installation
9
-
10
- Add this line to your application's Gemfile:
11
-
12
- gem 'login_radius'
13
-
14
- And then execute:
15
-
16
- $ bundle
17
-
18
- Or install it yourself as:
19
-
20
- $ gem install login_radius
21
-
22
- ## Usage
23
-
24
- Take a peek:
25
-
26
- @user_profile = LoginRadius::UserProfile.new({
27
- :token => "TOKEN",
28
- :secret => "SECRET",
29
- :async => false #Set to true if using EventMachine driven frameworks(must use Em Synchrony)
30
- })
31
- @user_profile.login
32
- my_contacts = @user_profile.contacts
33
-
34
- That's right, folks. It's that simple. In order to get access to LoginRadius API, you only
35
- need to create a UserProfile object with a user's login token and your apps secret, and login.
36
-
37
- ### How to get a token and actually make a client
38
-
39
- On the LoginRadius website, you are able to enter your own callback URL for your app. You will need
40
- to setup a route on whatever framework you use, maybe "/callback." Then, get the gem forward(www.forwardhq.com)
41
- and use it to set up a public web address for your localhost server. Then, you can enter the callback on LoginRadius
42
- as https://jordanmatthew.fwd.wf/callback, for instance.
43
-
44
- Paste their example login stuff onto your index page, and then enter your FB/Twitter credentials on their site.
45
-
46
- Now you're ready to go with testing!
47
-
48
- When LoginRadius hits your callback after a user logs in, you'll see parameters like this:
49
-
50
- Parameters: {"token"=>"yourtokenhere"}
51
-
52
- This token is the token used in the above example. This is what you'll need to get your user's profile.
53
- Just paste it into the code above, and you can immediately grab their user profile on the callback,
54
- login, and grab their contacts.
55
-
56
- ### Some examples
57
-
58
- Below is just code exemplifying some of the more interesting methods and what they return.
59
- Note if you have a user authed via facebook, and not twitter, methods like
60
-
61
- @user_profile.twitter_timeline
62
- => false
63
-
64
- Will return false, indicating you don't have access to that stream.
65
-
66
- #### Facebook Stuff
67
-
68
- @user_profile.facebook_groups
69
- => [{:id=>"11111", :name=>"Name"},
70
- {:id=>"11111", :name=>"Name"},
71
- {:id=>"11111", :name=>"Name"},
72
- {:id=>"11111", :name=>"Name"},
73
- {:id=>"11111", :name=>"Name"},
74
- {:id=>"11111", :name=>"Name"},
75
- {:id=>"11111", :name=>"Name"},
76
- {:id=>"11111", :name=>"Name"},
77
- {:id=>"11111", :name=>"Name"}]
78
-
79
- @user_profile.facebook_groups
80
- => [{:id=>"11111", :name=>"Name"},
81
- {:id=>"11111", :name=>"Name"}]
82
-
83
-
84
- @user_profile.facebook_events
85
- => [{:id=>"11111",
86
- :name=>"Name",
87
- :start_time=>"3/14/2015 9:00:00 AM",
88
- :rsvp_status=>"attending",
89
- :location=>"Across the world!"}]
90
-
91
- And, finally, you can also make facebook posts:
92
-
93
- params = {
94
- :title => "Testing",
95
- :url => "www.loginradius.com",
96
- :status => "Wizzup",
97
- :caption => "Testly",
98
- :description => "Testing"
99
- }
100
- @user_profile.make_facebook_post(params)
101
- => true
102
-
103
- Note that as of publishing, the :to option on facebook params does not work. You can't post to
104
- other people's walls.
105
-
106
- #### LinkedIn Stuff
107
-
108
- To send messages over linked in:
109
-
110
- @user_profile.send_linked_in_message(@user_profile.contacts.first[:id], "Testing", "This is a test.")
111
- => true
112
-
113
- Notice how I grabbed my first contact and used his :id property.
114
-
115
- Also, you can grab a user's linked in companies:
116
-
117
- @user_profile.linked_in_companies
118
- => [{:id=>11111, :name=>"Name"}]
119
-
120
- #### Twitter Stuff
121
-
122
- To send messages over twitter:
123
-
124
- @user_profile.send_linked_in_message(@user_profile.contacts.first[:id], "Testing", "This is a test.")
125
- => true
126
-
127
- Notice how I grabbed my first contact and used his :id property.
128
-
129
- Grab your timelines and mentions:
130
-
131
- @user_profile.twitter_timeline
132
- => [{:id=>"11111",
133
- :text=>"Stuff",
134
- :date_time=>"5/20/2013 4:53:52 PM",
135
- :likes=>0,
136
- :place=>"",
137
- :source=>
138
- "<a href=\"http://twitterfeed.com\" rel=\"nofollow\">twitterfeed</a>",
139
- :image_url=>nil,
140
- :link_url=>nil,
141
- :name=>"Name"}]
142
-
143
- @user_profile.twitter_mentions
144
- => [{:id=>"11111",
145
- :text=>"Stuff",
146
- :date_time=>"3/31/2013 7:54:10 PM",
147
- :likes=>0,
148
- :place=>"",
149
- :source=>"web",
150
- :image_url=>nil,
151
- :link_url=>nil,
152
- :name=>"Name"}]
153
-
154
- #### Social Network Contacts
155
-
156
- Note this is all the contacts from every social network the user is connected to.
157
-
158
- @user_profile.contacts
159
- => [{:name=>"Name",
160
- :email_id=>"",
161
- :phone_number=>"",
162
- :id=>"11111",
163
- :profile_url=>nil,
164
- :image_url=>nil,
165
- :status=>nil,
166
- :industry=>nil,
167
- :country=>nil,
168
- :gender=>nil}]
169
-
170
- #### User Profile Stuff
171
-
172
- When you login, the API returns a hash of user profile information, which is then turned into methods
173
- on the LoginRadius::UserProfile object for your accessing pleasure. A quick call to methods will show this.
174
-
175
- @user_profile.methods
176
- =>[:id,
177
- :provider,
178
- :prefix,
179
- :first_name,
180
- :middle_name,
181
- :last_name,
182
- :suffix,
183
- :full_name,
184
- :nick_name,
185
- :profile_name,
186
- :birth_date,
187
- :gender,
188
- :website,
189
- :email,
190
- :country,
191
- ...]
192
-
193
- Calling .methods on a user profile right after a successful login call will reveal these.
194
- For more information, please read the section in caveats on the matter, as it's a bit esoteric.
195
-
196
- ## Caveats
197
-
198
- This section is for the nitpickers. It's got notes about the finer pickings of this API for those
199
- who are wondering, but is not strictly necessary reading.
200
-
201
- ### The Bang Methods
202
-
203
- When authenticated, a method like contacts will return
204
-
205
- @user_profile.authenticated?
206
- => true
207
- @user_profile.contacts
208
- => [{:name=>"Name",
209
- :email_id=>"",
210
- :phone_number=>"",
211
- :id=>"11111",
212
- :profile_url=>nil,
213
- :image_url=>nil,
214
- :status=>nil,
215
- :industry=>nil,
216
- :country=>nil,
217
- :gender=>nil},
218
- ...
219
-
220
- When unauthenticated, a method like contacts will return false.
221
-
222
- @user_profile.authenticated?
223
- => false
224
- @user_profile.contacts
225
- => false
226
-
227
- However, if you want to be a bit more flammable, try using contacts!, the bang version. It still returns
228
- the same results when authed, but when unauthed, will actually raise a LoginRadius::Exception.
229
-
230
- ### The LoginRadius::UserProfile object before and after login
231
-
232
- Once you've got a valid user_profile, you have many methods available to you. Let's quickly take a look
233
- at the methods in a LoginRadius::UserProfile object that hasn't yet been authenticated:
234
-
235
- @user_profile.authenticated?
236
- => false
237
-
238
- @user_profile.methods - Object.new.methods
239
- => [:secret,
240
- :secret=,
241
- :token,
242
- :token=,
243
- :async,
244
- :async=,
245
- :guid_valid?,
246
- :authenticated?,
247
- :call_api,
248
- :send_twitter_message,
249
- :send_linkedin_message,
250
- :make_facebook_post,
251
- :login!,
252
- :login,
253
- :twitter_mentions!,
254
- :twitter_mentions,
255
- :twitter_timeline!,
256
- :twitter_timeline,
257
- :linked_in_companies!,
258
- :linked_in_companies,
259
- :contacts!,
260
- :contacts,
261
- :facebook_groups!,
262
- :facebook_groups,
263
- :facebook_posts!,
264
- :facebook_posts,
265
- :facebook_events!,
266
- :facebook_events]
267
-
268
- Notice we've got a lot of stuff we can access. But we're not yet authenticated. Running login and then checking
269
- the new methods created, we see we have much more than before!
270
-
271
- @user_profile.login
272
- => true
273
- @user_profile.authenticated?
274
- => true
275
- @user_profile.methods - Object.new.methods
276
- => [:id,
277
- :provider,
278
- :prefix,
279
- :first_name,
280
- :middle_name,
281
- :last_name,
282
- :suffix,
283
- :full_name,
284
- :nick_name,
285
- :profile_name,
286
- :birth_date,
287
- :gender,
288
- :website,
289
- :email,
290
- :country,
291
- :thumbnail_image_url,
292
- :image_url,
293
- :favicon,
294
- :profile_url,
295
- :home_town,
296
- :state,
297
- :city,
298
- :industry,
299
- :about,
300
- :time_zone,
301
- :local_language,
302
- :language,
303
- :verified,
304
- :updated_time,
305
- :positions,
306
- :educations,
307
- :phone_numbers,
308
- :im_accounts,
309
- :addresses,
310
- :main_address,
311
- :created,
312
- :local_city,
313
- :profile_city,
314
- :local_country,
315
- :profile_country,
316
- :relationship_status,
317
- :quota,
318
- :interested_in,
319
- :interests,
320
- :religion,
321
- :political,
322
- :sports,
323
- :inspirational_people,
324
- :https_image_url,
325
- :followers_count,
326
- :friends_count,
327
- :is_geo_enabled,
328
- :total_statuses_count,
329
- :associations,
330
- :num_recommenders,
331
- :honors,
332
- :skills,
333
- :current_status,
334
- :certifications,
335
- :courses,
336
- :volunteer,
337
- :recommendations_received,
338
- :languages,
339
- :public_repository,
340
- :hireable,
341
- :repository_url,
342
- :age,
343
- :patents,
344
- :favorite_things,
345
- :professional_headline,
346
- :provider_access_credential,
347
- :secret,
348
- :secret=,
349
- :token,
350
- :token=,
351
- :async,
352
- :async=,
353
- :guid_valid?,
354
- :authenticated?,
355
- :call_api,
356
- :send_twitter_message,
357
- :send_linkedin_message,
358
- :make_facebook_post,
359
- :login!,
360
- :login,
361
- :twitter_mentions!,
362
- :twitter_mentions,
363
- :twitter_timeline!,
364
- :twitter_timeline,
365
- :linked_in_companies!,
366
- :linked_in_companies,
367
- :contacts!,
368
- :contacts,
369
- :facebook_groups!,
370
- :facebook_groups,
371
- :facebook_posts!,
372
- :facebook_posts,
373
- :facebook_events!,
374
- :facebook_events]
375
-
376
- Holy moly we got a whole bunch of new methods! That's because on login, all the user profile information
377
- returned by the API is turned into dynamically generated GETTERs on the object that you can then use later.
378
-
379
- ### Running the tests in test/unit
380
-
381
- The base_test.rb file isn't meant to be run, it is inherited by user_profile_test.rb. In that file
382
- you'll notice the lines at the top of the file:
383
-
384
- TOKEN = "yourtokenhere"
385
- SECRET = "yoursecrethere"
386
-
387
- These are meant to be changed to your API secret and some user's token. What I do is I run a dummy
388
- rails app locally and use the forward gem so that it can receive requests from the internet. Then I setup
389
- a callback route and login page on the app and use it to have LoginRadius ping me with tokens that I can
390
- paste into this test file.
391
-
392
- *Beware, LoginRadius invalidates any token after 15 minutes, so during testing, you'll have to repeat the token
393
- creation A LOT*
394
-
395
- To run the tests, do:
396
-
397
- bundle exec ruby -Itest test/unit/user_profile_test.rb
398
-
399
- If you login with a facebook user, for instance, you'll notice all the twitter/linked in tests failing.
400
- This is to be expected, you don't have access to those streams!
401
-
402
- ### Evented Frameworks
403
-
404
- I've built this gem to work with frameworks like Cramp. I've done a little bit of testing by creating
405
- a basic event loop script in basic_async_test.rb in the test folder, which you can run to see that
406
- things work there.
407
-
408
- I've also done some AB testing using a Cramp framework elsewhere, but you should take caution in using
409
- this gem in evented frameworks and make sure to use apache bench to test it for nonblocking yourself.
410
-
411
- ## Contributing
412
-
413
- 1. Fork it
414
- 2. Create your feature branch (`git checkout -b my-new-feature`)
415
- 3. Commit your changes (`git commit -am 'Added some feature'`)
416
- 4. Push to the branch (`git push origin my-new-feature`)
417
- 5. Create new Pull Request