sappho-data-publisher 0.2.3 → 0.2.4
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.
|
@@ -14,33 +14,44 @@ module Sappho
|
|
|
14
14
|
def initialize
|
|
15
15
|
@appName = self.class.name.split("::").last
|
|
16
16
|
@appServer = nil
|
|
17
|
-
@
|
|
17
|
+
@token = nil
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def connect
|
|
21
|
-
raise "you have already attempted to connect to #{@appName}" if @appServer
|
|
21
|
+
raise "you have already attempted to connect to #{@appName}" if @appServer
|
|
22
22
|
modules = Sappho::ApplicationModuleRegister.instance
|
|
23
23
|
@config = modules.get :configuration
|
|
24
24
|
@logger = modules.get :log
|
|
25
25
|
url = @config.data["#{@appName.downcase}.url"]
|
|
26
26
|
mock = "mock#{@appName}"
|
|
27
27
|
@appServer = modules.set?(mock) ? modules.get(mock).mockInstance(url) : yield(url)
|
|
28
|
+
@logger.info "connected to #{@appName} #{url}"
|
|
29
|
+
login
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def login
|
|
28
33
|
@token = @appServer.login @config.data["#{@appName.downcase}.username"], @config.data["#{@appName.downcase}.password"]
|
|
29
|
-
@logger.info "logged
|
|
30
|
-
@loggedIn = true
|
|
34
|
+
@logger.info "logged in to #{@appName}"
|
|
31
35
|
end
|
|
32
36
|
|
|
33
|
-
def
|
|
37
|
+
def logout
|
|
34
38
|
if loggedIn?
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
begin
|
|
40
|
+
@appServer.logout @token
|
|
41
|
+
@logger.info "logged out of #{@appName}"
|
|
42
|
+
rescue
|
|
43
|
+
end
|
|
44
|
+
@token = nil
|
|
37
45
|
end
|
|
38
|
-
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def shutdown
|
|
49
|
+
logout
|
|
39
50
|
@appServer = nil
|
|
40
51
|
end
|
|
41
52
|
|
|
42
53
|
def loggedIn?
|
|
43
|
-
@
|
|
54
|
+
@token
|
|
44
55
|
end
|
|
45
56
|
|
|
46
57
|
private
|
|
@@ -43,25 +43,30 @@ module Sappho
|
|
|
43
43
|
|
|
44
44
|
def getPage spaceKey, pageName
|
|
45
45
|
checkLoggedIn
|
|
46
|
+
logout
|
|
47
|
+
login
|
|
46
48
|
@logger.info "reading wiki page #{spaceKey}:#{pageName}"
|
|
47
49
|
@appServer.getPage(@token, spaceKey, pageName)['content']
|
|
48
50
|
end
|
|
49
51
|
|
|
50
52
|
def setPage spaceKey, parentPageName, pageName, content
|
|
51
53
|
checkLoggedIn
|
|
54
|
+
logout
|
|
55
|
+
login
|
|
52
56
|
begin
|
|
53
|
-
page = @appServer.getPage
|
|
57
|
+
page = @appServer.getPage @token, spaceKey, pageName
|
|
54
58
|
page['content'] = content
|
|
55
59
|
@logger.info "rewriting existing wiki page #{spaceKey}:#{pageName}"
|
|
60
|
+
@appServer.updatePage @token, page, {'versionComment' => "Automatic update", 'minorEdit' => false}
|
|
56
61
|
rescue
|
|
57
62
|
page = {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
'space' => spaceKey,
|
|
64
|
+
'parentId' => @appServer.getPage(@token, spaceKey, parentPageName)['id'],
|
|
65
|
+
'title' => pageName,
|
|
66
|
+
'content' => content}
|
|
62
67
|
@logger.info "creating new wiki page #{spaceKey}:#{pageName} as child of #{parentPageName}"
|
|
68
|
+
@appServer.storePage @token, page
|
|
63
69
|
end
|
|
64
|
-
@appServer.storePage @token, page
|
|
65
70
|
end
|
|
66
71
|
|
|
67
72
|
end
|
|
@@ -74,33 +74,29 @@ module Sappho
|
|
|
74
74
|
|
|
75
75
|
def jqlQuery jql, maxresults
|
|
76
76
|
@logger.info "fetching up to #{maxresults} Jira issues for #{jql}"
|
|
77
|
-
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def getJiraIssueDetails issue, cookedIssue
|
|
81
|
-
['id', 'key', 'summary', 'description', 'assignee', 'created', 'duedate', 'priority',
|
|
82
|
-
'project', 'reporter', 'resolution', 'status', 'type', 'updated'].each { |key|
|
|
83
|
-
cookedIssue[key] = issue[key]
|
|
84
|
-
}
|
|
85
|
-
cookedIssue['components'] = components = []
|
|
86
|
-
issue['components'].each { |component| components << component['name'] }
|
|
87
|
-
cookedIssue['cf'] = customFields = {}
|
|
88
|
-
@allCustomFields.each { |customField|
|
|
89
|
-
customFields[cfname customField['id']] = {'name' => customField['name']}
|
|
90
|
-
}
|
|
91
|
-
issue['customFieldValues'].each { |customFieldValue|
|
|
92
|
-
customFields[cfname customFieldValue['customfieldId']]['values'] =
|
|
93
|
-
customFieldValue['values']
|
|
94
|
-
}
|
|
95
|
-
cookedIssue['subtasks'] = cookedSubtasks = []
|
|
96
|
-
subtasks = jqlQuery "parent=#{issue['key']}", 100
|
|
97
|
-
cookIssues subtasks, cookedSubtasks
|
|
77
|
+
@appServer.getIssuesFromJqlSearch @token, jql, maxresults
|
|
98
78
|
end
|
|
99
79
|
|
|
100
80
|
def cookIssues issues, cookedIssues
|
|
101
81
|
issues.each { |issue|
|
|
102
82
|
cookedIssue = {}
|
|
103
|
-
|
|
83
|
+
['id', 'key', 'summary', 'description', 'assignee', 'created', 'duedate', 'priority',
|
|
84
|
+
'project', 'reporter', 'resolution', 'status', 'type', 'updated'].each { |key|
|
|
85
|
+
cookedIssue[key] = issue[key]
|
|
86
|
+
}
|
|
87
|
+
cookedIssue['components'] = components = []
|
|
88
|
+
issue['components'].each { |component| components << component['name'] }
|
|
89
|
+
cookedIssue['cf'] = customFields = {}
|
|
90
|
+
@allCustomFields.each { |customField|
|
|
91
|
+
customFields[cfname customField['id']] = {'name' => customField['name']}
|
|
92
|
+
}
|
|
93
|
+
issue['customFieldValues'].each { |customFieldValue|
|
|
94
|
+
customFields[cfname customFieldValue['customfieldId']]['values'] =
|
|
95
|
+
customFieldValue['values']
|
|
96
|
+
}
|
|
97
|
+
cookedIssue['subtasks'] = cookedSubtasks = []
|
|
98
|
+
subtasks = jqlQuery "parent=#{issue['key']}", 100
|
|
99
|
+
cookIssues subtasks, cookedSubtasks
|
|
104
100
|
cookedIssues << cookedIssue
|
|
105
101
|
}
|
|
106
102
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sappho-data-publisher
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 31
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 2
|
|
9
|
-
-
|
|
10
|
-
version: 0.2.
|
|
9
|
+
- 4
|
|
10
|
+
version: 0.2.4
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Andrew Heald
|