Skip to content

Commit

Permalink
First version release
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Samami ッ committed Oct 17, 2014
0 parents commit 7a8d346
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
@@ -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
10 changes: 10 additions & 0 deletions .travis.yml
@@ -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
2 changes: 2 additions & 0 deletions Gemfile
@@ -0,0 +1,2 @@
source 'https://rubygems.org'
gemspec
19 changes: 19 additions & 0 deletions LICENSE
@@ -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.
21 changes: 21 additions & 0 deletions README.md
@@ -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)
6 changes: 6 additions & 0 deletions Rakefile
@@ -0,0 +1,6 @@
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

task :default => :spec
1 change: 1 addition & 0 deletions lib/lita-chuck_norris.rb
@@ -0,0 +1 @@
require 'lita/handlers/chuck_norris'
35 changes: 35 additions & 0 deletions lib/lita/handlers/chuck_norris.rb
@@ -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
25 changes: 25 additions & 0 deletions lita-chuck_norris.gemspec
@@ -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
5 changes: 5 additions & 0 deletions spec/lita/handlers/chuck_norris_spec.rb
@@ -0,0 +1,5 @@
require 'spec_helper'

describe Lita::Handlers::ChuckNorris, lita_handler: true do
it { routes_command('chuck').to(:chuck) }
end
12 changes: 12 additions & 0 deletions spec/spec_helper.rb
@@ -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'

0 comments on commit 7a8d346

Please sign in to comment.