lita-campfire 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.travis.yml +6 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +87 -0
- data/README.md +72 -0
- data/Rakefile +1 -0
- data/lib/lita/adapters/campfire/callback.rb +33 -0
- data/lib/lita/adapters/campfire/connector.rb +46 -0
- data/lib/lita/adapters/campfire/room_not_available.rb +8 -0
- data/lib/lita/adapters/campfire.rb +57 -0
- data/lib/lita-campfire.rb +8 -0
- data/lita-campfire.gemspec +24 -0
- data/spec/lita/adapters/campfire/callback_spec.rb +40 -0
- data/spec/lita/adapters/campfire/connector_spec.rb +72 -0
- data/spec/lita/adapters/campfire_spec.rb +88 -0
- data/spec/spec_helper.rb +12 -0
- metadata +162 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e6c09610adbd5cde7dbcba15ed189ae282565d42
|
4
|
+
data.tar.gz: 685c6bfafacd7ec73f258831629f2087deedabf0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d00c551bcb948b8d0f8f2da32d63ea271ca06fe06277d46c20e60ba85c36f784dd0613cc19fd662f740e3e2a5ed0af4c3936d1c901398c4f82a4e6b42badb10f
|
7
|
+
data.tar.gz: baf6b041d1bb6033d29317b51bf7648d3eb753b61a4df6fb4e081e0625fc5d83b02d66d4e17a90c0910711cb9975529cedba13974d57175c3705f862ef560b88
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lita-campfire (0.1)
|
5
|
+
lita (~> 2.0)
|
6
|
+
tinder (~> 1.9.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
colorize (0.5.8)
|
12
|
+
coveralls (0.6.7)
|
13
|
+
colorize
|
14
|
+
multi_json (~> 1.3)
|
15
|
+
rest-client
|
16
|
+
simplecov (>= 0.7)
|
17
|
+
thor
|
18
|
+
daemons (1.1.9)
|
19
|
+
diff-lcs (1.2.4)
|
20
|
+
eventmachine (1.0.3)
|
21
|
+
faraday (0.8.8)
|
22
|
+
multipart-post (~> 1.2.0)
|
23
|
+
faraday_middleware (0.9.0)
|
24
|
+
faraday (>= 0.7.4, < 0.9)
|
25
|
+
hashie (1.2.0)
|
26
|
+
http_parser.rb (0.5.3)
|
27
|
+
json (1.7.7)
|
28
|
+
lita (2.2.0)
|
29
|
+
bundler (~> 1.3)
|
30
|
+
faraday (~> 0.8.7)
|
31
|
+
multi_json (~> 1.7.7)
|
32
|
+
rack (~> 1.5.2)
|
33
|
+
redis-namespace (~> 1.3.0)
|
34
|
+
thin (~> 1.5.1)
|
35
|
+
thor (~> 0.18.1)
|
36
|
+
mime-types (1.23)
|
37
|
+
multi_json (1.7.8)
|
38
|
+
multipart-post (1.2.0)
|
39
|
+
rack (1.5.2)
|
40
|
+
rake (10.1.0)
|
41
|
+
redis (3.0.4)
|
42
|
+
redis-namespace (1.3.1)
|
43
|
+
redis (~> 3.0.0)
|
44
|
+
rest-client (1.6.7)
|
45
|
+
mime-types (>= 1.16)
|
46
|
+
rspec (2.14.1)
|
47
|
+
rspec-core (~> 2.14.0)
|
48
|
+
rspec-expectations (~> 2.14.0)
|
49
|
+
rspec-mocks (~> 2.14.0)
|
50
|
+
rspec-core (2.14.4)
|
51
|
+
rspec-expectations (2.14.0)
|
52
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
53
|
+
rspec-mocks (2.14.2)
|
54
|
+
simple_oauth (0.1.9)
|
55
|
+
simplecov (0.7.1)
|
56
|
+
multi_json (~> 1.0)
|
57
|
+
simplecov-html (~> 0.7.1)
|
58
|
+
simplecov-html (0.7.1)
|
59
|
+
thin (1.5.1)
|
60
|
+
daemons (>= 1.0.9)
|
61
|
+
eventmachine (>= 0.12.6)
|
62
|
+
rack (>= 1.0.0)
|
63
|
+
thor (0.18.1)
|
64
|
+
tinder (1.9.2)
|
65
|
+
eventmachine (~> 1.0)
|
66
|
+
faraday (~> 0.8)
|
67
|
+
faraday_middleware (~> 0.9)
|
68
|
+
hashie (~> 1.0)
|
69
|
+
json (~> 1.7.5)
|
70
|
+
mime-types (~> 1.19)
|
71
|
+
multi_json (~> 1.5)
|
72
|
+
twitter-stream (~> 0.1)
|
73
|
+
twitter-stream (0.1.16)
|
74
|
+
eventmachine (>= 0.12.8)
|
75
|
+
http_parser.rb (~> 0.5.1)
|
76
|
+
simple_oauth (~> 0.1.4)
|
77
|
+
|
78
|
+
PLATFORMS
|
79
|
+
ruby
|
80
|
+
|
81
|
+
DEPENDENCIES
|
82
|
+
bundler (~> 1.3)
|
83
|
+
coveralls
|
84
|
+
lita-campfire!
|
85
|
+
rake
|
86
|
+
rspec (~> 2.14)
|
87
|
+
simplecov
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Campfire adapter for Lita
|
2
|
+
|
3
|
+
## Continuous Integration
|
4
|
+
|
5
|
+
[![Build Status](https://secure.travis-ci.org/josacar/lita-campfire.png)](http://travis-ci.org/josacar/lita-campfire)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/josacar/lita-campfire/badge.png)](https://coveralls.io/r/josacar/lita-campfire)
|
7
|
+
|
8
|
+
**lita-campfire** is an adapter for [Lita](https://github.com/jimmycuadra/lita) that allows you to use the robot with [Campfire](https://campfirenow.com).
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add lita-campfire to your Lita instance's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem "lita-campfire", :git => 'https://github.com/josacar/lita-campfire.git'
|
16
|
+
```
|
17
|
+
|
18
|
+
## Configuration
|
19
|
+
|
20
|
+
Values needed to work like apikey can be found on 'My info' link when logged, subdomain and rooms, extract it from the URL to join (https://org_name_example.campfirenow.com/rooms/78744).
|
21
|
+
|
22
|
+
### Required attributes
|
23
|
+
|
24
|
+
* `apikey` (String) - The APIKEY of your robot's Campfire account. Default: `nil`.
|
25
|
+
* `rooms` (Array) - The room ids to join by your robot. Default: `nil`.
|
26
|
+
* `subdomain` (String) - The organization name to join by your robot. Default: `nil`.
|
27
|
+
|
28
|
+
### Optional attributes
|
29
|
+
|
30
|
+
* `debug` (Boolean) - If `true`, turns on the underlying Campfire library's (tinder) logger, which is fairly verbose. Default: `false`.
|
31
|
+
|
32
|
+
**Note** You must set also `config.robot.name` and `config.robot.mention_name` to work.
|
33
|
+
|
34
|
+
### Example
|
35
|
+
|
36
|
+
This is the `lita_config.rb` file to work with campfire and be deployed on Heroku.
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
Lita.configure do |config|
|
40
|
+
# The name your robot will use.
|
41
|
+
config.robot.name = "Campfire bot"
|
42
|
+
config.robot.mention_name = "robot"
|
43
|
+
|
44
|
+
# The severity of messages to log.
|
45
|
+
config.robot.log_level = :info
|
46
|
+
|
47
|
+
# The adapter you want to connect with.
|
48
|
+
config.robot.adapter = :campfire
|
49
|
+
|
50
|
+
config.adapter.subdomain = ENV["CAMPFIRE_SUBDOMAIN"]
|
51
|
+
config.adapter.apikey = ENV["CAMPFIRE_APIKEY"]
|
52
|
+
config.adapter.rooms = ENV["CAMPFIRE_ROOMS"].split(',')
|
53
|
+
config.adapter.debug = false
|
54
|
+
|
55
|
+
config.redis.url = ENV["REDISTOGO_URL"]
|
56
|
+
config.http.port = ENV["PORT"]
|
57
|
+
|
58
|
+
config.handlers.google_images.safe_search = :off
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
Then, set the variables like:
|
63
|
+
|
64
|
+
```bash
|
65
|
+
heroku config:set CAMPFIRE_APIKEY=43242c42270856780656360bfbee863892
|
66
|
+
heroku config:set CAMPFIRE_SUBDOMAIN=orgname
|
67
|
+
heroku config:set CAMPFIRE_ROOMS=5674537,324424
|
68
|
+
```
|
69
|
+
|
70
|
+
## License
|
71
|
+
|
72
|
+
[MIT](http://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Lita
|
2
|
+
module Adapters
|
3
|
+
class Campfire < Adapter
|
4
|
+
class Callback
|
5
|
+
|
6
|
+
MESSAGE_TYPES = %w( TextMessage PasteMessage ).freeze
|
7
|
+
|
8
|
+
def initialize(robot)
|
9
|
+
@robot = robot
|
10
|
+
end
|
11
|
+
|
12
|
+
def room_message(room)
|
13
|
+
room.listen do |m|
|
14
|
+
if MESSAGE_TYPES.include?(m.type)
|
15
|
+
text = m.body
|
16
|
+
user = get_user(m.user)
|
17
|
+
source = Source.new(user, room)
|
18
|
+
message = Message.new(@robot, text, source)
|
19
|
+
@robot.receive message
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def get_user(user_data)
|
26
|
+
user_id = user_data.delete(:id)
|
27
|
+
User.new(user_id, user_data)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Lita
|
2
|
+
module Adapters
|
3
|
+
class Campfire < Adapter
|
4
|
+
class Connector
|
5
|
+
def initialize(robot, opts)
|
6
|
+
@robot = robot
|
7
|
+
@subdomain = opts.fetch(:subdomain)
|
8
|
+
@apikey = opts.fetch(:apikey)
|
9
|
+
@rooms = opts.fetch(:rooms)
|
10
|
+
@debug = opts.fetch(:debug) { false }
|
11
|
+
end
|
12
|
+
|
13
|
+
def connect
|
14
|
+
@campfire = Tinder::Campfire.new(@subdomain, token: @apikey)
|
15
|
+
end
|
16
|
+
|
17
|
+
def join_rooms(rooms)
|
18
|
+
rooms.each do |room_id|
|
19
|
+
room = fetch_room(room_id)
|
20
|
+
room.join
|
21
|
+
Callback.new(@robot).room_message(room)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def send_messages(room, messages)
|
26
|
+
@campfire.find_room_by_id(room.id).tap do |my_room|
|
27
|
+
messages.each do |message|
|
28
|
+
my_room.speak message
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def fetch_room(room_id)
|
36
|
+
@campfire.find_room_by_id(room_id).tap do |room|
|
37
|
+
if room.nil?
|
38
|
+
raise RoomNotAvailable,
|
39
|
+
"Make sure you have access to room #{ room_id }"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Lita
|
2
|
+
module Adapters
|
3
|
+
class Campfire < Adapter
|
4
|
+
require_configs :subdomain, :apikey, :rooms
|
5
|
+
|
6
|
+
attr_reader :connector
|
7
|
+
|
8
|
+
def initialize(robot)
|
9
|
+
super
|
10
|
+
|
11
|
+
@connector = Connector.new(
|
12
|
+
robot,
|
13
|
+
subdomain: config.subdomain,
|
14
|
+
apikey: config.apikey,
|
15
|
+
rooms: config.rooms,
|
16
|
+
debug: config.debug
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
connector.connect
|
22
|
+
connector.join_rooms rooms
|
23
|
+
sleep
|
24
|
+
rescue Interrupt
|
25
|
+
disconnect
|
26
|
+
end
|
27
|
+
|
28
|
+
def send_messages(target, messages)
|
29
|
+
connector.send_messages(target.room, messages)
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_topic(target, topic)
|
33
|
+
connector.set_topic(target.room, topic)
|
34
|
+
end
|
35
|
+
|
36
|
+
def shut_down
|
37
|
+
disconnect
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def config
|
43
|
+
Lita.config.adapter
|
44
|
+
end
|
45
|
+
|
46
|
+
def rooms
|
47
|
+
Array(config.rooms)
|
48
|
+
end
|
49
|
+
|
50
|
+
def disconnect
|
51
|
+
connector.disconnect
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
Lita.register_adapter(:campfire, Campfire)
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-campfire"
|
3
|
+
spec.version = "0.1"
|
4
|
+
spec.authors = ["Jose Luis Salas"]
|
5
|
+
spec.email = ["josacar@gmail.com"]
|
6
|
+
spec.description = %q{A Campfire adapter for Lita.}
|
7
|
+
spec.summary = %q{A Campfire adapter for the Lita chat robot.}
|
8
|
+
spec.homepage = "https://github.com/josacar/lita-campfire"
|
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
|
+
spec.add_runtime_dependency "tinder", "~> 1.9.0"
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
22
|
+
spec.add_development_dependency "simplecov"
|
23
|
+
spec.add_development_dependency "coveralls"
|
24
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Campfire::Callback do
|
4
|
+
|
5
|
+
class DummyRoom < Struct.new(:message)
|
6
|
+
def listen
|
7
|
+
yield message
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:campfire_user) { { id: 1, name: 'Bender Bending Rodriguez' } }
|
12
|
+
let(:message) { double('Message') }
|
13
|
+
let(:robot) { double('Robot', mention_name: 'Robot') }
|
14
|
+
let(:room) { DummyRoom.new(campfire_message) }
|
15
|
+
let(:source) { double('Source') }
|
16
|
+
let(:text) { "Yes it's the apocalypse alright. I always though is have a hand in it." }
|
17
|
+
let(:user) { double('User') }
|
18
|
+
|
19
|
+
subject { described_class.new(robot) }
|
20
|
+
|
21
|
+
describe '#room_message' do
|
22
|
+
%w( TextMessage PasteMessage ).each do |message_type|
|
23
|
+
describe "with a #{message_type}" do
|
24
|
+
let(:campfire_message) { double(
|
25
|
+
type: message_type,
|
26
|
+
body: text,
|
27
|
+
user: campfire_user) }
|
28
|
+
|
29
|
+
it 'passes the message to Robot#receive' do
|
30
|
+
expect(Lita::User).to receive(:new).with(1, name: 'Bender Bending Rodriguez').and_return(user)
|
31
|
+
expect(Lita::Source).to receive(:new).with(user, room).and_return(source)
|
32
|
+
expect(Lita::Message).to receive(:new).with(robot, text, source).and_return(message)
|
33
|
+
expect(robot).to receive(:receive).with(message)
|
34
|
+
subject.room_message(room)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Campfire::Connector do
|
4
|
+
let(:robot) { double }
|
5
|
+
let(:subdomain) { 'mycampfire' }
|
6
|
+
let(:apikey) { '2e9f45bb934c0fa13e9f19ee0901c316fda9fc1' }
|
7
|
+
let(:rooms) { %w( 12345 41234 ) }
|
8
|
+
let(:options) { { subdomain: subdomain, apikey: apikey, rooms: rooms } }
|
9
|
+
let(:campfire) { double }
|
10
|
+
|
11
|
+
subject { described_class.new(robot, options) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
allow(Tinder::Campfire).to receive(:new).and_return(campfire)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#connect' do
|
18
|
+
it 'connects the campfire connection' do
|
19
|
+
expect(Tinder::Campfire).to receive(:new).with(subdomain, token: apikey)
|
20
|
+
subject.connect
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#join_rooms' do
|
25
|
+
describe 'when I have access to the room' do
|
26
|
+
let(:room) { double('Room', id: 666) }
|
27
|
+
|
28
|
+
before do
|
29
|
+
allow(campfire).to receive(:find_room_by_id).and_return(room)
|
30
|
+
subject.connect
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'joins each room' do
|
34
|
+
expect(Campfire::Callback).to receive(:new).
|
35
|
+
with(robot).
|
36
|
+
and_return(callback = double('Callback'))
|
37
|
+
expect(callback).to receive(:room_message).with(room)
|
38
|
+
|
39
|
+
expect(room).to receive(:join)
|
40
|
+
|
41
|
+
subject.join_rooms [ double ]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when I don't have access to the room" do
|
46
|
+
before do
|
47
|
+
allow(campfire).to receive(:find_room_by_id).and_return(nil)
|
48
|
+
subject.connect
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'raises an exception' do
|
52
|
+
expect { subject.join_rooms [ double ] }.to raise_error(Campfire::RoomNotAvailable)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#send_messages' do
|
58
|
+
let(:message) { "I'm gonna drink 'til I reboot." }
|
59
|
+
|
60
|
+
let(:room) { double }
|
61
|
+
|
62
|
+
before do
|
63
|
+
allow(campfire).to receive(:find_room_by_id).and_return(room)
|
64
|
+
subject.connect
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'speaks each message into room' do
|
68
|
+
expect(room).to receive(:speak).with(message)
|
69
|
+
subject.send_messages double(id: 1), [ message ]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Lita::Adapters::Campfire do
|
4
|
+
before do
|
5
|
+
Lita.configure do |config|
|
6
|
+
config.adapter.subdomain = 'foodomain'
|
7
|
+
config.adapter.apikey = 'fooapikey'
|
8
|
+
config.adapter.rooms = ['fooroom']
|
9
|
+
end
|
10
|
+
|
11
|
+
allow(described_class::Connector).to receive(:new).and_return(connector)
|
12
|
+
end
|
13
|
+
|
14
|
+
subject { described_class.new(robot) }
|
15
|
+
|
16
|
+
let(:robot) { double("Lita::Robot") }
|
17
|
+
let(:connector) { double("Lita::Adapters::Campfire::Connector") }
|
18
|
+
|
19
|
+
it "registers with Lita" do
|
20
|
+
expect(Lita.adapters[:campfire]).to eql(described_class)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "requires config.subdomain, config.apikey and config.rooms" do
|
24
|
+
Lita.clear_config
|
25
|
+
expect(Lita.logger).to receive(:fatal).with(/subdomain, apikey, rooms/)
|
26
|
+
expect { subject }.to raise_error(SystemExit)
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#run' do
|
30
|
+
before do
|
31
|
+
allow(subject.connector).to receive(:connect)
|
32
|
+
allow(subject.connector).to receive(:join_rooms)
|
33
|
+
allow(subject).to receive(:sleep)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'connects to campfire' do
|
37
|
+
expect(subject.connector).to receive(:connect)
|
38
|
+
subject.run
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'join specified rooms' do
|
42
|
+
rooms = ['room1', 'room2']
|
43
|
+
Lita.config.adapter.rooms = rooms
|
44
|
+
expect(subject.connector).to receive(:join_rooms).with(rooms)
|
45
|
+
subject.run
|
46
|
+
end
|
47
|
+
|
48
|
+
it "sleeps the main thread" do
|
49
|
+
expect(subject).to receive(:sleep)
|
50
|
+
subject.run
|
51
|
+
end
|
52
|
+
|
53
|
+
it "disconnects gracefully on interrupt" do
|
54
|
+
expect(subject).to receive(:disconnect)
|
55
|
+
allow(subject).to receive(:sleep).and_raise(Interrupt)
|
56
|
+
subject.run
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#send_messages' do
|
61
|
+
it 'sends messages to rooms' do
|
62
|
+
source = double("Lita::Source", room: "room_id")
|
63
|
+
expect(subject.connector).to receive(:send_messages).with(
|
64
|
+
'room_id',
|
65
|
+
["Hello!"]
|
66
|
+
)
|
67
|
+
subject.send_messages(source, ["Hello!"])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#set_topic" do
|
72
|
+
it "sets a new topic for a room" do
|
73
|
+
source = double("Lita::Source", room: "room_id")
|
74
|
+
expect(subject.connector).to receive(:set_topic).with(
|
75
|
+
"room_id",
|
76
|
+
"Topic"
|
77
|
+
)
|
78
|
+
subject.set_topic(source, "Topic")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "#shut_down" do
|
83
|
+
it "shuts down the connector" do
|
84
|
+
expect(subject.connector).to receive(:disconnect)
|
85
|
+
subject.shut_down
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
require "coveralls"
|
3
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
4
|
+
SimpleCov::Formatter::HTMLFormatter,
|
5
|
+
Coveralls::SimpleCov::Formatter
|
6
|
+
]
|
7
|
+
SimpleCov.start { add_filter "/spec/" }
|
8
|
+
|
9
|
+
require "lita-campfire"
|
10
|
+
require "lita/rspec"
|
11
|
+
|
12
|
+
include Lita::Adapters
|
metadata
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-campfire
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jose Luis Salas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-24 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: tinder
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.9.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.9.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.14'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.14'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: A Campfire adapter for Lita.
|
112
|
+
email:
|
113
|
+
- josacar@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .travis.yml
|
120
|
+
- Gemfile
|
121
|
+
- Gemfile.lock
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- lib/lita-campfire.rb
|
125
|
+
- lib/lita/adapters/campfire.rb
|
126
|
+
- lib/lita/adapters/campfire/callback.rb
|
127
|
+
- lib/lita/adapters/campfire/connector.rb
|
128
|
+
- lib/lita/adapters/campfire/room_not_available.rb
|
129
|
+
- lita-campfire.gemspec
|
130
|
+
- spec/lita/adapters/campfire/callback_spec.rb
|
131
|
+
- spec/lita/adapters/campfire/connector_spec.rb
|
132
|
+
- spec/lita/adapters/campfire_spec.rb
|
133
|
+
- spec/spec_helper.rb
|
134
|
+
homepage: https://github.com/josacar/lita-campfire
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
metadata: {}
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.0.3
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: A Campfire adapter for the Lita chat robot.
|
158
|
+
test_files:
|
159
|
+
- spec/lita/adapters/campfire/callback_spec.rb
|
160
|
+
- spec/lita/adapters/campfire/connector_spec.rb
|
161
|
+
- spec/lita/adapters/campfire_spec.rb
|
162
|
+
- spec/spec_helper.rb
|