lita-static-meme 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +61 -0
- data/README.md +36 -0
- data/lib/lita-static-meme.rb +1 -0
- data/lib/lita/handlers/static_meme.rb +42 -0
- data/lita-static-meme.gemspec +21 -0
- data/spec/lita/handlers/static_meme_spec.rb +27 -0
- data/spec/spec_helper.rb +2 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 12deddb8ec390b582aa0c33cca8f9fd888c60ca8
|
4
|
+
data.tar.gz: 6e498818a3887f5a102b5a21b157ade2fd469eff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a0b5b3fd678460c5f100b19eb824ae806b7ce9df9329897da8ed52cc4963f79c26d7a378e3e1f217a131b7c32389fbe77b633c90e4f054322268191917352188
|
7
|
+
data.tar.gz: ffc0936d1b269dd8a65c8f39de24cdecccfda5a0aefe86e19f899d725964c5a46239157cf43c4dd82a72c917b000eadd47695d7819b410383d9b9172bd20c773
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lita-static-meme (1.0.0)
|
5
|
+
lita
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.2.5)
|
11
|
+
faraday (0.9.0)
|
12
|
+
multipart-post (>= 1.2, < 3)
|
13
|
+
http_router (0.11.1)
|
14
|
+
rack (>= 1.0.0)
|
15
|
+
url_mount (~> 0.2.1)
|
16
|
+
i18n (0.6.9)
|
17
|
+
ice_nine (0.11.0)
|
18
|
+
lita (3.0.3)
|
19
|
+
bundler (>= 1.3)
|
20
|
+
faraday (>= 0.8.7)
|
21
|
+
http_router (>= 0.11.1)
|
22
|
+
i18n (>= 0.6.9)
|
23
|
+
ice_nine (>= 0.11.0)
|
24
|
+
multi_json (>= 1.7.7)
|
25
|
+
puma (>= 2.7.1)
|
26
|
+
rack (>= 1.5.2)
|
27
|
+
redis-namespace (>= 1.3.0)
|
28
|
+
thor (>= 0.18.1)
|
29
|
+
multi_json (1.9.0)
|
30
|
+
multipart-post (2.0.0)
|
31
|
+
puma (2.8.1)
|
32
|
+
rack (>= 1.1, < 2.0)
|
33
|
+
rack (1.5.2)
|
34
|
+
rake (10.1.1)
|
35
|
+
redis (3.0.7)
|
36
|
+
redis-namespace (1.4.1)
|
37
|
+
redis (~> 3.0.4)
|
38
|
+
rspec (3.0.0.beta2)
|
39
|
+
rspec-core (= 3.0.0.beta2)
|
40
|
+
rspec-expectations (= 3.0.0.beta2)
|
41
|
+
rspec-mocks (= 3.0.0.beta2)
|
42
|
+
rspec-core (3.0.0.beta2)
|
43
|
+
rspec-support (= 3.0.0.beta2)
|
44
|
+
rspec-expectations (3.0.0.beta2)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (= 3.0.0.beta2)
|
47
|
+
rspec-mocks (3.0.0.beta2)
|
48
|
+
rspec-support (= 3.0.0.beta2)
|
49
|
+
rspec-support (3.0.0.beta2)
|
50
|
+
thor (0.18.1)
|
51
|
+
url_mount (0.2.1)
|
52
|
+
rack
|
53
|
+
|
54
|
+
PLATFORMS
|
55
|
+
ruby
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
bundler (~> 1.3)
|
59
|
+
lita-static-meme!
|
60
|
+
rake
|
61
|
+
rspec (>= 3.0.0.beta2)
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# lita-static-meme
|
2
|
+
|
3
|
+
**lita-static-meme** is a handler for [Lita](https://github.com/jimmycuadra/lita)
|
4
|
+
that allows you to respond to arbitrary regular expressions with given images.
|
5
|
+
|
6
|
+
There are [existing gems](https://github.com/wallace/lita-memegen) that dynamically
|
7
|
+
generate memes from given snippets of text, but sometimes you just want Lita to
|
8
|
+
respond to a particular phrase with a static image. One approach would be to write
|
9
|
+
a separate handler for each phrase / image pair, but wouldn't you rather just
|
10
|
+
specify a mapping between regular expressions and URLs? (I would!)
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
As per usual, add that puppy to your Gemfile:
|
15
|
+
|
16
|
+
`gem 'lita-static-meme', github: 'killpack/lita-static-meme'`
|
17
|
+
|
18
|
+
## Configuration
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
Lita.configure do |config|
|
22
|
+
...
|
23
|
+
config.handlers.static_meme.mapping = {
|
24
|
+
/ship it/i => "https://skitch-img.s3.amazonaws.com/20111026-r2wsngtu4jftwxmsytdke6arwd.png", # specify a single response image...
|
25
|
+
/deal with it/i => ["http://i.imgur.com/ykDuU.gif", "http://i.imgur.com/3PWHn.gif"] # ...or a set to randomly choose from
|
26
|
+
}
|
27
|
+
...
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
Given the configuration above:
|
33
|
+
|
34
|
+
`jordan_killpack`: `blah blah blah she should just deal with it already`
|
35
|
+
|
36
|
+
`Lita`: 
|
@@ -0,0 +1 @@
|
|
1
|
+
require "lita/handlers/static_meme"
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'lita'
|
2
|
+
module Lita
|
3
|
+
module Handlers
|
4
|
+
class StaticMeme < Handler
|
5
|
+
@@configured = false
|
6
|
+
|
7
|
+
def self.default_config(config)
|
8
|
+
config.mapping = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.mapping
|
12
|
+
Lita.config.handlers.static_meme.mapping
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.dispatch(robot, message)
|
16
|
+
unless @@configured
|
17
|
+
self.mapping.each do |regex, img_value|
|
18
|
+
if img_value.is_a?(Array)
|
19
|
+
route(regex, :random, help: { regex.to_s => "respond with image" })
|
20
|
+
else
|
21
|
+
route(regex, :echo, help: { regex.to_s => "respond with image" })
|
22
|
+
end
|
23
|
+
end
|
24
|
+
@@configured = true
|
25
|
+
end
|
26
|
+
super(robot, message)
|
27
|
+
end
|
28
|
+
|
29
|
+
def echo(response)
|
30
|
+
img = self.class.mapping[response.pattern]
|
31
|
+
response.reply img
|
32
|
+
end
|
33
|
+
|
34
|
+
def random(response)
|
35
|
+
imgs = self.class.mapping[response.pattern]
|
36
|
+
response.reply imgs.sample
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
Lita.register_handler(StaticMeme)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-static-meme"
|
3
|
+
spec.version = "1.0.0"
|
4
|
+
spec.authors = ["Jordan Killpack"]
|
5
|
+
spec.email = ["jordan.killpack@gatech.edu"]
|
6
|
+
spec.description = %q{Configurable Lita handler for responding to certain phrases with images}
|
7
|
+
spec.summary = %q{Configurable Lita handler for responding to certain phrases with images}
|
8
|
+
spec.homepage = "https://github.com/killpack/lita-static-meme"
|
9
|
+
spec.license = "MIT"
|
10
|
+
|
11
|
+
spec.files = `git ls-files`.split($/)
|
12
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
spec.add_runtime_dependency "lita"
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
19
|
+
spec.add_development_dependency "rake"
|
20
|
+
spec.add_development_dependency "rspec", ">= 3.0.0.beta2"
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Lita::Handlers::StaticMeme, lita_handler: true do
|
4
|
+
|
5
|
+
context "with a mapping configuration object" do
|
6
|
+
before do
|
7
|
+
Lita.config.handlers.static_meme.mapping = {
|
8
|
+
/deal with it/i => ["http://i.imgur.com/ykDuU.gif", "http://i.imgur.com/3PWHn.gif"],
|
9
|
+
/ship it/i => "https://skitch-img.s3.amazonaws.com/20111026-r2wsngtu4jftwxmsytdke6arwd.png"
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
context "for atomic mappings" do
|
14
|
+
it "replies to the given regex with the given image" do
|
15
|
+
send_message("ship it")
|
16
|
+
expect(replies.last).to include("https://skitch-img.s3.amazonaws.com/20111026-r2wsngtu4jftwxmsytdke6arwd.png")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "for array mappings" do
|
21
|
+
it "replies to the given regex with a random image from the array" do
|
22
|
+
send_message("deal with it")
|
23
|
+
expect(replies.last).to satisfy { |reply| ["http://i.imgur.com/ykDuU.gif", "http://i.imgur.com/3PWHn.gif"].include? reply }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-static-meme
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jordan Killpack
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-11 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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '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: 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
|
+
description: Configurable Lita handler for responding to certain phrases with images
|
70
|
+
email:
|
71
|
+
- jordan.killpack@gatech.edu
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- README.md
|
80
|
+
- lib/lita-static-meme.rb
|
81
|
+
- lib/lita/handlers/static_meme.rb
|
82
|
+
- lita-static-meme.gemspec
|
83
|
+
- spec/lita/handlers/static_meme_spec.rb
|
84
|
+
- spec/spec_helper.rb
|
85
|
+
homepage: https://github.com/killpack/lita-static-meme
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.0.3
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Configurable Lita handler for responding to certain phrases with images
|
109
|
+
test_files:
|
110
|
+
- spec/lita/handlers/static_meme_spec.rb
|
111
|
+
- spec/spec_helper.rb
|