Skip to content

Commit

Permalink
first 'release'
Browse files Browse the repository at this point in the history
- gemspec
- updating readme
- calls to Me and other nested relationships inherit better
  • Loading branch information
holman committed Nov 21, 2008
1 parent 0af2429 commit 50dc075
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@ pkg
doc doc
.DS_Store .DS_Store
Rakefile Rakefile
Manifest.txt
26 changes: 25 additions & 1 deletion README.markdown
Expand Up @@ -5,9 +5,33 @@ by [Zach Holman](http://zachholman.com) ([brightkite](http://brightkite.com/peop
brightkitey is a cute little wrapper around Brightkite's API. It's possibly horribly broken and incomplete, but it's getting there. Pull requests welcome and appreciated. brightkitey is a cute little wrapper around Brightkite's API. It's possibly horribly broken and incomplete, but it's getting there. Pull requests welcome and appreciated.


## installation and usage ## installation and usage


gem sources -a http://gems.github.com
sudo gem install holman-brightkitey

To get a feel for what you're in for, check out the [Brightkite REST API](http://groups.google.com/group/brightkite-api/web/rest-api). The [object reference](http://groups.google.com/group/brightkite-api/web/api-object-reference) might be helpful, too. Some fun things you can do:

### authentication
require 'rubygems'
require 'brightkitey'

Brightkitey.authenticate(:user => 'dr_strangelove', :password => 'cant-allow-gaps')
Brightkitey.logged_in? # quick login check

### brightkitein' around

me = Brightkitey.me
me.friends.first.checkins # => grab a friend's checkins

home = me.checkins.first.place
me.checkin(home) # => check yourself in at home

Brightkitey::Place.search("arby's") # => mmmm... I'm thinking Arby's. If you're logged in, this'll pull in those closest to you first.

## thanks ## thanks


The official [Lighthouse](http://github.com/Caged/lighthouse-api) wrapper was fairly helpful for a newbie like me to wrap my head around. Thankee, Justin.

## license ## license


(The MIT License) (The MIT License)
Expand Down
21 changes: 21 additions & 0 deletions brightkitey.gemspec
@@ -0,0 +1,21 @@
Gem::Specification.new do |s|
s.name = %q{brightkitey}
s.version = "0.1.0"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Zach Holman"]
s.date = %q{2008-11-20}
s.description = %q{A cute little Ruby wrapper around Brightkite's API}
s.email = [""]
s.files = ["README.markdown", "lib/brightkitey.rb"]
s.has_rdoc = false
s.homepage = %q{http://github.com/holman/brightkitey}
s.rdoc_options = ["--main", "README.markdown"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{}
s.rubygems_version = %q{1.2.0}
s.summary = %q{A cute little Ruby wrapper around Brightkite's API}
s.test_files = []

s.add_dependency(%q<activeresource>, [">= 2.1.0"])
end
76 changes: 40 additions & 36 deletions lib/brightkitey.rb
Expand Up @@ -2,16 +2,27 @@
require 'activeresource' require 'activeresource'


module Brightkitey module Brightkitey
VERSION = '0.0.1' VERSION = '0.1.0'

attr_accessor :logged_in


class << self class << self
def authenticate(options) def authenticate(options)
Brightkitey::Base.user = options[:user] Brightkitey::Base.user = options[:user]
Brightkitey::Base.password = options[:password] Brightkitey::Base.password = options[:password]
Brightkitey::Me.person Brightkitey::Me.person
@logged_in = true
rescue ActiveResource::UnauthorizedAccess rescue ActiveResource::UnauthorizedAccess
false false
end end

def logged_in?
@logged_in == true
end

def me
Brightkitey::Me.person
end
end end


class Base < ActiveResource::Base class Base < ActiveResource::Base
Expand All @@ -34,37 +45,6 @@ class Comment < Base
class DirectMessage < Base class DirectMessage < Base
end end


class Friend < Base
end

class Me < Base
def self.person
Me.find(:one, :from => '/me.xml')
end

def self.friends
Friend.find(:all, :from => '/me/friends.xml')
end

def self.sent_messages
DirectMessage.find(:all, :from => '/me/sent_messages.xml')
end

def self.received_messages
DirectMessage.find(:all, :from => '/me/received_messages.xml')
end

def self.blocks
Block.find(:all, :from => '/me/blocked_people.xml')
end

def self.checkin(place_id)
Brightkitey::Place.connection.post("/places/#{place_id}/checkins",'')
rescue ActiveResource::Redirection
true
end
end

class Note < Base class Note < Base
end end


Expand All @@ -77,10 +57,6 @@ def checkins
Checkin.find(:all, :from => "/people/#{login}/objects.xml", :params => {:filters => :checkins}) Checkin.find(:all, :from => "/people/#{login}/objects.xml", :params => {:filters => :checkins})
end end


def checkins
Note.find(:all, :from => "/people/#{login}/objects.xml", :params => {:filters => :notes})
end

def photos def photos
Photo.find(:all, :from => "/people/#{login}/objects.xml", :params => {:filters => :photos}) Photo.find(:all, :from => "/people/#{login}/objects.xml", :params => {:filters => :photos})
end end
Expand All @@ -102,6 +78,9 @@ def self.search(query)
end end
end end


class Friend < Person
end

class Photo < Base class Photo < Base
self.element_name = 'object' self.element_name = 'object'


Expand All @@ -120,4 +99,29 @@ def self.search(query)
end end
end end


class Me < Person
def self.person
Me.find(:one, :from => '/me.xml')
end

def sent_messages
DirectMessage.find(:all, :from => '/me/sent_messages.xml')
end

def received_messages
DirectMessage.find(:all, :from => '/me/received_messages.xml')
end

def blocks
Block.find(:all, :from => '/me/blocked_people.xml')
end

def checkin(place)
place = place.id if place.kind_of?(Place)
Brightkitey::Place.connection.post("/places/#{place}/checkins",'')
rescue ActiveResource::Redirection
true
end
end

end end

0 comments on commit 50dc075

Please sign in to comment.