Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Add connected and disconnected events.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmycuadra committed Oct 5, 2013
1 parent 56ea234 commit 7ff9eaf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions lib/lita/adapters/hipchat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def initialize(robot)

def run
connector.connect
robot.trigger(:connected)
connector.join_rooms(config.muc_domain, rooms)
sleep
rescue Interrupt
Expand All @@ -43,6 +44,7 @@ def set_topic(target, topic)

def shut_down
connector.shut_down
robot.trigger(:disconnected)
end

private
Expand Down
4 changes: 2 additions & 2 deletions lita-hipchat.gemspec
Original file line number Diff line number Diff line change
@@ -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.}
Expand All @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions spec/lita/adapters/hipchat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7ff9eaf

Please sign in to comment.