forked from MrTin/lita-chuck_norris
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Martin Samami ッ
committed
Oct 17, 2014
0 parents
commit 7a8d346
Showing
11 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
*.gem | ||
*.rbc | ||
.bundle | ||
.config | ||
.yardoc | ||
Gemfile.lock | ||
InstalledFiles | ||
_yardoc | ||
coverage | ||
doc/ | ||
lib/bundler/man | ||
pkg | ||
rdoc | ||
spec/reports | ||
test/tmp | ||
test/version_tmp | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: ruby | ||
rvm: | ||
- 2.0.0 | ||
- 2.1.0 | ||
- 2.1.3 | ||
script: bundle exec rake | ||
before_install: | ||
- gem update --system | ||
services: | ||
- redis-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
source 'https://rubygems.org' | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2013 Martin Samami | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# lita-norris-facts | ||
|
||
[![Build Status](https://travis-ci.org/webdestroya/lita-catfacts.png)](https://travis-ci.org/webdestroya/lita-catfacts) | ||
[![Code Climate](https://codeclimate.com/github/webdestroya/lita-catfacts.png)](https://codeclimate.com/github/webdestroya/lita-catfacts) | ||
[![Coverage Status](https://coveralls.io/repos/webdestroya/lita-catfacts/badge.png)](https://coveralls.io/r/webdestroya/lita-catfacts) | ||
|
||
**lita-norris-facts** is a handler for [Lita](https://www.lita.io) that provides Chuck Norris facts with the ability to replace Chuck Norris with your custom name. | ||
|
||
## Installation | ||
Add lita-norris-facts to your Gemfile: | ||
|
||
``` ruby | ||
gem 'lita-norris-facts' | ||
``` | ||
|
||
## Usage | ||
Lita: norrisfacts | ||
Lita: norrisfacts John Doe | ||
|
||
## License | ||
[MIT](http://opensource.org/licenses/MIT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require 'bundler/gem_tasks' | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task :default => :spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'lita/handlers/chuck_norris' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'lita' | ||
|
||
module Lita | ||
module Handlers | ||
|
||
class ChuckNorrisError < StandardError; end | ||
class RequestError < ChuckNorrisError; end | ||
class UnknownAPIError < ChuckNorrisError; end | ||
|
||
class ChuckNorris < Handler | ||
|
||
route %r{^chuck$}i, :chuck, command: true, help: { | ||
'chuck' => 'Facts about Chuck Norris.' | ||
} | ||
|
||
def chuck(response) | ||
resp = http.get("http://api.icndb.com/jokes/random.json") | ||
raise RequestError unless resp.status == 200 | ||
|
||
obj = MultiJson.load(resp.body) | ||
raise UnknownAPIError unless obj['type'] == 'success' | ||
|
||
response.reply obj['value']['joke'] | ||
|
||
rescue => e | ||
Lita.logger.error("ChuckNorris#chucknorris raised #{e.class}: #{e.message}") | ||
response.reply "Chuck Norris has turned off the internetz, #{e.class} is raising '#{e.message}'" | ||
end | ||
|
||
|
||
end | ||
|
||
Lita.register_handler(ChuckNorris) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Gem::Specification.new do |spec| | ||
spec.name = 'lita-chuck_norris' | ||
spec.version = '0.0.1' | ||
spec.authors = 'Martin Samami' | ||
spec.email = ['martin@digitalkookie.io'] | ||
spec.description = %q{Lita handler delivering instafun using Chuck Norris jokes} | ||
spec.summary = %q{Lita handler delivering instafun using Chuck Norris jokes} | ||
spec.homepage = 'https://github.com/MrTin/lita-chuck_norris' | ||
spec.license = 'MIT' | ||
|
||
spec.files = `git ls-files`.split($/) | ||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } | ||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | ||
spec.require_paths = ['lib'] | ||
|
||
spec.add_runtime_dependency 'lita', '>= 3.0' | ||
|
||
spec.add_development_dependency 'bundler', '~> 1.3' | ||
spec.add_development_dependency 'rake' | ||
spec.add_development_dependency 'rspec', '>= 3.1' | ||
spec.add_development_dependency 'simplecov' | ||
spec.add_development_dependency 'coveralls' | ||
|
||
spec.metadata = { 'lita_plugin_type' => 'handler' } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
describe Lita::Handlers::ChuckNorris, lita_handler: true do | ||
it { routes_command('chuck').to(:chuck) } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'simplecov' | ||
require 'coveralls' | ||
|
||
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ | ||
SimpleCov::Formatter::HTMLFormatter, | ||
Coveralls::SimpleCov::Formatter | ||
] | ||
|
||
SimpleCov.start { add_filter '/spec/' } | ||
|
||
require 'lita-chuck_norris' | ||
require 'lita/rspec' |