lita-pugbomb 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: 0ec1a24ed0c01f0900e86e07524d5a1e2a853aa7
4
+ data.tar.gz: 8031efb6cbc712a6b1af896570986a17f5b39e7f
5
+ SHA512:
6
+ metadata.gz: 2123e6d8528327b70151eb39e2dd77c3c8a923bc0a4951de33f3096d13bece1b8c8b482d64ab241d1044238448f356e7e04110c5b6ede61a33a2bb0b00487ea2
7
+ data.tar.gz: 09833e0a5fbeaa6a626c9585107d0ad9b1452541917b91fd81a9799935914c00994f557f3afb643b8eea1ed3ac9f6a9d70628c250aaf7fed93c0ff8ea2828f65
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lita-pugbomb (1.0.0)
5
+ lita (~> 3.0)
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.2)
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.8.4)
30
+ multipart-post (2.0.0)
31
+ puma (2.7.1)
32
+ rack (>= 1.1, < 2.0)
33
+ rack (1.5.2)
34
+ rake (10.1.0)
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-pugbomb!
60
+ rake
61
+ rspec (~> 3.0.0.beta1)
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # lita-pugbomb
2
+
3
+ **lita-pugbomb** is a handler for [Lita](https://github.com/jimmycuadra/lita) that displays an arbitrary number of images of pugs, via [this single-serving Heroku app](http://pugme.herokuapp.com).
4
+
5
+ Sometimes you'd just rather see an array of pugs than whatever else is currently in chat.
6
+
7
+ ## Installation
8
+
9
+ Add `lita-pugbomb` to your Lita instance's Gemfile:
10
+ ``` ruby
11
+ gem "lita-pugbomb"
12
+ ```
13
+
14
+ ### Usage
15
+ `Lita: pug me` - display a single pug.
16
+
17
+ `Lita: pug bomb` - display five pugs.
18
+
19
+ `Lita: pug bomb n` - display n pugs, where n is an integer.
20
+
21
+ `Lita: how many pugs are there` - you can figure it out
22
+
23
+
@@ -0,0 +1,33 @@
1
+ require 'lita'
2
+
3
+ module Lita
4
+ module Handlers
5
+ class Pugbomb < Handler
6
+ route(/\bpug me\b/i, :pug, command: true, help: { "pug me" => "Display a single pug" })
7
+ route(/\bpug bomb( (\d+))?/i, :bomb, command: true, help: { "pug bomb" => "Display five pugs", "pug bomb N" => "Display N pugs" })
8
+ route(/how many pugs are there/i, :count, command: true, help: { "how many pugs are there" => "Gets the current number of pugs" })
9
+
10
+ BASE_URL = "http://pugme.herokuapp.com"
11
+
12
+ def pug(response)
13
+ data = MultiJson.load(http.get(BASE_URL + "/random").body)
14
+ response.reply data['pug']
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['pugs'].each do |pug|
21
+ response.reply pug
22
+ end
23
+ end
24
+
25
+ def count(response)
26
+ data = MultiJson.load(http.get(BASE_URL + "/count").body)
27
+ pug_count = data['pug_count']
28
+ response.reply "There are #{pug_count} pugs."
29
+ end
30
+ end
31
+ Lita.register_handler(Pugbomb)
32
+ end
33
+ end
@@ -0,0 +1 @@
1
+ require "lita/handlers/pugbomb"
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-pugbomb"
3
+ spec.version = "1.0.0"
4
+ spec.authors = ["Jordan Killpack"]
5
+ spec.email = ["jordan.killpack@gatech.edu"]
6
+ spec.description = %q{Lita handler for pug bombs}
7
+ spec.summary = %q{Lita handler for pug bombs}
8
+ spec.homepage = "https://github.com/killpack/lita-pugbomb"
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.beta1"
21
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lita::Handlers::Pugbomb, lita_handler: true do
4
+ it { routes_command("pug me").to :pug }
5
+ it { routes_command("pug bomb").to :bomb }
6
+ it { routes_command("pug bomb 10").to :bomb }
7
+ it { routes_command("how many pugs are there").to :count }
8
+
9
+ describe "#pug" do
10
+ let(:pug) { '{"pug": "http://26.media.tumblr.com/tumblr_lomvroWFOE1qaa50yo1_500.jpg"}' }
11
+ before do
12
+ allow_any_instance_of(Faraday::Connection).to receive(:get).with("http://pugme.herokuapp.com/random").and_return(double("Faraday::Response", status: 200, body: pug))
13
+ end
14
+
15
+ it "replies with a single pug" do
16
+ send_command("pug me")
17
+ expect(replies.last).to include("http://26.media.tumblr.com/tumblr_lomvroWFOE1qaa50yo1_500.jpg")
18
+ end
19
+ end
20
+
21
+ describe "#bomb" do
22
+ let(:bomb) { '{"pugs": ["http://28.media.tumblr.com/tumblr_ltef3eghZ71qb08qmo1_500.jpg","http://28.media.tumblr.com/tumblr_lk5h7hIRFf1qi4pifo1_500.jpg"]}' }
23
+ before do
24
+ allow_any_instance_of(Faraday::Connection).to receive(:get).with("http://pugme.herokuapp.com/bomb", count: "2").and_return(double("Faraday::Response", status: 200, body: bomb))
25
+ end
26
+
27
+ it "replies with n pugs" do
28
+ expect {
29
+ send_command("pug bomb 2")
30
+ }.to change{replies.count}.by(2)
31
+ expect(replies.last).to include("http://28.media.tumblr.com/tumblr_lk5h7hIRFf1qi4pifo1_500.jpg")
32
+ expect(replies[-2]).to include("http://28.media.tumblr.com/tumblr_ltef3eghZ71qb08qmo1_500.jpg")
33
+ end
34
+ end
35
+
36
+ describe "#count" do
37
+ let(:count) { '{"pug_count": 298}' }
38
+ before do
39
+ allow_any_instance_of(Faraday::Connection).to receive(:get).with("http://pugme.herokuapp.com/count").and_return(double("Faraday::Response", status: 200, body: count))
40
+ end
41
+
42
+ it "replies with the current pug count" do
43
+ send_command("how many pugs are there")
44
+ expect(replies.last).to include("There are 298 pugs")
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,2 @@
1
+ require 'lita-pugbomb'
2
+ require 'lita/rspec'
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-pugbomb
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: '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.beta1
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.beta1
69
+ description: Lita handler for pug bombs
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-pugbomb.rb
81
+ - lib/lita/handlers/pugbomb.rb
82
+ - lita-pugbomb.gemspec
83
+ - spec/lita/handlers/pugbomb_spec.rb
84
+ - spec/spec_helper.rb
85
+ homepage: https://github.com/killpack/lita-pugbomb
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: Lita handler for pug bombs
109
+ test_files:
110
+ - spec/lita/handlers/pugbomb_spec.rb
111
+ - spec/spec_helper.rb