Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first 'release'

- gemspec
- updating readme
- calls to Me and other nested relationships inherit better
  • Loading branch information...
commit 50dc0758a4d21dd55e6c9d58fcd2ce56a7599308 1 parent 0af2429
@holman authored
View
1  .gitignore
@@ -3,3 +3,4 @@ pkg
doc
.DS_Store
Rakefile
+Manifest.txt
View
26 README.markdown
@@ -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.
## 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
+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
(The MIT License)
View
21 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
View
76 lib/brightkitey.rb
@@ -2,16 +2,27 @@
require 'activeresource'
module Brightkitey
- VERSION = '0.0.1'
+ VERSION = '0.1.0'
+
+ attr_accessor :logged_in
class << self
def authenticate(options)
Brightkitey::Base.user = options[:user]
Brightkitey::Base.password = options[:password]
Brightkitey::Me.person
+ @logged_in = true
rescue ActiveResource::UnauthorizedAccess
false
end
+
+ def logged_in?
+ @logged_in == true
+ end
+
+ def me
+ Brightkitey::Me.person
+ end
end
class Base < ActiveResource::Base
@@ -34,37 +45,6 @@ class Comment < Base
class DirectMessage < Base
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
end
@@ -77,10 +57,6 @@ def checkins
Checkin.find(:all, :from => "/people/#{login}/objects.xml", :params => {:filters => :checkins})
end
- def checkins
- Note.find(:all, :from => "/people/#{login}/objects.xml", :params => {:filters => :notes})
- end
-
def photos
Photo.find(:all, :from => "/people/#{login}/objects.xml", :params => {:filters => :photos})
end
@@ -102,6 +78,9 @@ def self.search(query)
end
end
+ class Friend < Person
+ end
+
class Photo < Base
self.element_name = 'object'
@@ -120,4 +99,29 @@ def self.search(query)
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
Please sign in to comment.
Something went wrong with that request. Please try again.