Class: Ruboty::Jira::Actions::Base
- Inherits:
-
Actions::Base
- Object
- Actions::Base
- Ruboty::Jira::Actions::Base
show all
- Defined in:
- lib/ruboty/jira/actions/base.rb
Instance Method Summary
collapse
Instance Method Details
#associate_project ⇒ Object
56
57
58
59
60
|
# File 'lib/ruboty/jira/actions/base.rb', line 56
def associate_project
project = projects[message.to]
return if project.nil?
project
end
|
#associate_user ⇒ Object
50
51
52
53
54
|
# File 'lib/ruboty/jira/actions/base.rb', line 50
def associate_user
user = users[message.from_name]
return if user.nil?
user
end
|
#client ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/ruboty/jira/actions/base.rb', line 5
def client
JIRA::Client.new(
username: jira_username,
password: jira_password,
site: jira_site,
context_path: jira_context,
auth_type: :basic,
use_ssl: use_ssl
)
end
|
#find_issue(key) ⇒ Object
69
70
71
72
73
74
|
# File 'lib/ruboty/jira/actions/base.rb', line 69
def find_issue(key)
client.Issue.find(key)
rescue => e
Ruboty.logger.error e
nil
end
|
#find_project(key) ⇒ Object
62
63
64
65
66
67
|
# File 'lib/ruboty/jira/actions/base.rb', line 62
def find_project(key)
client.Project.find(key)
rescue => e
Ruboty.logger.error e
nil
end
|
#find_user(key) ⇒ Object
76
77
78
79
80
81
|
# File 'lib/ruboty/jira/actions/base.rb', line 76
def find_user(key)
client.User.find(key)
rescue => e
Ruboty.logger.error e
nil
end
|
#jira_context ⇒ Object
28
29
30
|
# File 'lib/ruboty/jira/actions/base.rb', line 28
def jira_context
ENV['JIRA_CONTEXT_PATH'] || ''
end
|
#jira_password ⇒ Object
20
21
22
|
# File 'lib/ruboty/jira/actions/base.rb', line 20
def jira_password
ENV['JIRA_PASSWORD']
end
|
#jira_site ⇒ Object
24
25
26
|
# File 'lib/ruboty/jira/actions/base.rb', line 24
def jira_site
ENV['JIRA_URL']
end
|
#jira_username ⇒ Object
16
17
18
|
# File 'lib/ruboty/jira/actions/base.rb', line 16
def jira_username
ENV['JIRA_USERNAME']
end
|
#memory ⇒ Object
38
39
40
|
# File 'lib/ruboty/jira/actions/base.rb', line 38
def memory
message.robot.brain.data[Ruboty::Jira::NAME_SPACE] ||= {}
end
|
#projects ⇒ Object
46
47
48
|
# File 'lib/ruboty/jira/actions/base.rb', line 46
def projects
memory['PROJECTS'] ||= {}
end
|
#query_issue(jql) ⇒ Object
83
84
85
|
# File 'lib/ruboty/jira/actions/base.rb', line 83
def query_issue(jql)
client.Issue.jql(jql)
end
|
#use_ssl ⇒ Object
32
33
34
35
36
|
# File 'lib/ruboty/jira/actions/base.rb', line 32
def use_ssl
value = ENV['JIRA_USE_SSL']
return value unless value.nil?
true
end
|
#users ⇒ Object
42
43
44
|
# File 'lib/ruboty/jira/actions/base.rb', line 42
def users
memory['USERS'] ||= {}
end
|
#valid_project? ⇒ Boolean
87
88
89
90
91
92
93
94
|
# File 'lib/ruboty/jira/actions/base.rb', line 87
def valid_project?
return true unless associate_project.nil?
message.reply <<-ERROR
Please associate this channel with the jira project
ex: @Botname jira project associate <project_name>
ERROR
false
end
|
#valid_user? ⇒ Boolean
96
97
98
99
100
101
102
103
|
# File 'lib/ruboty/jira/actions/base.rb', line 96
def valid_user?
return true unless associate_user.nil?
message.reply <<-ERROR
Please associate chat name with the jira account
ex: @Botname jira user #<jira_user_name> is @<chat_name>
ERROR
false
end
|