diff --git a/README.md b/README.md index 1e7a75b..9e9375e 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,10 @@ Lita.configure do |config| end ``` +## Events + +The HipChat adapter will trigger the `:connected` and `:disconnected` events when the robot has connected and disconnected from HipChat, respectively. There is no payload data for either event. + ## License [MIT](http://opensource.org/licenses/MIT) diff --git a/lib/lita/adapters/hipchat.rb b/lib/lita/adapters/hipchat.rb index 5377364..016ba6a 100644 --- a/lib/lita/adapters/hipchat.rb +++ b/lib/lita/adapters/hipchat.rb @@ -23,6 +23,7 @@ def initialize(robot) def run connector.connect + robot.trigger(:connected) connector.join_rooms(config.muc_domain, rooms) sleep rescue Interrupt @@ -43,6 +44,7 @@ def set_topic(target, topic) def shut_down connector.shut_down + robot.trigger(:disconnected) end private diff --git a/lita-hipchat.gemspec b/lita-hipchat.gemspec index fea1099..8122fdb 100644 --- a/lita-hipchat.gemspec +++ b/lita-hipchat.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = "lita-hipchat" - spec.version = "1.0.1" + spec.version = "1.2.0" spec.authors = ["Jimmy Cuadra"] spec.email = ["jimmy@jimmycuadra.com"] spec.description = %q{A HipChat adapter for Lita.} @@ -13,7 +13,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.add_runtime_dependency "lita", "~> 2.0" + spec.add_runtime_dependency "lita", "~> 2.5" spec.add_runtime_dependency "xmpp4r", "~> 0.5" spec.add_development_dependency "bundler", "~> 1.3" diff --git a/spec/lita/adapters/hipchat_spec.rb b/spec/lita/adapters/hipchat_spec.rb index cfd0a4b..6954a43 100644 --- a/spec/lita/adapters/hipchat_spec.rb +++ b/spec/lita/adapters/hipchat_spec.rb @@ -30,12 +30,14 @@ describe "#run" do before do allow(subject.connector).to receive(:connect) + allow(robot).to receive(:trigger) allow(subject.connector).to receive(:join_rooms) allow(subject).to receive(:sleep) end it "connects to HipChat" do expect(subject.connector).to receive(:connect) + expect(robot).to receive(:trigger).with(:connected) subject.run end @@ -115,6 +117,7 @@ describe "#shut_down" do it "shuts down the connector" do expect(subject.connector).to receive(:shut_down) + expect(robot).to receive(:trigger).with(:disconnected) subject.shut_down end end