lita-flowdock 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/GETTING_STARTED.md +75 -0
- data/README.md +38 -30
- data/lib/lita/adapters/flowdock.rb +1 -7
- data/lita-flowdock.gemspec +1 -1
- data/spec/lita/adapters/flowdock/connector_spec.rb +1 -6
- data/spec/lita/adapters/flowdock/message_handler_spec.rb +7 -17
- data/spec/lita/adapters/flowdock/users_creator_spec.rb +11 -25
- data/spec/spec_helper.rb +10 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d17560dac166db8aa3752365bcbfb733d07f37ec
|
4
|
+
data.tar.gz: 4e78edc712c4f725cfa939510e57cd61b44d9803
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 124a803f2ff0243fd3b612ca678e48956f896cff9c12225d7f5163bb029adcf006ff792a7e6cef8ed525dd5768233181954fcb53e9b7fcfa3fb8a1a1cb91974b
|
7
|
+
data.tar.gz: d12dfe101062b92c469c7fb9e5d1d37581ea5c45bb83f82fb42b2594a9fbd50081522d79a2dc856108b87cc45ead652be9c2eff406282143e28aa2239619d36e
|
data/GETTING_STARTED.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# Getting Started
|
2
|
+
|
3
|
+
## Flowdock setup
|
4
|
+
|
5
|
+
1. Create a new Flowdock user for your bot and sign-in as the bot
|
6
|
+
1. Get the Personal API token for the bot from the [API tokens](https://flowdock.com/account/tokens) page.
|
7
|
+
1. Invite the bot account to the flows it should monitor
|
8
|
+
|
9
|
+
## Bot setup
|
10
|
+
|
11
|
+
Development can be done using vagrant and the [development-environment](https://github.com/litaio/development-environment) supplied by the lita project.
|
12
|
+
|
13
|
+
See the [getting started](http://docs.lita.io/getting-started/installation/) docs page on the lita site for more information.
|
14
|
+
|
15
|
+
Assuming you have vagrant installed:
|
16
|
+
|
17
|
+
```shell
|
18
|
+
git clone https://github.com/litaio/development-environment ~/lita-dev
|
19
|
+
cd ~/lita-dev
|
20
|
+
vagrant up
|
21
|
+
vagrant ssh
|
22
|
+
```
|
23
|
+
|
24
|
+
Once you're logged into the vagrant vm:
|
25
|
+
|
26
|
+
```shell
|
27
|
+
export $BOT_NAME=<name of the bot>
|
28
|
+
export $ORG=<flowdock organization name>
|
29
|
+
export $FLOW_NAME=<flowdock flow name>
|
30
|
+
export $FLOWDOCK_API_TOKEN=<flowdock bot's personal api token>
|
31
|
+
```
|
32
|
+
|
33
|
+
```shell
|
34
|
+
cd /vagrant
|
35
|
+
lita new .
|
36
|
+
echo 'gem "lita-whois"' >> Gemfile
|
37
|
+
echo 'gem "lita-flowdock"' >> Gemfile
|
38
|
+
cat << EOF > lita_config.rb
|
39
|
+
Lita.configure do |config|
|
40
|
+
config.robot.name = "$BOT_NAME"
|
41
|
+
config.robot.mention_name = "!"
|
42
|
+
config.robot.log_level = :debug
|
43
|
+
config.robot.adapter = :flowdock
|
44
|
+
config.adapters.flowdock.api_key = "$FLOWDOCK_API_TOKEN"
|
45
|
+
config.adapters.flowdock.organization = "$ORG"
|
46
|
+
config.adapters.flowdock.flows = ["$FLOW_NAME"]
|
47
|
+
end
|
48
|
+
EOF
|
49
|
+
apt-get update && apt-get install build-essential -y
|
50
|
+
bundle install --path vendor/bundle
|
51
|
+
bundle update
|
52
|
+
bundle exec lita
|
53
|
+
```
|
54
|
+
|
55
|
+
## Test it out
|
56
|
+
|
57
|
+
In flowdock, try
|
58
|
+
|
59
|
+
```
|
60
|
+
!help
|
61
|
+
|
62
|
+
<should output help for lita commands>
|
63
|
+
|
64
|
+
!whois github.com
|
65
|
+
|
66
|
+
Whois Server Version 2.0
|
67
|
+
|
68
|
+
Domain names in the .com and .net domains can now be registered
|
69
|
+
with many different competing registrars. Go to http://www.internic.net
|
70
|
+
for detailed information.
|
71
|
+
...
|
72
|
+
```
|
73
|
+
|
74
|
+
# Production
|
75
|
+
For a production setup, try the [chef cookbook](https://github.com/litaio/chef-lita) for lita
|
data/README.md
CHANGED
@@ -3,41 +3,49 @@
|
|
3
3
|
[](https://travis-ci.org/bhouse/lita-flowdock)
|
4
4
|
[](https://coveralls.io/r/bhouse/lita-flowdock?branch=master)
|
5
5
|
|
6
|
-
##
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
## Welcome!
|
7
|
+
|
8
|
+
|
9
|
+
[Lita](https://lita.io) is a chat service bot, similar to [hubot](http://hubot.github.com), but written in ruby. **lita-flowdock** is an adapter to connect Lita to the [Flowdock](http://flowdock.com) chat service.
|
10
|
+
|
11
|
+
### Disclaimer
|
12
|
+
This code is heavily based on the awesome work by [kenjij](https://github.com/kenjij) and [jimmycuadra](https://github.com/jimmycuadra) in the [lita-slack](https://github.com/kenjij/lita-slack) adapter. Changes were made for the difference in the API's between the services.
|
13
|
+
|
14
|
+
Slack uses a bi-directional Websockets API for listening to and posting messages, whereas Flowdock uses a one-way [Server-Sent Events](https://www.flowdock.com/api/streaming) stream for listening in real-time, and a [REST API](https://www.flowdock.com/api/rest) for posting messages.
|
15
|
+
|
16
|
+
|
17
|
+
## Installation
|
14
18
|
|
15
|
-
|
19
|
+
Add lita-flowdock to your Lita instance's Gemfile:
|
16
20
|
|
17
|
-
```
|
18
|
-
|
19
|
-
export $FLOW_NAME=<flowdock flow name>
|
20
|
-
export $FLOW_API_TOKEN=<flowdock flow api token>
|
21
|
+
``` ruby
|
22
|
+
gem "lita-flowdock"
|
21
23
|
```
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
For quick setup, see the [Getting Started](https://github.com/bhouse/lita-flowdock/tree/master/GETTING_STARTED.md) page.
|
26
|
+
|
27
|
+
## Configuration
|
28
|
+
|
29
|
+
### Required Attributes
|
30
|
+
* `api_token` (String) - The bot's personal API token
|
31
|
+
* Login to https://flowdock.com with the bot account
|
32
|
+
* Get the personal API token from https://flowdock.com/account/tokens
|
33
|
+
* `organization` (String) - The organization for the flowdock account
|
34
|
+
* `flows` (Array) - Array of flows the bot should connect to, i.e. `main`
|
35
|
+
|
36
|
+
### Example
|
37
|
+
|
38
|
+
```ruby
|
30
39
|
Lita.configure do |config|
|
31
|
-
config.robot.name = "Lita"
|
32
|
-
config.robot.log_level = :info
|
33
40
|
config.robot.adapter = :flowdock
|
34
|
-
config.
|
35
|
-
|
36
|
-
config.adapters.flowdock.
|
41
|
+
config.robot.name = 'John_McClane'
|
42
|
+
|
43
|
+
config.robot.adapters.flowdock.api_token = '210bf4d1ae890b20265313fdc907903c'
|
44
|
+
config.robot.adapters.flowdock.organization = 'mycompany'
|
45
|
+
config.robot.adapters.flowdock.flows = ['main', 'ops']
|
37
46
|
end
|
38
|
-
EOF
|
39
|
-
apt-get update && apt-get install build-essential -y
|
40
|
-
bundle install --path vendor/bundle
|
41
|
-
bundle update
|
42
|
-
bundle exec lita
|
43
47
|
```
|
48
|
+
|
49
|
+
## License
|
50
|
+
|
51
|
+
[MIT](http://opensource.org/licenses/MIT)
|
@@ -7,9 +7,8 @@ module Lita
|
|
7
7
|
namespace 'flowdock'
|
8
8
|
|
9
9
|
config :api_token, type: String, required: true
|
10
|
-
config :bot_name, type: String, required: true
|
11
10
|
config :organization, type: String, required: true
|
12
|
-
config :flows, type:
|
11
|
+
config :flows, type: Array, required: true
|
13
12
|
|
14
13
|
|
15
14
|
def mention_format(name)
|
@@ -43,12 +42,7 @@ module Lita
|
|
43
42
|
end
|
44
43
|
|
45
44
|
private
|
46
|
-
|
47
45
|
attr_reader :connector
|
48
|
-
|
49
|
-
def bot_name
|
50
|
-
config.bot_name
|
51
|
-
end
|
52
46
|
end
|
53
47
|
|
54
48
|
Lita.register_adapter(:flowdock, Flowdock)
|
data/lita-flowdock.gemspec
CHANGED
@@ -9,12 +9,7 @@ describe Lita::Adapters::Flowdock::Connector, lita: true do
|
|
9
9
|
let(:organization) { 'lita-test' }
|
10
10
|
let(:flows) { ['testing'] }
|
11
11
|
let(:fd_client) { instance_double('Flowdock::Client') }
|
12
|
-
let(:users) {
|
13
|
-
[
|
14
|
-
{'id' => 1, 'name' => 'Test User1', 'nick' => 'user1'},
|
15
|
-
{'id' => 2, 'name' => 'Test User2', 'nick' => 'user2'}
|
16
|
-
]
|
17
|
-
}
|
12
|
+
let(:users) { [ user_hash(1), user_hash(2) ] }
|
18
13
|
|
19
14
|
describe "#new" do
|
20
15
|
it "creates users" do
|
@@ -12,9 +12,7 @@ describe Lita::Adapters::Flowdock::MessageHandler, lita: true do
|
|
12
12
|
{ 'id' => robot_id, 'name' => 'Lita', 'nick' => 'lita' }
|
13
13
|
}
|
14
14
|
let(:test_user_id) { 3 }
|
15
|
-
let(:test_fd_user) {
|
16
|
-
{ 'id' => test_user_id, 'name' => 'Test User3', 'nick' => 'user3' }
|
17
|
-
}
|
15
|
+
let(:test_fd_user) { user_hash(3) }
|
18
16
|
let(:test_flow) { 'testing:lita-test' }
|
19
17
|
|
20
18
|
before do
|
@@ -37,7 +35,7 @@ describe Lita::Adapters::Flowdock::MessageHandler, lita: true do
|
|
37
35
|
end
|
38
36
|
let(:message) { instance_double('Lita::Message', command!: false) }
|
39
37
|
let(:source) { instance_double('Lita::Source', private_message?: false) }
|
40
|
-
let(:user) {
|
38
|
+
let(:user) { user_double(test_user_id) }
|
41
39
|
|
42
40
|
before do
|
43
41
|
allow(Lita::User).to receive(:find_by_id).and_return(user)
|
@@ -103,7 +101,7 @@ describe Lita::Adapters::Flowdock::MessageHandler, lita: true do
|
|
103
101
|
'user' => robot_id
|
104
102
|
}
|
105
103
|
end
|
106
|
-
let(:robot_user) {
|
104
|
+
let(:robot_user) { user_double(robot_id) }
|
107
105
|
|
108
106
|
before do
|
109
107
|
allow(Lita::User).to receive(:find_by_id).and_return(robot_user)
|
@@ -118,9 +116,7 @@ describe Lita::Adapters::Flowdock::MessageHandler, lita: true do
|
|
118
116
|
|
119
117
|
context "a message from an unknown user" do
|
120
118
|
let(:new_user_id) { 4 }
|
121
|
-
let(:new_fd_user) {
|
122
|
-
{ 'id' => new_user_id, 'name' => 'Test User4', 'nick' => 'user4' }
|
123
|
-
}
|
119
|
+
let(:new_fd_user) { user_hash(4) }
|
124
120
|
|
125
121
|
|
126
122
|
let(:data) do
|
@@ -131,9 +127,7 @@ describe Lita::Adapters::Flowdock::MessageHandler, lita: true do
|
|
131
127
|
'user' => new_user_id
|
132
128
|
}
|
133
129
|
end
|
134
|
-
let(:user4) {
|
135
|
-
'Lita::User', id: 4, name: 'Test User4', mention_name: 'user4'
|
136
|
-
)}
|
130
|
+
let(:user4) { user_double(4) }
|
137
131
|
|
138
132
|
before do
|
139
133
|
allow(Lita::User).to receive(:find_by_id).with(
|
@@ -184,9 +178,7 @@ describe Lita::Adapters::Flowdock::MessageHandler, lita: true do
|
|
184
178
|
}
|
185
179
|
end
|
186
180
|
let(:added_user_id) { 5 }
|
187
|
-
let(:added_user_fd)
|
188
|
-
{ 'id' => 5, 'name' => 'Test User5', 'nick' => 'user5' }
|
189
|
-
end
|
181
|
+
let(:added_user_fd) { user_hash(5) }
|
190
182
|
|
191
183
|
before do
|
192
184
|
allow(Lita::User).to receive(:find_by_id).with(5).and_return(nil)
|
@@ -206,9 +198,7 @@ describe Lita::Adapters::Flowdock::MessageHandler, lita: true do
|
|
206
198
|
|
207
199
|
context "for a user joining the flow" do
|
208
200
|
let(:joining_user_id) { 6 }
|
209
|
-
let(:joining_user_fd)
|
210
|
-
{ 'id' => 6, 'name' => 'Test User6', 'nick' => 'user6' }
|
211
|
-
end
|
201
|
+
let(:joining_user_fd) { user_hash(6) }
|
212
202
|
let(:data) do
|
213
203
|
{
|
214
204
|
'content' => {'type' => 'join', 'description' => 'tbd'},
|
@@ -3,46 +3,32 @@ require 'spec_helper'
|
|
3
3
|
describe Lita::Adapters::Flowdock::UsersCreator do
|
4
4
|
subject { described_class }
|
5
5
|
|
6
|
-
def stubbed_user(id)
|
7
|
-
instance_double(
|
8
|
-
'Lita::User', id: id, name: "Test User#{id}", mention_name: "user#{id}"
|
9
|
-
)
|
10
|
-
end
|
11
|
-
|
12
6
|
describe "#create_user" do
|
13
|
-
let(:
|
14
|
-
{
|
15
|
-
'id' => 1,
|
16
|
-
'name' => 'Test User1',
|
17
|
-
'nick' => 'user1'
|
18
|
-
}
|
19
|
-
end
|
7
|
+
let(:user1) { user_hash(1) }
|
20
8
|
|
21
9
|
it "creates a single Lita user" do
|
22
10
|
expect(Lita::User).to receive(:create).with(
|
23
11
|
1,
|
24
|
-
{
|
25
|
-
|
12
|
+
{
|
13
|
+
'name' => 'Test User1',
|
14
|
+
'mention_name' => 'user1'
|
15
|
+
}).and_return(user_double(1))
|
26
16
|
|
27
|
-
subject.create_user(
|
17
|
+
subject.create_user(user1)
|
28
18
|
end
|
29
19
|
end
|
30
20
|
|
31
21
|
describe "#create_users" do
|
32
|
-
let(:users)
|
33
|
-
[
|
34
|
-
{'id' => 1, 'name' => 'Test User1', 'nick' => 'user1'},
|
35
|
-
{'id' => 2, 'name' => 'Test User2', 'nick' => 'user2'},
|
36
|
-
{'id' => 3, 'name' => 'Test User3', 'nick' => 'user3'}
|
37
|
-
]
|
38
|
-
end
|
22
|
+
let(:users) { [ user_hash(1), user_hash(2), user_hash(3) ] }
|
39
23
|
|
40
24
|
it "creates multiple Lita users" do
|
41
25
|
(1..3).each do |id|
|
42
26
|
expect(Lita::User).to receive(:create).with(
|
43
27
|
id,
|
44
|
-
{
|
45
|
-
|
28
|
+
{
|
29
|
+
'name' => "Test User#{id}",
|
30
|
+
'mention_name' => "user#{id}"
|
31
|
+
}).and_return(user_double(id))
|
46
32
|
end
|
47
33
|
|
48
34
|
subject.create_users(users)
|
data/spec/spec_helper.rb
CHANGED
@@ -17,3 +17,13 @@ RSpec.configure do |config|
|
|
17
17
|
config.color = true
|
18
18
|
config.formatter = :documentation
|
19
19
|
end
|
20
|
+
|
21
|
+
def user_double(id)
|
22
|
+
instance_double(
|
23
|
+
'Lita::User', id: id, name: "Test User#{id}", mention_name: "user#{id}"
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def user_hash(id)
|
28
|
+
{ 'id' => id, 'name' => "Test User#{id}", "nick" => "user#{id}" }
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-flowdock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben House
|
@@ -173,6 +173,7 @@ extra_rdoc_files: []
|
|
173
173
|
files:
|
174
174
|
- ".gitignore"
|
175
175
|
- ".travis.yml"
|
176
|
+
- GETTING_STARTED.md
|
176
177
|
- Gemfile
|
177
178
|
- LICENSE
|
178
179
|
- README.md
|