lita-teamwork 0.3.1 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e54234454934cfdb758b24ea41127eeeac63579
4
- data.tar.gz: 87719f275091c433a6daab56dd8acc8bcf731856
3
+ metadata.gz: e71151611f11469e91fee7eb596c4496eb5f9047
4
+ data.tar.gz: 3d7892aaa1dd5419f2da271dd0aab561afe76547
5
5
  SHA512:
6
- metadata.gz: cf5fdc8f22fb7e671bfb830438a49f3d8feac57fbbfa7b64674169b80fa60cc3c3ed549a6dbf83cb2c37d6e9089b78792ce5a6812750deeda8cebbb68aa7349a
7
- data.tar.gz: 59f75147938e44b00c2589c0c11303ce1bfbea6d8aeba558656c8024a88222627edc28aa378ea89e98c8d94ca51488ef9698e0a2ba5a1200db1082e6c5003f07
6
+ metadata.gz: 61cedefc9065ab38d13cea5194bd27a3eca68e6a8ab7f8f6d10d9088c31c143b9396febce6fea27f53fdde3ae3b7014e30fa40444e47bd9545bc1f66babe0146
7
+ data.tar.gz: 08d3224907bd921ba99d3de7ada77fb288b2d6ec53b1023d7b8b20a7f1ef46f157c8221275ae1ecc1e291be0c542287cdd0c073f139a840100a9e80f956a66b7
@@ -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"),
@@ -1,7 +1,7 @@
1
1
  class Account
2
2
 
3
3
  def initialize
4
- @repo = AccountRepo.instance
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 = @repo.find_by(login)
15
+ account = @ac_repo.find_by(login)
16
16
  account ? account : login
17
17
  end
18
18
 
@@ -0,0 +1,18 @@
1
+ require 'singleton'
2
+
3
+ class GithubRepo
4
+ include Singleton
5
+
6
+ def regist(repo)
7
+ @hub_repo = repo
8
+ end
9
+
10
+ def name
11
+ @hub_repo
12
+ end
13
+
14
+ def clear
15
+ @hub_repo = nil
16
+ end
17
+
18
+ end
@@ -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(/list/, :list)
6
- route(/regist\s+(.+)/, :regist)
7
- route(/delete/, :delete)
8
- route(/issues/, :issues)
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
- @repo = AccountRepo.instance
15
+ @ac_repo = AccountRepo.instance
16
+ @hub_repo = GithubRepo.instance
13
17
  end
14
18
 
15
- def list(response)
16
- @repo.list.each do |key,value|
17
- response.reply(value + " is " + key + " in GitHub")
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 regist(response)
22
- @repo.regist(login: response.match_data[1], slack_name: response.user.name)
23
- response.reply("register \"" + response.user.name + "\" to " + response.match_data[1])
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 = @repo.find_by(response.user.name)
28
- @repo.delete(login_name)
29
- response.reply("delete " + login_name + " from account map list")
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("yutakakinjyo/lita-teamwork")
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 + " assignee " + account.name(issue.assignee) if issue.assignee
63
+ response.reply "*`#{issue.title}`* working _assignee_ *#{account.name(issue.assignee)}*"
38
64
  end
39
65
  end
40
66
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-teamwork"
3
- spec.version = "0.3.1"
3
+ spec.version = "0.4.1"
4
4
  spec.authors = ["yutakakinjyo"]
5
5
  spec.email = ["yutakakinjyo@gmail.com"]
6
6
  spec.description = "for teamwork on chat. alpha version"
@@ -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("list").to(:list) }
10
- it { is_expected.to route('regist yutaka').to(:regist) }
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 "regist" do
15
- send_message("regist yutaka")
16
- expect(replies.last).to eq("register \"" + user.name + "\" to yutaka")
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 "list" do
20
- send_message("regist yutakakinjyo")
21
- send_message("list")
22
- expect(replies.last).to eq(user.name + " is yutakakinjyo in GitHub")
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("regist yutakakinjyo")
35
+ send_message("map yutakakinjyo")
27
36
  send_message("delete")
28
- expect(replies.last).to eq("delete yutakakinjyo from account map list")
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("regist yutakakinjyo")
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 assignee Test User")
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.3.1
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-05 00:00:00.000000000 Z
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