foursquare 0.0.1
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/History +1 -0
- data/LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +52 -0
- data/examples/fq_test_script.rb +7 -0
- data/lib/foursquare.rb +79 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/foursquare_spec.rb +7 -0
- data/spec/spec_helper.rb +2 -0
- metadata +75 -0
data/History
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1 - initial release
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Workperch Inc
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rubygems/specification'
|
4
|
+
require 'date'
|
5
|
+
require 'spec/rake/spectask'
|
6
|
+
|
7
|
+
spec = Gem::Specification.new do |s|
|
8
|
+
s.name = "foursquare"
|
9
|
+
s.version = "0.0.1"
|
10
|
+
s.author = "Jeremy Welch"
|
11
|
+
s.email = "hello@jeremyrwelch.com"
|
12
|
+
s.homepage = "http://jeremyrwelch.com"
|
13
|
+
s.description = s.summary = "A simple Ruby wrapper for the Foursquare API"
|
14
|
+
|
15
|
+
s.platform = Gem::Platform::RUBY
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.extra_rdoc_files = ["README.rdoc", "LICENSE", "History"]
|
18
|
+
|
19
|
+
# Uncomment this to add a dependency
|
20
|
+
# s.add_dependency "foo"
|
21
|
+
|
22
|
+
s.require_path = 'lib'
|
23
|
+
s.autorequire = 'foursquare'
|
24
|
+
s.files = %w(LICENSE README.rdoc Rakefile History) + Dir.glob("{lib,spec,script,examples}/**/*")
|
25
|
+
|
26
|
+
s.add_dependency('httparty', '0.4.3')
|
27
|
+
end
|
28
|
+
|
29
|
+
task :default => :spec
|
30
|
+
|
31
|
+
desc "Run specs"
|
32
|
+
Spec::Rake::SpecTask.new do |t|
|
33
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
34
|
+
t.spec_opts = %w(-fs --color)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
39
|
+
pkg.gem_spec = spec
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "install the gem locally"
|
43
|
+
task :install => [:package] do
|
44
|
+
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "create a gemspec file"
|
48
|
+
task :make_spec do
|
49
|
+
File.open("foursquare.gemspec", "w") do |file|
|
50
|
+
file.puts spec.to_ruby
|
51
|
+
end
|
52
|
+
end
|
data/lib/foursquare.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
class Foursquare
|
5
|
+
|
6
|
+
include HTTParty
|
7
|
+
base_uri 'api.foursquare.com'
|
8
|
+
format :xml
|
9
|
+
|
10
|
+
# auth user
|
11
|
+
def initialize(user,pass)
|
12
|
+
self.class.basic_auth user, pass
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
# test for response from Foursquare
|
17
|
+
def test
|
18
|
+
self.class.get("/v1/test")
|
19
|
+
end
|
20
|
+
|
21
|
+
# does not require auth
|
22
|
+
def cities
|
23
|
+
self.class.get("/v1/cities")
|
24
|
+
end
|
25
|
+
|
26
|
+
def venues(lat,long,radius="",limit="",query="")
|
27
|
+
self.class.get("/v1/venues?geolat=#{lat}&geolong=#{long}&r=#{radius}&l=#{limit}&q=#{query}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def tips(lat,long,limit)
|
31
|
+
self.class.get("/v1/tips?geolat=#{lat}&geolong=#{long}&l=#{limit}")
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
# require auth
|
36
|
+
def check_city(lat, long)
|
37
|
+
self.class.get("/v1/checkcity?geolat=#{lat}&geolong=#{long}")
|
38
|
+
end
|
39
|
+
|
40
|
+
def switch_city(city_id)
|
41
|
+
self.class.post("/v1/switchcity", :body => {:cityid => city_id})
|
42
|
+
end
|
43
|
+
|
44
|
+
def friend_checkins
|
45
|
+
self.class.get("/v1/checkins")
|
46
|
+
end
|
47
|
+
|
48
|
+
def checkin(vid,venue,shout,private_checkin,tweetThis,geolat,geolong)
|
49
|
+
self.class.get("/v1/checkin?vid=#{vid}&venue=#{venue}&shout=#{shout}&private=#{private_checkin}&twitter=#{tweetThis}&geolat=#{geolat}&geolong=#{geolong}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def history(limit)
|
53
|
+
self.class.get("/v1/history?l=#{limit}")
|
54
|
+
end
|
55
|
+
|
56
|
+
def user_details(user_id,badges,mayor)
|
57
|
+
self.class.get("/v1/user?uid=#{user_id}&badges=#{badges}&mayor=#{mayor}")
|
58
|
+
end
|
59
|
+
|
60
|
+
def friends
|
61
|
+
self.class.get("/v1/friends")
|
62
|
+
end
|
63
|
+
|
64
|
+
def venue_details(venue_id)
|
65
|
+
self.class.get("/v1/venue?vid=#{venue_id}")
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_venue(city_id,name,address,cross_street,city,state,zip='0',phone='0')
|
69
|
+
self.class.post("/v1/addvenue", :body => {:name => name, :address => address, :crossstreet => cross_street, :city => city, :state => state, :zip => zip, :cityid => city_id, :phone => phone})
|
70
|
+
end
|
71
|
+
|
72
|
+
def add_tip(venue_id,text,type)
|
73
|
+
self.class.post("/v1/addtip", :body => {:vid => venue_id, :text => text, :type => type})
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:newgem_simple, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:newgem_simple, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: foursquare
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeremy Welch
|
8
|
+
autorequire: foursquare
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-31 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: httparty
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - "="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.4.3
|
24
|
+
version:
|
25
|
+
description: A simple Ruby wrapper for the Foursquare API
|
26
|
+
email: hello@jeremyrwelch.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.rdoc
|
33
|
+
- LICENSE
|
34
|
+
- History
|
35
|
+
files:
|
36
|
+
- LICENSE
|
37
|
+
- README.rdoc
|
38
|
+
- Rakefile
|
39
|
+
- History
|
40
|
+
- lib/foursquare.rb
|
41
|
+
- spec/foursquare_spec.rb
|
42
|
+
- spec/spec_helper.rb
|
43
|
+
- script/destroy
|
44
|
+
- script/generate
|
45
|
+
- examples/fq_test_script.rb
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: http://jeremyrwelch.com
|
48
|
+
licenses: []
|
49
|
+
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
version:
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
version:
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.3.5
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: A simple Ruby wrapper for the Foursquare API
|
74
|
+
test_files: []
|
75
|
+
|