lita-teamwork 0.3.1 → 0.4.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/lib/lita-teamwork.rb +1 -0
- data/lib/lita/domain/account.rb +2 -2
- data/lib/lita/domain/github_repo.rb +18 -0
- data/lib/lita/domain/hub_client.rb +2 -4
- data/lib/lita/handlers/teamwork.rb +42 -16
- data/lita-teamwork.gemspec +1 -1
- data/spec/lita/handlers/teamwork_spec.rb +43 -13
- data/spec/lita/hub_client_spec.rb +7 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e71151611f11469e91fee7eb596c4496eb5f9047
|
4
|
+
data.tar.gz: 3d7892aaa1dd5419f2da271dd0aab561afe76547
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61cedefc9065ab38d13cea5194bd27a3eca68e6a8ab7f8f6d10d9088c31c143b9396febce6fea27f53fdde3ae3b7014e30fa40444e47bd9545bc1f66babe0146
|
7
|
+
data.tar.gz: 08d3224907bd921ba99d3de7ada77fb288b2d6ec53b1023d7b8b20a7f1ef46f157c8221275ae1ecc1e291be0c542287cdd0c073f139a840100a9e80f956a66b7
|
data/lib/lita-teamwork.rb
CHANGED
@@ -9,6 +9,7 @@ require "lita/handlers/teamwork"
|
|
9
9
|
require "lita/domain/account"
|
10
10
|
require "lita/domain/account_repo"
|
11
11
|
require "lita/domain/hub_client"
|
12
|
+
require "lita/domain/github_repo"
|
12
13
|
|
13
14
|
Lita::Handlers::Teamwork.template_root File.expand_path(
|
14
15
|
File.join("..", "..", "templates"),
|
data/lib/lita/domain/account.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class Account
|
2
2
|
|
3
3
|
def initialize
|
4
|
-
@
|
4
|
+
@ac_repo = AccountRepo.instance
|
5
5
|
end
|
6
6
|
|
7
7
|
def name(assignee)
|
@@ -12,7 +12,7 @@ class Account
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def account_mapping(login)
|
15
|
-
account = @
|
15
|
+
account = @ac_repo.find_by(login)
|
16
16
|
account ? account : login
|
17
17
|
end
|
18
18
|
|
@@ -6,13 +6,11 @@ class HubClient
|
|
6
6
|
def initialize
|
7
7
|
Dotenv.load
|
8
8
|
@client = Octokit::Client.new(:access_token => ENV['ACCESS_TOKEN'])
|
9
|
-
# @account = Account.new
|
10
9
|
Octokit.auto_paginate = true
|
11
10
|
end
|
12
11
|
|
13
|
-
def list_issues(repo)
|
14
|
-
@client.list_issues(repo)
|
15
|
-
# puts issue.title + " " + @account.name(issue.assignee) if issue.assignee
|
12
|
+
def list_issues(repo, option={})
|
13
|
+
@client.list_issues(repo, option)
|
16
14
|
end
|
17
15
|
|
18
16
|
end
|
@@ -2,39 +2,65 @@ module Lita
|
|
2
2
|
module Handlers
|
3
3
|
class Teamwork < Handler
|
4
4
|
|
5
|
-
route(
|
6
|
-
route(
|
7
|
-
route(
|
8
|
-
route(
|
5
|
+
route(/^map$/, :map)
|
6
|
+
route(/^map\s+(.+)/, :map_regist)
|
7
|
+
route(/^delete$/, :delete)
|
8
|
+
route(/^hub$/, :hub)
|
9
|
+
route(/^hub\s+(.+)$/, :hub_regist)
|
10
|
+
route(/^issues$/, :issues)
|
11
|
+
route(/^issues\s+(.+)$/, :working)
|
9
12
|
|
10
13
|
def initialize(robot)
|
11
14
|
super(robot)
|
12
|
-
@
|
15
|
+
@ac_repo = AccountRepo.instance
|
16
|
+
@hub_repo = GithubRepo.instance
|
13
17
|
end
|
14
18
|
|
15
|
-
def
|
16
|
-
@
|
17
|
-
|
19
|
+
def map(response)
|
20
|
+
response.reply("map is empty") if @ac_repo.list.empty?
|
21
|
+
@ac_repo.list.each do |key,value|
|
22
|
+
response.reply("*#{value}* is *#{key}* in _GitHub_")
|
18
23
|
end
|
19
24
|
end
|
20
25
|
|
21
|
-
def
|
22
|
-
@
|
23
|
-
response.reply("
|
26
|
+
def map_regist(response)
|
27
|
+
@ac_repo.regist(login: response.match_data[1], slack_name: response.user.name)
|
28
|
+
response.reply("set *#{response.user.name}* is *#{response.match_data[1]}* in _GitHub_")
|
24
29
|
end
|
25
30
|
|
26
31
|
def delete(response)
|
27
|
-
login_name = @
|
28
|
-
@
|
29
|
-
response.reply("delete
|
32
|
+
login_name = @ac_repo.find_by(response.user.name)
|
33
|
+
@ac_repo.delete(login_name)
|
34
|
+
response.reply("delete *#{login_name}* from map")
|
35
|
+
end
|
36
|
+
|
37
|
+
def hub(response)
|
38
|
+
response.reply(@hub_repo.name)
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def hub_regist(response)
|
43
|
+
@hub_repo.regist(response.match_data[1])
|
44
|
+
response.reply("set *#{response.match_data[1]}* to repository")
|
30
45
|
end
|
31
46
|
|
32
47
|
def issues(response)
|
33
48
|
client = HubClient.new
|
34
49
|
account = Account.new
|
35
|
-
issues = client.list_issues(
|
50
|
+
issues = client.list_issues(@hub_repo.name)
|
51
|
+
issues.each do |issue|
|
52
|
+
response.reply "*`#{issue.title}`* _assignee_ *#{account.name(issue.assignee)}*" if issue.assignee
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def working(response)
|
57
|
+
client = HubClient.new
|
58
|
+
account = Account.new
|
59
|
+
label = response.match_data[1]
|
60
|
+
assignee = response.match_data[2]
|
61
|
+
issues = client.list_issues(@hub_repo.name, {labels: label, assignee: assignee})
|
36
62
|
issues.each do |issue|
|
37
|
-
response.reply issue.title
|
63
|
+
response.reply "*`#{issue.title}`* working _assignee_ *#{account.name(issue.assignee)}*"
|
38
64
|
end
|
39
65
|
end
|
40
66
|
|
data/lita-teamwork.gemspec
CHANGED
@@ -4,35 +4,65 @@ describe Lita::Handlers::Teamwork, lita_handler: true do
|
|
4
4
|
|
5
5
|
before(:each) do
|
6
6
|
AccountRepo.instance.clear
|
7
|
+
GithubRepo.instance.clear
|
7
8
|
end
|
8
9
|
|
9
|
-
it { is_expected.to route("
|
10
|
-
it { is_expected.to route('
|
10
|
+
it { is_expected.to route("map").to(:map) }
|
11
|
+
it { is_expected.to route('map githubname').to(:map_regist) }
|
11
12
|
it { is_expected.to route('delete').to(:delete) }
|
13
|
+
it { is_expected.to route('hub githubname').to(:hub_regist) }
|
14
|
+
it { is_expected.to route('hub').to(:hub) }
|
12
15
|
it { is_expected.to route('issues').to(:issues) }
|
16
|
+
it { is_expected.to route('issues working').to(:working) }
|
13
17
|
|
14
|
-
it "
|
15
|
-
send_message("
|
16
|
-
expect(replies.last).to eq("
|
18
|
+
it "map" do
|
19
|
+
send_message("map yutaka")
|
20
|
+
expect(replies.last).to eq("set *#{user.name}* is *yutaka* in _GitHub_")
|
17
21
|
end
|
18
22
|
|
19
|
-
it "
|
20
|
-
send_message("
|
21
|
-
send_message("
|
22
|
-
expect(replies.last).to eq(
|
23
|
+
it "map" do
|
24
|
+
send_message("map yutakakinjyo")
|
25
|
+
send_message("map")
|
26
|
+
expect(replies.last).to eq("*Test User* is *yutakakinjyo* in _GitHub_")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "map is empty" do
|
30
|
+
send_message("map")
|
31
|
+
expect(replies.last).to eq("map is empty")
|
23
32
|
end
|
24
33
|
|
25
34
|
it "delete" do
|
26
|
-
send_message("
|
35
|
+
send_message("map yutakakinjyo")
|
27
36
|
send_message("delete")
|
28
|
-
expect(replies.last).to eq("delete yutakakinjyo from
|
37
|
+
expect(replies.last).to eq("delete *yutakakinjyo* from map")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "set hub repo" do
|
41
|
+
send_message("hub yutakakinjyo/lita-teamwork")
|
42
|
+
expect(replies.last).to eq("set *yutakakinjyo/lita-teamwork* to repository")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "hub name" do
|
46
|
+
send_message("hub yutakakinjyo/lita-teamwork")
|
47
|
+
send_message("hub")
|
48
|
+
expect(replies.last).to eq("yutakakinjyo/lita-teamwork")
|
29
49
|
end
|
30
50
|
|
51
|
+
|
31
52
|
it "isseus", :skip => true do
|
32
|
-
send_message("
|
53
|
+
send_message("hub yutakakinjyo/lita-teamwork")
|
54
|
+
send_message("map yutakakinjyo")
|
33
55
|
send_message("issues")
|
34
|
-
expect(replies.last).to eq("issue for test
|
56
|
+
expect(replies.last).to eq("*`issue for test`* _assignee_ *Test User*")
|
35
57
|
end
|
36
58
|
|
59
|
+
it "working", :skip => true do
|
60
|
+
send_message("hub yutakakinjyo/lita-teamwork")
|
61
|
+
send_message("map yutakakinjyo")
|
62
|
+
send_message("issues working")
|
63
|
+
expect(replies.last).to eq("*`issue for test`* working _assignee_ *Test User*")
|
64
|
+
end
|
65
|
+
|
66
|
+
|
37
67
|
|
38
68
|
end
|
@@ -6,9 +6,15 @@ describe HubClient do
|
|
6
6
|
@client = HubClient.new
|
7
7
|
end
|
8
8
|
|
9
|
-
it "list_issues", :skip => true do
|
9
|
+
it "list_issues" , :skip => true do
|
10
10
|
issue = @client.list_issues("yutakakinjyo/lita-teamwork")[0]
|
11
11
|
expect("issue for test").to eq(issue.title)
|
12
12
|
end
|
13
13
|
|
14
|
+
it "list_issues option", :skip => true do
|
15
|
+
issue = @client.list_issues("yutakakinjyo/lita-teamwork", {labels: "Working"})[0]
|
16
|
+
expect("issue for test").to eq(issue.title)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
14
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-teamwork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yutakakinjyo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- lib/lita-teamwork.rb
|
138
138
|
- lib/lita/domain/account.rb
|
139
139
|
- lib/lita/domain/account_repo.rb
|
140
|
+
- lib/lita/domain/github_repo.rb
|
140
141
|
- lib/lita/domain/hub_client.rb
|
141
142
|
- lib/lita/handlers/teamwork.rb
|
142
143
|
- lita-teamwork.gemspec
|