starbucks 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +10 -0
- data/lib/starbucks/result.rb +11 -0
- data/lib/starbucks/version.rb +3 -0
- data/lib/starbucks.rb +21 -0
- data/starbucks.gemspec +20 -0
- metadata +90 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Brian Muller
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Starbucks - Find them.
|
2
|
+
|
3
|
+
This gem allows you to find the nearest Starbucks from a lat/lon. This gem may stop functioning at any time without warning because the API that it uses is not published or public. Please see the LICENSE.txt file for more information.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'starbucks'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install starbucks
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
require 'starbucks'
|
22
|
+
|
23
|
+
# Get the nearest:
|
24
|
+
Starbucks.find_nearest(38.8903694152832, -77.0319595336914) { |bucks|
|
25
|
+
puts bucks.name
|
26
|
+
puts bucks.address
|
27
|
+
}
|
28
|
+
|
29
|
+
# Alternative form
|
30
|
+
bucks = Starbucks.find_nearest(38.8903694152832, -77.0319595336914)
|
31
|
+
puts bucks.name
|
32
|
+
puts bucks.address
|
33
|
+
|
34
|
+
# Get the nearest 30 and print out all their attributes (there's a bunch, which I won't list here)
|
35
|
+
Starbucks.find(lat, lon).each { |bucks|
|
36
|
+
puts bucks
|
37
|
+
}
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rdoc/task'
|
3
|
+
|
4
|
+
desc "Create documentation"
|
5
|
+
RDoc::Task.new("doc") { |rdoc|
|
6
|
+
rdoc.title = "Starbucks - Find them."
|
7
|
+
rdoc.rdoc_dir = 'docs'
|
8
|
+
rdoc.rdoc_files.include('README.md')
|
9
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
10
|
+
}
|
data/lib/starbucks.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "starbucks/version"
|
2
|
+
require "starbucks/result"
|
3
|
+
require 'net/http'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Starbucks
|
7
|
+
def self.find(lat, lon, limit=100)
|
8
|
+
res = Net::HTTP.start("www.starbucks.com", 80) {|http|
|
9
|
+
http.get("/api/location.ashx?lat=#{lat}&long=#{lon}&limit=#{limit}")
|
10
|
+
}
|
11
|
+
JSON.parse(res.body).map { |r| Result.new.replace(r) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.find_nearest(lat, lon)
|
15
|
+
if block_given?
|
16
|
+
yield self.find(lat, lon, 1).first
|
17
|
+
else
|
18
|
+
self.find(lat, lon, 1).first
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/starbucks.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'starbucks/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "starbucks"
|
7
|
+
gem.version = Starbucks::VERSION
|
8
|
+
gem.authors = ["Brian Muller"]
|
9
|
+
gem.email = ["bamuller@gmail.com"]
|
10
|
+
gem.description = %q{Find starbuckses.}
|
11
|
+
gem.summary = %q{Find starbuckses from lat/lon.}
|
12
|
+
gem.homepage = "https://github.com/bmuller/starbucks"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
gem.add_dependency("json")
|
19
|
+
gem.add_development_dependency("rake")
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: starbucks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brian Muller
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2012-12-23 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: json
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rake
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *id002
|
37
|
+
description: Find starbuckses.
|
38
|
+
email:
|
39
|
+
- bamuller@gmail.com
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- .gitignore
|
48
|
+
- Gemfile
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- lib/starbucks.rb
|
53
|
+
- lib/starbucks/result.rb
|
54
|
+
- lib/starbucks/version.rb
|
55
|
+
- starbucks.gemspec
|
56
|
+
homepage: https://github.com/bmuller/starbucks
|
57
|
+
licenses: []
|
58
|
+
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: -875040050244349308
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: -875040050244349308
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 1.8.24
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: Find starbuckses from lat/lon.
|
89
|
+
test_files: []
|
90
|
+
|