mosaic-foursquare 0.1.9
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/.gitignore +2 -0
- data/Gemfile +14 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +37 -0
- data/lib/mosaic-foursquare.rb +1 -0
- data/lib/mosaic/foursquare.rb +5 -0
- data/lib/mosaic/foursquare/checkin.rb +23 -0
- data/lib/mosaic/foursquare/object.rb +33 -0
- data/lib/mosaic/foursquare/photo.rb +9 -0
- data/lib/mosaic/foursquare/user.rb +9 -0
- data/lib/mosaic/foursquare/venue.rb +38 -0
- data/lib/mosaic/foursquare/version.rb +5 -0
- data/lib/tasks/mosaic-foursquare_tasks.rake +4 -0
- data/mosaic-foursquare.gemspec +20 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in mosaic-foursquare.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
+
# your gem to rubygems.org.
|
12
|
+
|
13
|
+
# To use debugger
|
14
|
+
# gem 'ruby-debug'
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 Mosaic Sales Solution
|
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,37 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Mosaic::Foursquare'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task :default => :test
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'mosaic/foursquare'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'mosaic/foursquare/object'
|
2
|
+
|
3
|
+
module Mosaic
|
4
|
+
module Foursquare
|
5
|
+
class Checkin < Mosaic::Foursquare::Object
|
6
|
+
attr_accessor :created_at, :id, :photos, :shout, :user, :venue
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def find(id, options = {})
|
10
|
+
response = query("/checkins/#{id}", options)
|
11
|
+
self.new response['response']['checkin']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(attributes = {})
|
16
|
+
super
|
17
|
+
self.photos &&= self.photos['items'].collect { |item| Mosaic::Foursquare::Photo.new(item) }
|
18
|
+
self.user &&= Mosaic::Foursquare::User.new(self.user)
|
19
|
+
self.venue &&= Mosaic::Foursquare::Venue.new(self.venue)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Mosaic
|
4
|
+
module Foursquare
|
5
|
+
class Object
|
6
|
+
include HTTParty
|
7
|
+
base_uri 'https://api.foursquare.com/v2'
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def query(path, options)
|
11
|
+
self.request_count += 1
|
12
|
+
# STDERR.puts "REQUEST[#{self.request_count}]: #{path} with #{options.inspect}"
|
13
|
+
response = get(path, :query => options)
|
14
|
+
# STDERR.puts "RESPONSE[#{self.request_count}]: #{response.inspect}"
|
15
|
+
response.error! unless response.success?
|
16
|
+
response
|
17
|
+
end
|
18
|
+
|
19
|
+
def request_count
|
20
|
+
@request_count ||= 0
|
21
|
+
end
|
22
|
+
|
23
|
+
def request_count=(value)
|
24
|
+
@request_count = value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(attributes = {})
|
29
|
+
attributes.each { |key,value| instance_variable_set("@#{key.to_s.underscore}".to_sym, value) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'mosaic/foursquare/object'
|
2
|
+
|
3
|
+
module Mosaic
|
4
|
+
module Foursquare
|
5
|
+
class Venue < Mosaic::Foursquare::Object
|
6
|
+
attr_accessor :canonical_url, :created_at, :description, :id, :location, :mayor, :name, :short_url, :stats, :tags, :url
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def find(id, options = {})
|
10
|
+
response = query("/venues/#{id}", options)
|
11
|
+
self.new response['response']['venue']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# locally defined location object (until general one is required)
|
16
|
+
class Location < Mosaic::Foursquare::Object
|
17
|
+
attr_reader :lat, :lng
|
18
|
+
end
|
19
|
+
|
20
|
+
# locally defined stats object (general one is probably not required)
|
21
|
+
class Stats < Mosaic::Foursquare::Object
|
22
|
+
attr_reader :checkins_count, :users_count, :tip_count
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(attributes = {})
|
26
|
+
super
|
27
|
+
self.location &&= Mosaic::Foursquare::Venue::Location.new(self.location)
|
28
|
+
self.mayor &&= (self.mayor['user'] ? Mosaic::Foursquare::User.new(self.mayor['user']) : nil)
|
29
|
+
self.stats &&= Mosaic::Foursquare::Venue::Stats.new(self.stats)
|
30
|
+
end
|
31
|
+
|
32
|
+
def herenow(options = {})
|
33
|
+
response = self.class.query("/venues/#{id}/herenow", options)
|
34
|
+
response['response']['hereNow']['items'].collect { |item| Mosaic::Foursquare::Checkin.new(item) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "mosaic/foursquare/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "mosaic-foursquare"
|
9
|
+
s.version = Mosaic::Foursquare::VERSION
|
10
|
+
s.authors = ["S. Brent Faulkner"]
|
11
|
+
s.email = ["brent.faulkner@mosaic.com"]
|
12
|
+
s.homepage = "http://github.com/mosaicxm/mosaic-foursquare"
|
13
|
+
s.summary = "Mosaic Sales Solutions Foursquare API wrapper."
|
14
|
+
s.description = "Wrapper for the Foursquare API with support for the venues API."
|
15
|
+
|
16
|
+
s.files =`git ls-files`.split($/)
|
17
|
+
#s.test_files = Dir["test/**/*"]
|
18
|
+
|
19
|
+
s.add_dependency "httparty", "~> 0.10.2"
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mosaic-foursquare
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.9
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- S. Brent Faulkner
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.10.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.10.2
|
30
|
+
description: Wrapper for the Foursquare API with support for the venues API.
|
31
|
+
email:
|
32
|
+
- brent.faulkner@mosaic.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- MIT-LICENSE
|
40
|
+
- README.rdoc
|
41
|
+
- Rakefile
|
42
|
+
- lib/mosaic-foursquare.rb
|
43
|
+
- lib/mosaic/foursquare.rb
|
44
|
+
- lib/mosaic/foursquare/checkin.rb
|
45
|
+
- lib/mosaic/foursquare/object.rb
|
46
|
+
- lib/mosaic/foursquare/photo.rb
|
47
|
+
- lib/mosaic/foursquare/user.rb
|
48
|
+
- lib/mosaic/foursquare/venue.rb
|
49
|
+
- lib/mosaic/foursquare/version.rb
|
50
|
+
- lib/tasks/mosaic-foursquare_tasks.rake
|
51
|
+
- mosaic-foursquare.gemspec
|
52
|
+
homepage: http://github.com/mosaicxm/mosaic-foursquare
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.8.23
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Mosaic Sales Solutions Foursquare API wrapper.
|
76
|
+
test_files: []
|