holman-brightkitey 0.1.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.
- data/README.markdown +58 -0
- data/lib/brightkitey.rb +127 -0
- metadata +64 -0
data/README.markdown
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
## brightkitey
|
2
|
+
|
3
|
+
by [Zach Holman](http://zachholman.com) ([brightkite](http://brightkite.com/people/holman))
|
4
|
+
|
5
|
+
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.
|
6
|
+
|
7
|
+
## installation and usage
|
8
|
+
|
9
|
+
gem sources -a http://gems.github.com
|
10
|
+
sudo gem install holman-brightkitey
|
11
|
+
|
12
|
+
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:
|
13
|
+
|
14
|
+
### authentication
|
15
|
+
require 'rubygems'
|
16
|
+
require 'brightkitey'
|
17
|
+
|
18
|
+
Brightkitey.authenticate(:user => 'dr_strangelove', :password => 'cant-allow-gaps')
|
19
|
+
Brightkitey.logged_in? # quick login check
|
20
|
+
|
21
|
+
### brightkitein' around
|
22
|
+
|
23
|
+
me = Brightkitey.me
|
24
|
+
me.friends.first.checkins # => grab a friend's checkins
|
25
|
+
|
26
|
+
home = me.checkins.first.place
|
27
|
+
me.checkin(home) # => check yourself in at home
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
## thanks
|
32
|
+
|
33
|
+
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.
|
34
|
+
|
35
|
+
## license
|
36
|
+
|
37
|
+
(The MIT License)
|
38
|
+
|
39
|
+
Copyright (c) 2008 Zach Holman
|
40
|
+
|
41
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
42
|
+
a copy of this software and associated documentation files (the
|
43
|
+
'Software'), to deal in the Software without restriction, including
|
44
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
45
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
46
|
+
permit persons to whom the Software is furnished to do so, subject to
|
47
|
+
the following conditions:
|
48
|
+
|
49
|
+
The above copyright notice and this permission notice shall be
|
50
|
+
included in all copies or substantial portions of the Software.
|
51
|
+
|
52
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
53
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
54
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
55
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
56
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
57
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
58
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/brightkitey.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'activeresource'
|
3
|
+
|
4
|
+
module Brightkitey
|
5
|
+
VERSION = '0.1.0'
|
6
|
+
|
7
|
+
attr_accessor :logged_in
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def authenticate(options)
|
11
|
+
Brightkitey::Base.user = options[:user]
|
12
|
+
Brightkitey::Base.password = options[:password]
|
13
|
+
Brightkitey::Me.person
|
14
|
+
@logged_in = true
|
15
|
+
rescue ActiveResource::UnauthorizedAccess
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
19
|
+
def logged_in?
|
20
|
+
@logged_in == true
|
21
|
+
end
|
22
|
+
|
23
|
+
def me
|
24
|
+
Brightkitey::Me.person
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Base < ActiveResource::Base
|
29
|
+
def self.inherited(base)
|
30
|
+
base.site = "http://brightkite.com/"
|
31
|
+
base.element_name = base.to_s.split('::').last.downcase
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Block < Base
|
37
|
+
end
|
38
|
+
|
39
|
+
class Checkin < Base
|
40
|
+
end
|
41
|
+
|
42
|
+
class Comment < Base
|
43
|
+
end
|
44
|
+
|
45
|
+
class DirectMessage < Base
|
46
|
+
end
|
47
|
+
|
48
|
+
class Note < Base
|
49
|
+
end
|
50
|
+
|
51
|
+
class Objekt < Base
|
52
|
+
self.element_name = 'object'
|
53
|
+
end
|
54
|
+
|
55
|
+
class Person < Base
|
56
|
+
def checkins
|
57
|
+
Checkin.find(:all, :from => "/people/#{login}/objects.xml", :params => {:filters => :checkins})
|
58
|
+
end
|
59
|
+
|
60
|
+
def photos
|
61
|
+
Photo.find(:all, :from => "/people/#{login}/objects.xml", :params => {:filters => :photos})
|
62
|
+
end
|
63
|
+
|
64
|
+
def objects(options = {})
|
65
|
+
Objekt.find(:all, :from => "/people/#{login}/search.xml", :params => options)
|
66
|
+
end
|
67
|
+
|
68
|
+
def friends
|
69
|
+
Friend.find(:all, :from => "/people/#{login}/friends.xml")
|
70
|
+
end
|
71
|
+
|
72
|
+
def pending_friends
|
73
|
+
Friend.find(:all, :from => "/people/#{login}/pending_friends.xml")
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.search(query)
|
77
|
+
Person.find(:all, :from => "/people/search.xml", :params => {:query => query})
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class Friend < Person
|
82
|
+
end
|
83
|
+
|
84
|
+
class Photo < Base
|
85
|
+
self.element_name = 'object'
|
86
|
+
|
87
|
+
def comments
|
88
|
+
Comment.find(:all, :from => "/objects/#{id}/comments")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class Place < Base
|
93
|
+
def checkins
|
94
|
+
Checkin.find(:all, :params => options.update(:project_id => id))
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.search(query)
|
98
|
+
Place.find(:all, :from => :search, :params => {:q => query})
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class Me < Person
|
103
|
+
def self.person
|
104
|
+
Me.find(:one, :from => '/me.xml')
|
105
|
+
end
|
106
|
+
|
107
|
+
def sent_messages
|
108
|
+
DirectMessage.find(:all, :from => '/me/sent_messages.xml')
|
109
|
+
end
|
110
|
+
|
111
|
+
def received_messages
|
112
|
+
DirectMessage.find(:all, :from => '/me/received_messages.xml')
|
113
|
+
end
|
114
|
+
|
115
|
+
def blocks
|
116
|
+
Block.find(:all, :from => '/me/blocked_people.xml')
|
117
|
+
end
|
118
|
+
|
119
|
+
def checkin(place)
|
120
|
+
place = place.id if place.kind_of?(Place)
|
121
|
+
Brightkitey::Place.connection.post("/places/#{place}/checkins",'')
|
122
|
+
rescue ActiveResource::Redirection
|
123
|
+
true
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: holman-brightkitey
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zach Holman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-11-20 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activeresource
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.1.0
|
23
|
+
version:
|
24
|
+
description: A cute little Ruby wrapper around Brightkite's API
|
25
|
+
email:
|
26
|
+
- ""
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files: []
|
32
|
+
|
33
|
+
files:
|
34
|
+
- README.markdown
|
35
|
+
- lib/brightkitey.rb
|
36
|
+
has_rdoc: false
|
37
|
+
homepage: http://github.com/holman/brightkitey
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options:
|
40
|
+
- --main
|
41
|
+
- README.markdown
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
version:
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
rubyforge_project: ""
|
59
|
+
rubygems_version: 1.2.0
|
60
|
+
signing_key:
|
61
|
+
specification_version: 2
|
62
|
+
summary: A cute little Ruby wrapper around Brightkite's API
|
63
|
+
test_files: []
|
64
|
+
|