sappho-data-publisher 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  require 'sappho-basics/module_register'
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  require 'sappho-basics/module_register'
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  require 'sappho-data-publisher/atlassian_app'
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  require 'liquid'
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  require 'sappho-data-publisher/atlassian_app'
@@ -23,20 +23,23 @@ module Sappho
23
23
  def gatherData pageData, parameters
24
24
  checkLoggedIn
25
25
  # process a single issue fetch request
26
- if id = parameters['id']
27
- @logger.info "fetching Jira issue #{id}"
28
- getJiraIssueDetails @appServer.getIssue(@token, id), pageData
26
+ if key = parameters['key']
27
+ @logger.info "fetching Jira issue #{key}"
28
+ issue = @appServer.getIssue(@token, key)
29
+ pageData['pagename'] = issue['summary'] unless pageData['pagename']
30
+ processIssues pageData, [issue]
29
31
  end
30
32
  # process a multi-issue, via filter, fetch request
31
33
  if filterId = parameters['filterId']
32
34
  @logger.info "fetching all Jira issues included in filter #{filterId}"
33
35
  issues = @appServer.getIssuesFromFilter @token, filterId
34
- pageData['issues'] = cookedIssues = []
35
- issues.each { |issue|
36
- cookedIssue = { 'key' => issue['key'] }
37
- getJiraIssueDetails issue, cookedIssue
38
- cookedIssues << cookedIssue
39
- }
36
+ processIssues pageData, issues
37
+ end
38
+ # process a multi-issue, via JQL, fetch request
39
+ if jql = parameters['jql']
40
+ maxResults = parameters['max']
41
+ issues = jqlQuery jql, maxResults
42
+ processIssues pageData, issues
40
43
  end
41
44
  # process a group membership fetch request
42
45
  if groupName = parameters['groupName']
@@ -48,26 +51,10 @@ module Sappho
48
51
  'username' => user['name'],
49
52
  'fullName' => user['fullname'],
50
53
  'email' => user['email']
51
- }}
54
+ } }
52
55
  end
53
56
  end
54
57
 
55
- def getJiraIssueDetails issue, pageData
56
- ['summary', 'description', 'assignee', 'components', 'created', 'duedate', 'priority',
57
- 'project', 'reporter', 'resolution', 'status', 'type', 'updated'].each { |key|
58
- pageData[key] = issue[key]
59
- }
60
- pageData['pagename'] = issue['summary'] unless pageData['pagename']
61
- pageData['cf'] = customFields = {}
62
- @allCustomFields.each { |customField|
63
- customFields[cfname customField['id']] = { 'name' => customField['name'] }
64
- }
65
- issue['customFieldValues'].each { |customFieldValue|
66
- customFields[cfname customFieldValue['customfieldId']]['values'] =
67
- customFieldValue['values']
68
- }
69
- end
70
-
71
58
  def getUserFullName username
72
59
  checkLoggedIn
73
60
  user = @users[username]
@@ -80,6 +67,44 @@ module Sappho
80
67
 
81
68
  private
82
69
 
70
+ def processIssues pageData, issues
71
+ pageData['issues'] = cookedIssues = []
72
+ cookIssues issues, cookedIssues
73
+ end
74
+
75
+ def jqlQuery jql, maxresults
76
+ @logger.info "fetching up to #{maxresults} Jira issues for #{jql}"
77
+ return @appServer.getIssuesFromJqlSearch @token, jql, maxresults
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
98
+ end
99
+
100
+ def cookIssues issues, cookedIssues
101
+ issues.each { |issue|
102
+ cookedIssue = {}
103
+ getJiraIssueDetails issue, cookedIssue
104
+ cookedIssues << cookedIssue
105
+ }
106
+ end
107
+
83
108
  def cfname name
84
109
  name.sub /customfield_/, ''
85
110
  end
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  require 'liquid'
@@ -1,16 +1,16 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  module Sappho
7
7
  module Data
8
8
  module Publisher
9
9
  NAME = 'sappho-data-publisher'
10
- VERSION = '0.2.2'
10
+ VERSION = '0.2.3'
11
11
  AUTHORS = ['Andrew Heald']
12
12
  EMAILS = ['andrew@heald.co.uk']
13
- HOMEPAGE = 'https://github.com/sappho/sappho-data-publisher/wiki'
13
+ HOMEPAGE = 'https://wiki.sappho.org.uk/display/DP/sappho-data-publisher'
14
14
  SUMMARY = 'Publishes aggregated data to formatted pages on a wiki'
15
15
  DESCRIPTION = 'See the project home page for more information'
16
16
  end
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  require 'sappho-basics/module_register'
@@ -2,43 +2,51 @@
2
2
  # See http://yaml.org/spec for syntax help
3
3
 
4
4
  TEST-42-A:
5
- summary: Testing 123
6
5
  pagename: Testing 123
7
- description: This is a test.
8
- assignee:
9
- components:
10
- created:
11
- duedate:
12
- priority:
13
- project:
14
- reporter:
15
- resolution:
16
- status:
17
- type:
18
- updated:
19
- cf:
20
- !str 10500: { name: Service }
21
- !str 10501: { name: Type, values: [ Business Process ] }
22
- !str 10502: { name: Invoice Number }
23
- !str 10503: { name: Customer, values: [ Bank of England ] }
6
+ issues:
7
+ - id: 1234
8
+ key: TEST-42
9
+ summary: Testing 123
10
+ description: This is a test.
11
+ assignee:
12
+ components: []
13
+ created:
14
+ duedate:
15
+ priority:
16
+ project:
17
+ reporter:
18
+ resolution:
19
+ status:
20
+ type:
21
+ updated:
22
+ cf:
23
+ !str 10500: { name: Service }
24
+ !str 10501: { name: Type, values: [ Business Process ] }
25
+ !str 10502: { name: Invoice Number }
26
+ !str 10503: { name: Customer, values: [ Bank of England ] }
27
+ subtasks: []
24
28
 
25
29
  TEST-42-B:
26
- summary: Testing 123
27
30
  pagename: Test Page
28
- description: This is a test.
29
- assignee:
30
- components:
31
- created:
32
- duedate:
33
- priority:
34
- project:
35
- reporter:
36
- resolution:
37
- status:
38
- type:
39
- updated:
40
- cf:
41
- !str 10500: { name: Service }
42
- !str 10501: { name: Type, values: [ Business Process ] }
43
- !str 10502: { name: Invoice Number }
44
- !str 10503: { name: Customer, values: [ Bank of England ] }
31
+ issues:
32
+ - id: 1234
33
+ key: TEST-42
34
+ summary: Testing 123
35
+ description: This is a test.
36
+ assignee:
37
+ components: []
38
+ created:
39
+ duedate:
40
+ priority:
41
+ project:
42
+ reporter:
43
+ resolution:
44
+ status:
45
+ type:
46
+ updated:
47
+ cf:
48
+ !str 10500: { name: Service }
49
+ !str 10501: { name: Type, values: [ Business Process ] }
50
+ !str 10502: { name: Invoice Number }
51
+ !str 10503: { name: Customer, values: [ Bank of England ] }
52
+ subtasks: []
data/test/data/jira.yml CHANGED
@@ -9,10 +9,12 @@ users:
9
9
  issues:
10
10
 
11
11
  TEST-42:
12
+ id: 1234
13
+ key: TEST-42
12
14
  summary: Testing 123
13
15
  description: This is a test.
14
16
  assignee:
15
- components:
17
+ components: []
16
18
  created:
17
19
  duedate:
18
20
  priority:
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  require 'helper'
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  require 'helper'
data/test/ruby/helper.rb CHANGED
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  require 'rubygems'
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  require 'helper'
@@ -55,24 +55,24 @@ class JiraTest < Test::Unit::TestCase
55
55
 
56
56
  def test_data_gathering_pagename_as_summary
57
57
  # pagename will be a copy of the issue summary
58
- assert_data_gathered({}, { 'id' => 'TEST-42' }, 'TEST-42-A')
58
+ assert_data_gathered({}, {'key' => 'TEST-42'}, 'TEST-42-A')
59
59
  end
60
60
 
61
61
  def test_data_gathering_pagename_as_supplied
62
62
  # pagename supplied already so should not be set by data gatherer
63
- assert_data_gathered({ 'pagename' => 'Test Page' }, { 'id' => 'TEST-42' }, 'TEST-42-B')
63
+ assert_data_gathered({'pagename' => 'Test Page'}, {'key' => 'TEST-42'}, 'TEST-42-B')
64
64
  end
65
65
 
66
66
  def test_data_gathering_from_invalid_issue
67
67
  assert_raise RuntimeError do
68
- assert_data_gathered({}, { 'id' => 'TEST-999' }, nil)
68
+ assert_data_gathered({}, {'key' => 'TEST-999'}, nil)
69
69
  end
70
70
  end
71
71
 
72
72
  def test_data_gathering_without_connecting
73
73
  assert_raise RuntimeError do
74
74
  # this would be okay if connected, but we're not
75
- assert_data_gathered({}, { 'id' => 'TEST-42' }, 'TEST-42-A', true)
75
+ assert_data_gathered({}, {'key' => 'TEST-42'}, 'TEST-42-A', true)
76
76
  end
77
77
  # keep the teardown happy by connecting anyway
78
78
  connect
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  class MockAtlassianApp
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  require 'mock_atlassian_app'
@@ -1,6 +1,6 @@
1
- # See https://github.com/sappho/sappho-data-publisher/wiki for project documentation.
2
- # This software is licensed under the GNU Affero General Public License, version 3.
3
- # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
1
+ # See https://wiki.sappho.org.uk/display/DP/sappho-data-publisher for project documentation.
2
+ # This software is licensed under the GNU General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/gpl.html for full details of the license terms.
4
4
  # Copyright 2012 Andrew Heald.
5
5
 
6
6
  require 'mock_atlassian_app'
@@ -23,10 +23,10 @@ class MockJira < MockAtlassianApp
23
23
  @allCustomFields
24
24
  end
25
25
 
26
- def getIssue token, id
26
+ def getIssue token, key
27
27
  assert_token_valid token
28
- raise 'issue does not exist' unless @issues.has_key? id
29
- @issues[id]
28
+ raise 'issue does not exist' unless @issues.has_key? key
29
+ @issues[key]
30
30
  end
31
31
 
32
32
  def getUser token, username
@@ -36,4 +36,9 @@ class MockJira < MockAtlassianApp
36
36
  @users[username]
37
37
  end
38
38
 
39
+ def getIssuesFromJqlSearch token, jql, maxResults
40
+ assert_token_valid token
41
+ return []
42
+ end
43
+
39
44
  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: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Heald
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-10 00:00:00 Z
18
+ date: 2012-10-11 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rake
@@ -104,7 +104,7 @@ files:
104
104
  - test/ruby/mock_atlassian_app.rb
105
105
  - test/ruby/mock_confluence.rb
106
106
  - test/ruby/mock_jira.rb
107
- homepage: https://github.com/sappho/sappho-data-publisher/wiki
107
+ homepage: https://wiki.sappho.org.uk/display/DP/sappho-data-publisher
108
108
  licenses: []
109
109
 
110
110
  post_install_message: