lita-yelpme 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +8 -0
- data/Gemfile +5 -0
- data/LICENSE +19 -0
- data/README.md +24 -0
- data/Rakefile +6 -0
- data/lib/lita/handlers/yelpme.rb +43 -0
- data/lib/lita-yelpme.rb +7 -0
- data/lita-yelpme.gemspec +24 -0
- data/locales/en.yml +4 -0
- data/spec/lita/handlers/yelpme_spec.rb +42 -0
- data/spec/spec_helper.rb +10 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8451a5f7e0dc171fb0973327b039840d4344e101
|
4
|
+
data.tar.gz: e050b1f6aa67233872bbcda537e37485fca8f216
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3543653deb837314944760ad38c904d1d2f7a43ac74294603670bc08e1861781739522904995cd6238130f947a7b2ce8cb653fe1e4edb1b3c3ac12b1b99ca62b
|
7
|
+
data.tar.gz: 1fcddc1a93c8db28b832677c24fe24f961c4fa7c12286a471cb13cbb14a8dac0bb85331206479d09281102eb86ac18da584564fa524df2944ce1df14f22bc1f4
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2014 Ted
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# lita-yelpme
|
2
|
+
|
3
|
+
TODO: Add a description of the plugin.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add lita-yelpme to your Lita instance's Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem "lita-yelpme"
|
11
|
+
```
|
12
|
+
|
13
|
+
|
14
|
+
## Configuration
|
15
|
+
|
16
|
+
TODO: Describe any configuration attributes the plugin exposes.
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
TODO: Describe the plugin's features and how to use them.
|
21
|
+
|
22
|
+
## License
|
23
|
+
|
24
|
+
[MIT](http://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'yelp'
|
2
|
+
|
3
|
+
module Lita
|
4
|
+
module Handlers
|
5
|
+
class Yelpme < Handler
|
6
|
+
route(/^(?:yelp|y)\s+(.+)/u, :yelp, command: true, help: {
|
7
|
+
"yelp QUERY" => "Return the first Yelp result with information about the first business found"
|
8
|
+
})
|
9
|
+
|
10
|
+
def self.default_config(handler_config)
|
11
|
+
handler_config.default_city = "San Francisco"
|
12
|
+
end
|
13
|
+
|
14
|
+
def yelp(response)
|
15
|
+
query = response.matches[0][0]
|
16
|
+
begin
|
17
|
+
yelp_response = client.search(config.default_city, { term: query, limit: 1 })
|
18
|
+
rescue Yelp::Error::MissingAPIKeys
|
19
|
+
Lita.logger.error('Could not receive response from yelp, check your API keys')
|
20
|
+
response.reply('Sorry, could not fetch a response from Yelp')
|
21
|
+
return
|
22
|
+
end
|
23
|
+
if yelp_response.businesses.length == 0
|
24
|
+
response.reply('Cannot find any businesses in #{config.default_city} matching #{query}')
|
25
|
+
end
|
26
|
+
result = yelp_response.businesses[0]
|
27
|
+
address = "#{result.location.address.join(' ')}, #{result.location.city}, #{result.location.state_code} #{result.location.postal_code}"
|
28
|
+
response.reply("#{result.name} (#{result.rating} from #{result.review_count} reviews) @ #{address} - #{result.display_phone} #{result.url}")
|
29
|
+
end
|
30
|
+
|
31
|
+
def client
|
32
|
+
Yelp::Client.new(
|
33
|
+
consumer_key: config.consumer_key,
|
34
|
+
consumer_secret: config.consumer_secret,
|
35
|
+
token: config.token,
|
36
|
+
token_secret: config.token_secret
|
37
|
+
)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Lita.register_handler(Yelpme)
|
42
|
+
end
|
43
|
+
end
|
data/lib/lita-yelpme.rb
ADDED
data/lita-yelpme.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-yelpme"
|
3
|
+
spec.version = "0.0.1"
|
4
|
+
spec.authors = ["Ted"]
|
5
|
+
spec.email = ["ted@stuckinacan.com"]
|
6
|
+
spec.description = %q{A yelp handler for lita}
|
7
|
+
spec.summary = %q{A yelp handler for lita}
|
8
|
+
spec.homepage = "https://github.com/twexler/lita-yelpme"
|
9
|
+
spec.license = "MIT"
|
10
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_runtime_dependency "lita", ">= 3.2"
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "rspec", ">= 3.0.0.beta2"
|
22
|
+
spec.add_development_dependency "simplecov"
|
23
|
+
spec.add_development_dependency "coveralls"
|
24
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::Yelpme, lita_handler: true do
|
4
|
+
it { routes_command('yelp state bird provisions').to(:yelp) }
|
5
|
+
|
6
|
+
describe "without valid API keys" do
|
7
|
+
it "returns an error when no api keys are defined" do
|
8
|
+
send_command("yelp state bird provisions")
|
9
|
+
expect(replies.last).to eq ("Sorry, could not fetch a response from Yelp")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "with valid API keys" do
|
14
|
+
let(:yelp_response) {
|
15
|
+
BurstStruct::Burst.new({
|
16
|
+
businesses: [
|
17
|
+
{
|
18
|
+
location: {
|
19
|
+
city: "San Francisco",
|
20
|
+
address: ["1529", "Fillmore", "St"],
|
21
|
+
state_code: "CA",
|
22
|
+
postal_code: "94115"
|
23
|
+
},
|
24
|
+
name: "State Bird Provisions",
|
25
|
+
rating: "4.5",
|
26
|
+
review_count: 787,
|
27
|
+
display_phone: "+1-415-795-1272",
|
28
|
+
url: "http://www.yelp.com/biz/state-bird-provisions-san-francisco"
|
29
|
+
}
|
30
|
+
]
|
31
|
+
})
|
32
|
+
}
|
33
|
+
before do
|
34
|
+
allow(Yelp::Client).to receive(:new) { Yelp::Client }
|
35
|
+
allow(Yelp::Client).to receive(:search) { yelp_response }
|
36
|
+
end
|
37
|
+
it "fetches a result from yelp" do
|
38
|
+
send_command("yelp state bird provisions")
|
39
|
+
expect(replies.last).to eq ("State Bird Provisions (4.5 from 787 reviews) @ 1529 Fillmore St, San Francisco, CA 94115 - +1-415-795-1272 http://www.yelp.com/biz/state-bird-provisions-san-francisco")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
require "coveralls"
|
3
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
4
|
+
SimpleCov::Formatter::HTMLFormatter,
|
5
|
+
Coveralls::SimpleCov::Formatter
|
6
|
+
]
|
7
|
+
SimpleCov.start { add_filter "/spec/" }
|
8
|
+
|
9
|
+
require "lita-yelpme"
|
10
|
+
require "lita/rspec"
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-yelpme
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ted
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0.beta2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0.beta2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: coveralls
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: A yelp handler for lita
|
98
|
+
email:
|
99
|
+
- ted@stuckinacan.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .travis.yml
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- lib/lita-yelpme.rb
|
111
|
+
- lib/lita/handlers/yelpme.rb
|
112
|
+
- lita-yelpme.gemspec
|
113
|
+
- locales/en.yml
|
114
|
+
- spec/lita/handlers/yelpme_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
homepage: https://github.com/twexler/lita-yelpme
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata:
|
120
|
+
lita_plugin_type: handler
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - '>='
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.0.14
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: A yelp handler for lita
|
141
|
+
test_files:
|
142
|
+
- spec/lita/handlers/yelpme_spec.rb
|
143
|
+
- spec/spec_helper.rb
|