Class: Lita::Handlers::Teamwork

Inherits:
Handler
  • Object
show all
Defined in:
lib/lita/handlers/teamwork.rb

Instance Method Summary collapse

Constructor Details

#initialize(robot) ⇒ Teamwork

Returns a new instance of Teamwork.



13
14
15
16
17
# File 'lib/lita/handlers/teamwork.rb', line 13

def initialize(robot)
  super(robot)
  @ac_repo = AccountRepo.instance
  @hub_repo = GithubRepo.instance
end

Instance Method Details

#delete(response) ⇒ Object



31
32
33
34
35
# File 'lib/lita/handlers/teamwork.rb', line 31

def delete(response)
   = @ac_repo.find_by(response.user.name)
  @ac_repo.delete()
  response.reply("delete *#{}* from map")
end

#hub(response) ⇒ Object



37
38
39
# File 'lib/lita/handlers/teamwork.rb', line 37

def hub(response)
  response.reply(@hub_repo.name)
end

#hub_regist(response) ⇒ Object



42
43
44
45
# File 'lib/lita/handlers/teamwork.rb', line 42

def hub_regist(response)
  @hub_repo.regist(response.match_data[1])
  response.reply("set *#{response.match_data[1]}* to repository")
end

#issues(response) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/lita/handlers/teamwork.rb', line 47

def issues(response)
  client = HubClient.new
   = Account.new
  issues = client.list_issues(@hub_repo.name)
  issues.each do |issue|
    response.reply "*`#{issue.title}`* _assignee_ *#{.name(issue.assignee)}*" if issue.assignee
  end
end

#map(response) ⇒ Object



19
20
21
22
23
24
# File 'lib/lita/handlers/teamwork.rb', line 19

def map(response)
  response.reply("map is empty") if @ac_repo.list.empty?
  @ac_repo.list.each do |key,value|
    response.reply("*#{value}* is *#{key}* in _GitHub_")
  end
end

#map_regist(response) ⇒ Object



26
27
28
29
# File 'lib/lita/handlers/teamwork.rb', line 26

def map_regist(response)
  @ac_repo.regist(login: response.match_data[1], slack_name: response.user.name)
  response.reply("set *#{response.user.name}* is *#{response.match_data[1]}* in _GitHub_")
end

#working(response) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/lita/handlers/teamwork.rb', line 56

def working(response)
  client = HubClient.new
   = Account.new
  label = response.match_data[1]
  assignee = response.match_data[2]
  issues = client.list_issues(@hub_repo.name, {labels: label, assignee: assignee})
  issues.each do |issue|
    response.reply "*`#{issue.title}`* working _assignee_ *#{.name(issue.assignee)}*"
  end
end