lita-wtf 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c839460bc714dc7ccde3efbf3aee0a2468098fd8
4
+ data.tar.gz: 9c4a7dd50932a52c5891487c1a5d715895d48bf3
5
+ SHA512:
6
+ metadata.gz: c7057078283db18660be76224f5a66698badba79d660afde40c41c556b4df64eac23abdba9b93d47e4718613275a79b92cb9512ddb5677512ac74edbe64dea6e
7
+ data.tar.gz: 3d13e2d0b21cf04f747a20983f3c97f8a07356166c2afb89cc6a29800e80206f8ef030055cb5dbb37994b633e3cbeea96919e892fee31f33cb23285c94db196d
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ *.swp
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ Documentation:
2
+ Exclude:
3
+ - lib/lita/handlers/wtf.rb
4
+
5
+ FileName:
6
+ Exclude:
7
+ - lib/lita-wtf.rb
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1
4
+ script: bundle exec rake
5
+ before_install:
6
+ - gem update --system
7
+ services:
8
+ - redis-server
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,9 @@
1
+ Pull requests are awesome! Pull requests with tests are even more awesome!
2
+
3
+ ## Quick steps
4
+
5
+ 1. Fork the repo.
6
+ 2. Run the tests: `bundle && rake`
7
+ 3. Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, it needs a test!
8
+ 4. Make the test pass.
9
+ 5. Push to your fork and submit a pull request.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2014 Eric Sigler
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,42 @@
1
+ # lita-wtf
2
+
3
+ [![Build Status](https://img.shields.io/travis/esigler/lita-wtf/master.svg)](https://travis-ci.org/esigler/lita-wtf)
4
+ [![MIT License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://tldrlegal.com/license/mit-license)
5
+ [![RubyGems :: RMuh Gem Version](http://img.shields.io/gem/v/lita-wtf.svg)](https://rubygems.org/gems/lita-wtf)
6
+ [![Coveralls Coverage](https://img.shields.io/coveralls/esigler/lita-wtf/master.svg)](https://coveralls.io/r/esigler/lita-wtf)
7
+ [![Code Climate](https://img.shields.io/codeclimate/github/esigler/lita-wtf.svg)](https://codeclimate.com/github/esigler/lita-wtf)
8
+ [![Gemnasium](https://img.shields.io/gemnasium/esigler/lita-wtf.svg)](https://gemnasium.com/esigler/lita-wtf)
9
+
10
+ A user-controlled dictionary plugin for [Lita](https://github.com/jimmycuadra/lita).
11
+
12
+ ## Installation
13
+
14
+ Add lita-wtf to your Lita instance's Gemfile:
15
+
16
+ ``` ruby
17
+ gem "lita-wtf"
18
+ ```
19
+
20
+ ## Configuration
21
+
22
+ None
23
+
24
+ ## Usage
25
+
26
+ Set an entry:
27
+
28
+ ```
29
+ lita define foo is something that you want to have defined
30
+ > foo is something that you want to have defined
31
+ ```
32
+
33
+ Find an entry:
34
+
35
+ ```
36
+ lita wtf is foo
37
+ > foo is something that you want to have defined
38
+ ```
39
+
40
+ ## License
41
+
42
+ [MIT](http://opensource.org/licenses/MIT)
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new(:rubocop)
7
+
8
+ task default: [:spec, :rubocop]
data/lib/lita-wtf.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'lita'
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join('..', '..', 'locales', '*.yml'), __FILE__
5
+ )]
6
+
7
+ require 'lita/handlers/wtf'
@@ -0,0 +1,57 @@
1
+ module Lita
2
+ module Handlers
3
+ class Wtf < Handler
4
+ route(
5
+ /^wtf(?:\s+is)?\s(?<term>\w+)(?:\?)?/,
6
+ :lookup,
7
+ command: true,
8
+ help: {
9
+ t('help.wtf.syntax') => t('help.wtf.desc')
10
+ }
11
+ )
12
+
13
+ route(
14
+ /^define\s(?<term>\w+)\sis\s(?<definition>.+)$/,
15
+ :define,
16
+ command: true,
17
+ help: {
18
+ t('help.define.syntax') => t('help.define.desc')
19
+ }
20
+ )
21
+
22
+ def lookup(response)
23
+ term = response.match_data['term']
24
+ return response.reply(t('wtf.unknown', term: term)) unless known?(term)
25
+ response.reply(format_definition(term, definition(term)))
26
+ end
27
+
28
+ def define(response)
29
+ term = response.match_data['term']
30
+ info = response.match_data['definition']
31
+ write(term, info, response.user.id)
32
+ response.reply(format_definition(term, definition(term)))
33
+ end
34
+
35
+ private
36
+
37
+ def format_definition(term, definition)
38
+ t('wtf.is', term: term, definition: definition)
39
+ end
40
+
41
+ def known?(term)
42
+ redis.exists(term.downcase)
43
+ end
44
+
45
+ def definition(term)
46
+ redis.hget(term.downcase, 'definition')
47
+ end
48
+
49
+ def write(term, definition, owner)
50
+ redis.hset(term.downcase, 'definition', definition)
51
+ redis.hset(term.downcase, 'owner', owner)
52
+ end
53
+ end
54
+
55
+ Lita.register_handler(Wtf)
56
+ end
57
+ end
data/lita-wtf.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'lita-wtf'
3
+ spec.version = '1.0.0'
4
+ spec.authors = ['Eric Sigler']
5
+ spec.email = ['me@esigler.com']
6
+ spec.description = 'A user-controlled dictionary plugin for Lita'
7
+ spec.summary = 'A user-controlled dictionary plugin for Lita'
8
+ spec.homepage = 'http://github.com/esigler/lita-wtf'
9
+ spec.license = 'MIT'
10
+ spec.metadata = { 'lita_plugin_type' => 'handler' }
11
+
12
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
13
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
15
+ spec.require_paths = ['lib']
16
+
17
+ spec.add_runtime_dependency 'lita', '>= 4.0'
18
+
19
+ spec.add_development_dependency 'bundler', '~> 1.3'
20
+ spec.add_development_dependency 'coveralls'
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'rspec', '>= 3.0'
23
+ spec.add_development_dependency 'rubocop'
24
+ spec.add_development_dependency 'simplecov'
25
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,14 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ wtf:
5
+ help:
6
+ wtf:
7
+ syntax: wtf is <term>?
8
+ desc: Get the description of <term>
9
+ define:
10
+ syntax: define <term> is <defintion>
11
+ define: Set the description of <term> to <definition>
12
+ wtf:
13
+ is: "%{term} is %{definition}"
14
+ unknown: "I don't know what %{term} is, type: define %{term} is <description> to set it."
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lita::Handlers::Wtf, lita_handler: true do
4
+ it do
5
+ is_expected.to route_command('wtf is foo').to(:lookup)
6
+ is_expected.to route_command('wtf foo').to(:lookup)
7
+ is_expected.to route_command('define foo is bar').to(:define)
8
+ end
9
+
10
+ describe '#lookup' do
11
+ it 'responds with the definition of the service' do
12
+ send_command('define web is Rails. Rails. Rails.')
13
+ send_command('wtf is web')
14
+ expect(replies.last).to eq('web is Rails. Rails. Rails.')
15
+ end
16
+
17
+ it 'responds with the definition of a capitalized service' do
18
+ send_command('define web is Rails. Rails. Rails.')
19
+ send_command('wtf is WEB')
20
+ expect(replies.last).to eq('WEB is Rails. Rails. Rails.')
21
+ end
22
+
23
+ it 'responds with an error if there is no such service' do
24
+ send_command('wtf is foo')
25
+ expect(replies.last).to eq('I don\'t know what foo is, ' \
26
+ 'type: define foo is <description> to set it.')
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,12 @@
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-wtf'
10
+ require 'lita/rspec'
11
+
12
+ Lita.version_3_compatibility_mode = false
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-wtf
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Eric Sigler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-10 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: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
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: coveralls
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: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
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
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: A user-controlled dictionary plugin for Lita
112
+ email:
113
+ - me@esigler.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rubocop.yml"
120
+ - ".travis.yml"
121
+ - CONTRIBUTING.md
122
+ - Gemfile
123
+ - LICENSE
124
+ - README.md
125
+ - Rakefile
126
+ - lib/lita-wtf.rb
127
+ - lib/lita/handlers/wtf.rb
128
+ - lita-wtf.gemspec
129
+ - locales/en.yml
130
+ - spec/lita/handlers/wtf_spec.rb
131
+ - spec/spec_helper.rb
132
+ homepage: http://github.com/esigler/lita-wtf
133
+ licenses:
134
+ - MIT
135
+ metadata:
136
+ lita_plugin_type: handler
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.2.2
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: A user-controlled dictionary plugin for Lita
157
+ test_files:
158
+ - spec/lita/handlers/wtf_spec.rb
159
+ - spec/spec_helper.rb