lita-dogebomb 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +63 -0
- data/LICENSE +22 -0
- data/README.md +25 -0
- data/lib/lita-dogebomb.rb +1 -0
- data/lib/lita/handlers/dogebomb.rb +33 -0
- data/lita-dogebomb.gemspec +21 -0
- data/spec/lita/handlers/dogebomb_spec.rb +48 -0
- data/spec/spec_helper.rb +3 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5a43091192cf6f122ce1819e8c312af0ce6fe3ee
|
4
|
+
data.tar.gz: 50550151e50eda0fa105537b66dff6e9e803e099
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d45709d156d1e51b698f70426c716d98b100b098cb42d81f8baa8b7f9be61be609c90347828a94b83e8cc0c95e1fc59b8fb29438580b3cde66fe6698c1a8f228
|
7
|
+
data.tar.gz: 6c117f4da5b8ad60eba75e99e326f8e7a36cb9e93804597c580aa9551405a92e0cc419ee97dd593e194326e669fccb85c530ecbb52caa387d1802884b84c63a0
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lita-dogebomb (1.0.0)
|
5
|
+
lita (>= 2.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.2.5)
|
11
|
+
faraday (0.9.1)
|
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.7.0)
|
17
|
+
ice_nine (0.11.1)
|
18
|
+
lita (4.2.0)
|
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
|
+
rb-readline (>= 0.5.1)
|
28
|
+
redis-namespace (>= 1.3.0)
|
29
|
+
thor (>= 0.18.1)
|
30
|
+
multi_json (1.10.1)
|
31
|
+
multipart-post (2.0.0)
|
32
|
+
puma (2.11.1)
|
33
|
+
rack (>= 1.1, < 2.0)
|
34
|
+
rack (1.6.0)
|
35
|
+
rake (10.4.2)
|
36
|
+
rb-readline (0.5.2)
|
37
|
+
redis (3.2.1)
|
38
|
+
redis-namespace (1.5.1)
|
39
|
+
redis (~> 3.0, >= 3.0.4)
|
40
|
+
rspec (3.0.0)
|
41
|
+
rspec-core (~> 3.0.0)
|
42
|
+
rspec-expectations (~> 3.0.0)
|
43
|
+
rspec-mocks (~> 3.0.0)
|
44
|
+
rspec-core (3.0.4)
|
45
|
+
rspec-support (~> 3.0.0)
|
46
|
+
rspec-expectations (3.0.4)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.0.0)
|
49
|
+
rspec-mocks (3.0.4)
|
50
|
+
rspec-support (~> 3.0.0)
|
51
|
+
rspec-support (3.0.4)
|
52
|
+
thor (0.19.1)
|
53
|
+
url_mount (0.2.1)
|
54
|
+
rack
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
bundler (~> 1.3)
|
61
|
+
lita-dogebomb!
|
62
|
+
rake
|
63
|
+
rspec (~> 3.0.0)
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Andrew Hayworth
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# lita-dogebomb
|
2
|
+
|
3
|
+
**lita-dogebomb** is a handler for [Lita](https://github.com/jimmycuadra/lita) that displays an arbitrary number of images of doges, via [http://dogeme.rowanmanning.com](http://dogeme.rowanmanning.com/).
|
4
|
+
|
5
|
+
Sometimes you'd just rather see an array of doges than whatever else is currently in chat.
|
6
|
+
|
7
|
+
Inspired heavily by (more or less copy-pasted from) [lita-pugbomb](https://github.com/killpack/lita-pugbomb).
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add `lita-dogebomb` to your Lita instance's Gemfile:
|
12
|
+
``` ruby
|
13
|
+
gem "lita-dogebomb"
|
14
|
+
```
|
15
|
+
|
16
|
+
### Usage
|
17
|
+
`Lita: doge me` - display a single doge.
|
18
|
+
|
19
|
+
`Lita: doge bomb` - display five doges. Alternate syntax: `Lita: dogebomb`
|
20
|
+
|
21
|
+
`Lita: doge bomb n` - display n doges, where n is an integer.
|
22
|
+
|
23
|
+
`Lita: how many doges are there` - you can figure it out
|
24
|
+
|
25
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require "lita/handlers/dogebomb"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'lita'
|
2
|
+
|
3
|
+
module Lita
|
4
|
+
module Handlers
|
5
|
+
class Dogebomb < Handler
|
6
|
+
route(/\bdoge me\b/i, :doge, command: true, help: { "doge me" => "Display a single doge" })
|
7
|
+
route(/\bdoge ?bomb( (\d+))?/i, :bomb, command: true, help: { "doge bomb" => "Display five doges", "doge bomb N" => "Display N doges" })
|
8
|
+
route(/how many doges are there/i, :count, command: true, help: { "how many doges are there" => "Gets the current number of doges" })
|
9
|
+
|
10
|
+
BASE_URL = "http://dogeme.rowanmanning.com"
|
11
|
+
|
12
|
+
def doge(response)
|
13
|
+
data = MultiJson.load(http.get(BASE_URL + "/random").body)
|
14
|
+
response.reply data['doge']
|
15
|
+
end
|
16
|
+
|
17
|
+
def bomb(response)
|
18
|
+
count = response.matches[0][1] || 5
|
19
|
+
data = MultiJson.load(http.get(BASE_URL + "/bomb", count: count).body)
|
20
|
+
data['doges'].each do |doge|
|
21
|
+
response.reply doge
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def count(response)
|
26
|
+
data = MultiJson.load(http.get(BASE_URL + "/count").body)
|
27
|
+
doge_count = data['doge_count']
|
28
|
+
response.reply "There are #{doge_count} doges."
|
29
|
+
end
|
30
|
+
end
|
31
|
+
Lita.register_handler(Dogebomb)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-dogebomb"
|
3
|
+
spec.version = "1.0.0"
|
4
|
+
spec.authors = ["Andrew Hayworth"]
|
5
|
+
spec.email = ["ahayworth@gmail.com"]
|
6
|
+
spec.description = %q{Lita handler for doge bombs}
|
7
|
+
spec.summary = %q{Lita handler for doge bombs}
|
8
|
+
spec.homepage = "https://github.com/ahayworth/lita-dogebomb"
|
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", ">= 2.0"
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
19
|
+
spec.add_development_dependency "rake"
|
20
|
+
spec.add_development_dependency "rspec", "~> 3.0.0"
|
21
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Lita::Handlers::Dogebomb, lita_handler: true do
|
4
|
+
it { is_expected.to route_command("doge me").to :doge }
|
5
|
+
it { is_expected.to route_command("doge bomb").to :bomb }
|
6
|
+
it { is_expected.to route_command("dogebomb").to :bomb }
|
7
|
+
it { is_expected.to route_command("doge bomb 10").to :bomb }
|
8
|
+
it { is_expected.to route_command("how many doges are there").to :count }
|
9
|
+
|
10
|
+
describe "#doge" do
|
11
|
+
let(:doge) { '{"doge": "http://i.imgur.com/nF8DtvV.jpg"}' }
|
12
|
+
before do
|
13
|
+
allow_any_instance_of(Faraday::Connection).to receive(:get).with("http://dogeme.rowanmanning.com/random").and_return(double("Faraday::Response", status: 200, body: doge))
|
14
|
+
end
|
15
|
+
|
16
|
+
it "replies with a single doge" do
|
17
|
+
send_command("doge me")
|
18
|
+
expect(replies.last).to include("http://i.imgur.com/nF8DtvV.jpg")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#bomb" do
|
23
|
+
let(:bomb) { '{"doges": ["https://pbs.twimg.com/media/BdTWMskCEAAQ5b7.jpg", "http://i.imgur.com/1uBYSzq.jpg"]}' }
|
24
|
+
before do
|
25
|
+
allow_any_instance_of(Faraday::Connection).to receive(:get).with("http://dogeme.rowanmanning.com/bomb", count: "2").and_return(double("Faraday::Response", status: 200, body: bomb))
|
26
|
+
end
|
27
|
+
|
28
|
+
it "replies with n doges" do
|
29
|
+
expect {
|
30
|
+
send_command("doge bomb 2")
|
31
|
+
}.to change{replies.count}.by(2)
|
32
|
+
expect(replies.last).to include("http://i.imgur.com/1uBYSzq.jpg")
|
33
|
+
expect(replies[-2]).to include("https://pbs.twimg.com/media/BdTWMskCEAAQ5b7.jpg")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#count" do
|
38
|
+
let(:count) { '{"doge_count": 82}' }
|
39
|
+
before do
|
40
|
+
allow_any_instance_of(Faraday::Connection).to receive(:get).with("http://dogeme.rowanmanning.com/count").and_return(double("Faraday::Response", status: 200, body: count))
|
41
|
+
end
|
42
|
+
|
43
|
+
it "replies with the current doge count" do
|
44
|
+
send_command("how many doges are there")
|
45
|
+
expect(replies.last).to include("There are 82 doges")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-dogebomb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Hayworth
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-21 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: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.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
|
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
|
69
|
+
description: Lita handler for doge bombs
|
70
|
+
email:
|
71
|
+
- ahayworth@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- lib/lita-dogebomb.rb
|
82
|
+
- lib/lita/handlers/dogebomb.rb
|
83
|
+
- lita-dogebomb.gemspec
|
84
|
+
- spec/lita/handlers/dogebomb_spec.rb
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
homepage: https://github.com/ahayworth/lita-dogebomb
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.4.5
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Lita handler for doge bombs
|
110
|
+
test_files:
|
111
|
+
- spec/lita/handlers/dogebomb_spec.rb
|
112
|
+
- spec/spec_helper.rb
|