jira-api 0.1.1 → 0.1.2
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.
- data/lib/jira-api/jira.rb +18 -11
- metadata +1 -1
data/lib/jira-api/jira.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module Jira
|
2
|
-
JIRA_URL = ENV['JIRA_URL'].to_s.gsub!(/\/*$/, '')
|
3
|
-
JIRA_USER_NAME = ENV['JIRA_USER_NAME']
|
4
|
-
JIRA_AUTH_MD5 = ENV['JIRA_AUTH_MD5']
|
5
|
-
JIRA_PROJECT_ID = ENV['JIRA_PROJECT_ID']
|
6
|
-
JIRA_USER_AGENT = ENV['JIRA_USER_AGENT'] || 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'
|
2
|
+
# JIRA_URL = ENV['JIRA_URL'].to_s.gsub!(/\/*$/, '')
|
3
|
+
# JIRA_USER_NAME = ENV['JIRA_USER_NAME']
|
4
|
+
# JIRA_AUTH_MD5 = ENV['JIRA_AUTH_MD5']
|
5
|
+
# JIRA_PROJECT_ID = ENV['JIRA_PROJECT_ID']
|
6
|
+
# JIRA_USER_AGENT = ENV['JIRA_USER_AGENT'] || 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'
|
7
7
|
|
8
8
|
def self.get(id)
|
9
|
-
|
9
|
+
host = config('jira.url').gsub(/\/*$/, '')
|
10
|
+
html = Request.fetch(host + '/browse/' + id.to_s, config('jira.auth_md5'), config('jira.user_agent')).to_s
|
10
11
|
jira_id = html [/<a id=\"key-val\"[^>]*>([^<]+)<\/a>/, 1]
|
11
12
|
|
12
13
|
# TODO ... pretty this up for display
|
@@ -14,16 +15,22 @@ module Jira
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def self.create(title, description)
|
18
|
+
host = config('jira.url').gsub(/\/*$/, '')
|
19
|
+
|
17
20
|
params = {
|
18
21
|
'summary' => title,
|
19
|
-
'reporter' =>
|
22
|
+
'reporter' => config('jira.user_name'),
|
20
23
|
'description'=> '{code}' + description.to_s.gsub!(/\r?\n/, "\r\n") + '{code}',
|
21
|
-
'assignee' =>
|
24
|
+
'assignee' => config('jira.user_name'),
|
22
25
|
'priority' => 3, # major
|
23
|
-
'pid' =>
|
26
|
+
'pid' => config('jira.project_id'),
|
24
27
|
'issuetype' => 3 # task
|
25
|
-
}
|
28
|
+
}
|
29
|
+
|
30
|
+
return Request.post(host + '/secure/CreateIssueDetails.jspa', params, config('jira.auth_md5'), config('jira.user_agent')).to_s
|
31
|
+
end
|
26
32
|
|
27
|
-
|
33
|
+
def self.config(key)
|
34
|
+
return ENV[key.upcase.gsub(/\./, '_')].to_s.strip
|
28
35
|
end
|
29
36
|
end
|