Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jnewland/ride_the_fireeagle
a Rails plugin that easily integrates your app with Fire Eagle
https://github.com/jnewland/ride_the_fireeagle
Last synced: about 16 hours ago
JSON representation
a Rails plugin that easily integrates your app with Fire Eagle
- Host: GitHub
- URL: https://github.com/jnewland/ride_the_fireeagle
- Owner: jnewland
- License: other
- Created: 2008-03-24T12:52:06.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2008-03-26T21:30:59.000Z (over 16 years ago)
- Last Synced: 2023-04-10T15:07:09.512Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 95.7 KB
- Stars: 15
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.textile
- License: COPYING
Awesome Lists containing this project
README
h2. Ride The FireEagle
This is a Rails plugin that easily integrates your app with "Fire Eagle":http://fireeagle.com/
For now, it only covers the ActiveRecord side of things. Full support for handling the entire authentication flow coming soon.
h3. Install
# @gem install fireeagle@
# @./script/generate ride_the_fireeagle User@
# @rake db:migrate@
# @mate config/fireeagle.yml@, add your FireEagle application info
# Add @ride_the_fireeagle@ to @/app/models/user.rb@h3. Usage
Once that's all done, your instances of @User@ have some fun new methods:
>> @user = User.create(:login => 'alice')
>> @user.authorized_with_fireeagle?
=> falseSo, this user hasn't linked their account to Fire Eagle yet. Send them to an action that does the following:
def activate_fireeagle
@user = User.find(params[:id])
@user.get_fireeagle_request_token
redirect_to @user.fireeagle_authorization_url
endNow you wait for the user to authorize. When they authorize, Fire Eagle will invoke your application callback URL with the request token appended as parameters.
def fireeagle_callback
@user = User.find_by_fireeagle_request_token(params[:oauth_token])
@user.authorize_with_fireeagle
endNow that user is authorized with Fire Eagle!
>> @user = User.find_by_login('alice')
>> @user.authorized_with_fireeagle?
=> trueYou can now update and query that user's location, assuming the User gave you those permissions when authorizing.
>> @user = User.find_by_login('alice')
>> @user.update_location(:q => "Atlanta, GA")
>> @user.location.name
=> "Atlanta, GA"More information about the acceptable parameters for updating a User's location is available in the RDoc for "FireEagle::Client#update":http://fireeagle.rubyforge.org/classes/FireEagle/Client.html
More information about 'location' response is available in the RDoc for "FireEagle::Location":http://fireeagle.rubyforge.org/classes/FireEagle/Location.html. The 'best guess' location is currently automatically selected and returned. We'd really appreciate it if you didn't call FireEagle to get a user's location on every page load - please cache locations for an appropriate length of time
Oh, and you get some pretty rad class-level finders too:
>> User.find_fireeagle_recent(:conditions => { :time => 'now' }, :limit => 10, :offset => 0)The call above returns a list of users of the application who have updated their location within the given amount of time. The @time@ condition is flexible, supported forms are 'now', 'yesterday', '12:00', '13:00', '1:00pm' and '2008-03-12 12:34:56'. (default: 'now')
>> User.find_fireeagle_within(:conditions => { :woe => "12796255" }, :limit => 10, :offset => 0)The call above takes a Place ID or a WoE ID and returns a list of users using your application who are within the bounding box of that location. Not for the faint of heart, this method is experimental and may not be stable.
The arrays of Users returned by both of the class level finders have their most recent location information cached fresh from Fire Eagle.
h3. Author
"Jesse Newland":http://jnewland.com/
h3. License
"WTFPL":http://sam.zoy.org/wtfpl/