sappho-data-publisher 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/sappho-data-publisher +7 -7
- data/lib/sappho-data-publisher/configuration.rb +27 -27
- data/lib/sappho-data-publisher/confluence.rb +78 -78
- data/lib/sappho-data-publisher/custom_liquid.rb +68 -68
- data/lib/sappho-data-publisher/jira.rb +66 -66
- data/lib/sappho-data-publisher/modules.rb +45 -45
- data/lib/sappho-data-publisher/publisher.rb +51 -51
- data/lib/sappho-data-publisher/version.rb +18 -13
- data/lib/sappho-data-publisher.rb +42 -42
- metadata +6 -6
data/bin/sappho-data-publisher
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
4
|
-
|
5
|
-
require 'sappho-data-publisher'
|
6
|
-
|
7
|
-
Sappho::Data::Publisher::CommandLine.process
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
4
|
+
|
5
|
+
require 'sappho-data-publisher'
|
6
|
+
|
7
|
+
Sappho::Data::Publisher::CommandLine.process
|
@@ -1,27 +1,27 @@
|
|
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.
|
4
|
-
# Copyright 2012 Andrew Heald.
|
5
|
-
|
6
|
-
require 'sappho-data-publisher/modules'
|
7
|
-
require 'yaml'
|
8
|
-
|
9
|
-
module Sappho
|
10
|
-
module Data
|
11
|
-
module Publisher
|
12
|
-
|
13
|
-
class Configuration
|
14
|
-
|
15
|
-
attr_reader :data
|
16
|
-
|
17
|
-
def initialize
|
18
|
-
filename = File.expand_path(ARGV[0] || 'config.yml')
|
19
|
-
@data = YAML.load_file filename
|
20
|
-
Modules.instance.get(:logger).warn "configuration loaded from #{filename}"
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
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.
|
4
|
+
# Copyright 2012 Andrew Heald.
|
5
|
+
|
6
|
+
require 'sappho-data-publisher/modules'
|
7
|
+
require 'yaml'
|
8
|
+
|
9
|
+
module Sappho
|
10
|
+
module Data
|
11
|
+
module Publisher
|
12
|
+
|
13
|
+
class Configuration
|
14
|
+
|
15
|
+
attr_reader :data
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
filename = File.expand_path(ARGV[0] || 'config.yml')
|
19
|
+
@data = YAML.load_file filename
|
20
|
+
Modules.instance.get(:logger).warn "configuration loaded from #{filename}"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,78 +1,78 @@
|
|
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.
|
4
|
-
# Copyright 2012 Andrew Heald.
|
5
|
-
|
6
|
-
require 'sappho-data-publisher/modules'
|
7
|
-
require 'xmlrpc/client'
|
8
|
-
|
9
|
-
module Sappho
|
10
|
-
module Data
|
11
|
-
module Publisher
|
12
|
-
|
13
|
-
class Confluence
|
14
|
-
|
15
|
-
def initialize
|
16
|
-
@config = Modules.instance.get :configuration
|
17
|
-
@logger = Modules.instance.get :logger
|
18
|
-
url = @config.data['confluence.url']
|
19
|
-
@wiki = XMLRPC::Client.new2("#{url}/rpc/xmlrpc").proxy('confluence1')
|
20
|
-
@token = @wiki.login @config.data['confluence.username'], @config.data['confluence.password']
|
21
|
-
@logger.info "Confluence #{url} is online"
|
22
|
-
end
|
23
|
-
|
24
|
-
def getGlobalConfiguration
|
25
|
-
pageName = @config.data['confluence.global.config.page.name']
|
26
|
-
return getPage @config.data['confluence.config.space.key'], pageName if pageName
|
27
|
-
''
|
28
|
-
end
|
29
|
-
|
30
|
-
def getConfiguration
|
31
|
-
getPage @config.data['confluence.config.space.key'], @config.data['confluence.config.page.name']
|
32
|
-
end
|
33
|
-
|
34
|
-
def getTemplate pageData, parameters
|
35
|
-
getPage parameters['templatespace'], parameters['templatepage']
|
36
|
-
end
|
37
|
-
|
38
|
-
def getScript rawPage
|
39
|
-
rawPage.scan(/\{noformat.*?\}(.*?)\{noformat\}/m).each { |pageData| yield pageData[0] }
|
40
|
-
end
|
41
|
-
|
42
|
-
def publish content, pageData, parameters
|
43
|
-
setPage parameters['space'], parameters['parent'], pageData['pagename'], content
|
44
|
-
end
|
45
|
-
|
46
|
-
def shutdown
|
47
|
-
@wiki.logout @token
|
48
|
-
@logger.info 'disconnected from Confluence'
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def getPage spaceKey, pageName
|
54
|
-
@logger.info "reading wiki page #{spaceKey}:#{pageName}"
|
55
|
-
@wiki.getPage(@token, spaceKey, pageName)['content']
|
56
|
-
end
|
57
|
-
|
58
|
-
def setPage spaceKey, parentPageName, pageName, content
|
59
|
-
begin
|
60
|
-
page = @wiki.getPage(@token, spaceKey, pageName)
|
61
|
-
page['content'] = content
|
62
|
-
@logger.info "rewriting existing wiki page #{spaceKey}:#{pageName}"
|
63
|
-
rescue
|
64
|
-
page = {
|
65
|
-
'space' => spaceKey,
|
66
|
-
'parentId' => @wiki.getPage(@token, spaceKey, parentPageName)['id'],
|
67
|
-
'title' => pageName,
|
68
|
-
'content' => content }
|
69
|
-
@logger.info "creating new wiki page #{spaceKey}:#{pageName} as child of #{parentPageName}"
|
70
|
-
end
|
71
|
-
@wiki.storePage @token, page
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
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.
|
4
|
+
# Copyright 2012 Andrew Heald.
|
5
|
+
|
6
|
+
require 'sappho-data-publisher/modules'
|
7
|
+
require 'xmlrpc/client'
|
8
|
+
|
9
|
+
module Sappho
|
10
|
+
module Data
|
11
|
+
module Publisher
|
12
|
+
|
13
|
+
class Confluence
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@config = Modules.instance.get :configuration
|
17
|
+
@logger = Modules.instance.get :logger
|
18
|
+
url = @config.data['confluence.url']
|
19
|
+
@wiki = XMLRPC::Client.new2("#{url}/rpc/xmlrpc").proxy('confluence1')
|
20
|
+
@token = @wiki.login @config.data['confluence.username'], @config.data['confluence.password']
|
21
|
+
@logger.info "Confluence #{url} is online"
|
22
|
+
end
|
23
|
+
|
24
|
+
def getGlobalConfiguration
|
25
|
+
pageName = @config.data['confluence.global.config.page.name']
|
26
|
+
return getPage @config.data['confluence.config.space.key'], pageName if pageName
|
27
|
+
''
|
28
|
+
end
|
29
|
+
|
30
|
+
def getConfiguration
|
31
|
+
getPage @config.data['confluence.config.space.key'], @config.data['confluence.config.page.name']
|
32
|
+
end
|
33
|
+
|
34
|
+
def getTemplate pageData, parameters
|
35
|
+
getPage parameters['templatespace'], parameters['templatepage']
|
36
|
+
end
|
37
|
+
|
38
|
+
def getScript rawPage
|
39
|
+
rawPage.scan(/\{noformat.*?\}(.*?)\{noformat\}/m).each { |pageData| yield pageData[0] }
|
40
|
+
end
|
41
|
+
|
42
|
+
def publish content, pageData, parameters
|
43
|
+
setPage parameters['space'], parameters['parent'], pageData['pagename'], content
|
44
|
+
end
|
45
|
+
|
46
|
+
def shutdown
|
47
|
+
@wiki.logout @token
|
48
|
+
@logger.info 'disconnected from Confluence'
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def getPage spaceKey, pageName
|
54
|
+
@logger.info "reading wiki page #{spaceKey}:#{pageName}"
|
55
|
+
@wiki.getPage(@token, spaceKey, pageName)['content']
|
56
|
+
end
|
57
|
+
|
58
|
+
def setPage spaceKey, parentPageName, pageName, content
|
59
|
+
begin
|
60
|
+
page = @wiki.getPage(@token, spaceKey, pageName)
|
61
|
+
page['content'] = content
|
62
|
+
@logger.info "rewriting existing wiki page #{spaceKey}:#{pageName}"
|
63
|
+
rescue
|
64
|
+
page = {
|
65
|
+
'space' => spaceKey,
|
66
|
+
'parentId' => @wiki.getPage(@token, spaceKey, parentPageName)['id'],
|
67
|
+
'title' => pageName,
|
68
|
+
'content' => content }
|
69
|
+
@logger.info "creating new wiki page #{spaceKey}:#{pageName} as child of #{parentPageName}"
|
70
|
+
end
|
71
|
+
@wiki.storePage @token, page
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -1,68 +1,68 @@
|
|
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.
|
4
|
-
# Copyright 2012 Andrew Heald.
|
5
|
-
|
6
|
-
require 'rubygems'
|
7
|
-
gem 'liquid'
|
8
|
-
require 'liquid'
|
9
|
-
require 'sappho-data-publisher/modules'
|
10
|
-
|
11
|
-
module Sappho
|
12
|
-
module Data
|
13
|
-
module Publisher
|
14
|
-
|
15
|
-
class CustomLiquid
|
16
|
-
|
17
|
-
def CustomLiquid.setup
|
18
|
-
Liquid::Template.register_filter(Fullname)
|
19
|
-
Liquid::Template.register_tag('squash', Squash)
|
20
|
-
Liquid::Template.register_tag('empty', Empty)
|
21
|
-
end
|
22
|
-
|
23
|
-
module Fullname
|
24
|
-
|
25
|
-
def fullname username
|
26
|
-
begin
|
27
|
-
Modules.instance.get('AddressBook').getUserFullName(username)
|
28
|
-
rescue
|
29
|
-
'** John Doe **'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
class Squash < Liquid::Block
|
36
|
-
|
37
|
-
def initialize tag_name, markup, tokens
|
38
|
-
super
|
39
|
-
@message = (markup ? markup.to_s : '')
|
40
|
-
@message = @message.length > 0 ? @message : 'This information has not been supplied.'
|
41
|
-
end
|
42
|
-
|
43
|
-
def render context
|
44
|
-
wiki = []
|
45
|
-
super.each { |line| wiki << line unless line.strip == ''}
|
46
|
-
wiki.size > 0 ? wiki.join : @message
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
class Empty < Liquid::Block
|
52
|
-
|
53
|
-
def initialize tag_name, markup, tokens
|
54
|
-
super
|
55
|
-
end
|
56
|
-
|
57
|
-
def render context
|
58
|
-
super
|
59
|
-
''
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
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.
|
4
|
+
# Copyright 2012 Andrew Heald.
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
gem 'liquid'
|
8
|
+
require 'liquid'
|
9
|
+
require 'sappho-data-publisher/modules'
|
10
|
+
|
11
|
+
module Sappho
|
12
|
+
module Data
|
13
|
+
module Publisher
|
14
|
+
|
15
|
+
class CustomLiquid
|
16
|
+
|
17
|
+
def CustomLiquid.setup
|
18
|
+
Liquid::Template.register_filter(Fullname)
|
19
|
+
Liquid::Template.register_tag('squash', Squash)
|
20
|
+
Liquid::Template.register_tag('empty', Empty)
|
21
|
+
end
|
22
|
+
|
23
|
+
module Fullname
|
24
|
+
|
25
|
+
def fullname username
|
26
|
+
begin
|
27
|
+
Modules.instance.get('AddressBook').getUserFullName(username)
|
28
|
+
rescue
|
29
|
+
'** John Doe **'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
class Squash < Liquid::Block
|
36
|
+
|
37
|
+
def initialize tag_name, markup, tokens
|
38
|
+
super
|
39
|
+
@message = (markup ? markup.to_s : '')
|
40
|
+
@message = @message.length > 0 ? @message : 'This information has not been supplied.'
|
41
|
+
end
|
42
|
+
|
43
|
+
def render context
|
44
|
+
wiki = []
|
45
|
+
super.each { |line| wiki << line unless line.strip == ''}
|
46
|
+
wiki.size > 0 ? wiki.join : @message
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
class Empty < Liquid::Block
|
52
|
+
|
53
|
+
def initialize tag_name, markup, tokens
|
54
|
+
super
|
55
|
+
end
|
56
|
+
|
57
|
+
def render context
|
58
|
+
super
|
59
|
+
''
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -1,66 +1,66 @@
|
|
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.
|
4
|
-
# Copyright 2012 Andrew Heald.
|
5
|
-
|
6
|
-
require 'sappho-data-publisher/modules'
|
7
|
-
require 'soap/wsdlDriver'
|
8
|
-
|
9
|
-
module Sappho
|
10
|
-
module Data
|
11
|
-
module Publisher
|
12
|
-
|
13
|
-
class Jira
|
14
|
-
|
15
|
-
def initialize
|
16
|
-
config = Modules.instance.get :configuration
|
17
|
-
@logger = Modules.instance.get :logger
|
18
|
-
url = config.data['jira.url']
|
19
|
-
@jira = SOAP::WSDLDriverFactory.new("#{url}/rpc/soap/jirasoapservice-v2?wsdl").create_rpc_driver
|
20
|
-
@token = @jira.login config.data['jira.username'], config.data['jira.password']
|
21
|
-
@allCustomFields = @jira.getCustomFields @token
|
22
|
-
@logger.info "Jira #{url} is online"
|
23
|
-
@users = {}
|
24
|
-
end
|
25
|
-
|
26
|
-
def gatherData pageData, parameters
|
27
|
-
id = parameters['id']
|
28
|
-
@logger.info "reading Jira issue #{id}"
|
29
|
-
issue = @jira.getIssue @token, id
|
30
|
-
pageData['summary'] = summary = issue['summary']
|
31
|
-
pageData['pagename'] = summary unless pageData['pagename']
|
32
|
-
pageData['description'] = issue['description']
|
33
|
-
pageData['customFields'] = customFields = {}
|
34
|
-
@allCustomFields.each { |customField|
|
35
|
-
customFields[customField['id']] = {
|
36
|
-
'name' => customField['name'],
|
37
|
-
'values' => nil
|
38
|
-
}
|
39
|
-
}
|
40
|
-
issue['customFieldValues'].each { |customFieldValue|
|
41
|
-
customFields[customFieldValue['customfieldId']]['values'] = customFieldValue['values']
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
def getUserFullName username
|
46
|
-
user = @users[username]
|
47
|
-
unless user
|
48
|
-
@logger.info "reading Jira user details for #{username}"
|
49
|
-
@users[username] = user = @jira.getUser(@token, username)
|
50
|
-
end
|
51
|
-
user['fullname']
|
52
|
-
end
|
53
|
-
|
54
|
-
def shutdown
|
55
|
-
if @jira
|
56
|
-
@jira.logout @token
|
57
|
-
@jira = nil
|
58
|
-
@logger.info 'disconnected from Jira'
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
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.
|
4
|
+
# Copyright 2012 Andrew Heald.
|
5
|
+
|
6
|
+
require 'sappho-data-publisher/modules'
|
7
|
+
require 'soap/wsdlDriver'
|
8
|
+
|
9
|
+
module Sappho
|
10
|
+
module Data
|
11
|
+
module Publisher
|
12
|
+
|
13
|
+
class Jira
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
config = Modules.instance.get :configuration
|
17
|
+
@logger = Modules.instance.get :logger
|
18
|
+
url = config.data['jira.url']
|
19
|
+
@jira = SOAP::WSDLDriverFactory.new("#{url}/rpc/soap/jirasoapservice-v2?wsdl").create_rpc_driver
|
20
|
+
@token = @jira.login config.data['jira.username'], config.data['jira.password']
|
21
|
+
@allCustomFields = @jira.getCustomFields @token
|
22
|
+
@logger.info "Jira #{url} is online"
|
23
|
+
@users = {}
|
24
|
+
end
|
25
|
+
|
26
|
+
def gatherData pageData, parameters
|
27
|
+
id = parameters['id']
|
28
|
+
@logger.info "reading Jira issue #{id}"
|
29
|
+
issue = @jira.getIssue @token, id
|
30
|
+
pageData['summary'] = summary = issue['summary']
|
31
|
+
pageData['pagename'] = summary unless pageData['pagename']
|
32
|
+
pageData['description'] = issue['description']
|
33
|
+
pageData['customFields'] = customFields = {}
|
34
|
+
@allCustomFields.each { |customField|
|
35
|
+
customFields[customField['id']] = {
|
36
|
+
'name' => customField['name'],
|
37
|
+
'values' => nil
|
38
|
+
}
|
39
|
+
}
|
40
|
+
issue['customFieldValues'].each { |customFieldValue|
|
41
|
+
customFields[customFieldValue['customfieldId']]['values'] = customFieldValue['values']
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def getUserFullName username
|
46
|
+
user = @users[username]
|
47
|
+
unless user
|
48
|
+
@logger.info "reading Jira user details for #{username}"
|
49
|
+
@users[username] = user = @jira.getUser(@token, username)
|
50
|
+
end
|
51
|
+
user['fullname']
|
52
|
+
end
|
53
|
+
|
54
|
+
def shutdown
|
55
|
+
if @jira
|
56
|
+
@jira.logout @token
|
57
|
+
@jira = nil
|
58
|
+
@logger.info 'disconnected from Jira'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -1,45 +1,45 @@
|
|
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.
|
4
|
-
# Copyright 2012 Andrew Heald.
|
5
|
-
|
6
|
-
require 'singleton'
|
7
|
-
|
8
|
-
module Sappho
|
9
|
-
module Data
|
10
|
-
module Publisher
|
11
|
-
|
12
|
-
class Modules
|
13
|
-
|
14
|
-
include Singleton
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
@modules = {}
|
18
|
-
end
|
19
|
-
|
20
|
-
def set name, mod
|
21
|
-
@modules[name] = mod
|
22
|
-
end
|
23
|
-
|
24
|
-
def get name
|
25
|
-
@modules[name]
|
26
|
-
end
|
27
|
-
|
28
|
-
def shutdown
|
29
|
-
each { |mod| mod.shutdown }
|
30
|
-
end
|
31
|
-
|
32
|
-
def each
|
33
|
-
@modules.each do |name, mod|
|
34
|
-
begin
|
35
|
-
yield mod
|
36
|
-
rescue
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
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.
|
4
|
+
# Copyright 2012 Andrew Heald.
|
5
|
+
|
6
|
+
require 'singleton'
|
7
|
+
|
8
|
+
module Sappho
|
9
|
+
module Data
|
10
|
+
module Publisher
|
11
|
+
|
12
|
+
class Modules
|
13
|
+
|
14
|
+
include Singleton
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@modules = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def set name, mod
|
21
|
+
@modules[name] = mod
|
22
|
+
end
|
23
|
+
|
24
|
+
def get name
|
25
|
+
@modules[name]
|
26
|
+
end
|
27
|
+
|
28
|
+
def shutdown
|
29
|
+
each { |mod| mod.shutdown }
|
30
|
+
end
|
31
|
+
|
32
|
+
def each
|
33
|
+
@modules.each do |name, mod|
|
34
|
+
begin
|
35
|
+
yield mod
|
36
|
+
rescue
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -1,51 +1,51 @@
|
|
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.
|
4
|
-
# Copyright 2012 Andrew Heald.
|
5
|
-
|
6
|
-
require 'rubygems'
|
7
|
-
gem 'liquid'
|
8
|
-
require 'liquid'
|
9
|
-
require 'yaml'
|
10
|
-
require 'sappho-data-publisher/modules'
|
11
|
-
|
12
|
-
module Sappho
|
13
|
-
module Data
|
14
|
-
module Publisher
|
15
|
-
|
16
|
-
class Publisher
|
17
|
-
|
18
|
-
def publish
|
19
|
-
modules = Modules.instance
|
20
|
-
logger = modules.get :logger
|
21
|
-
configurator = modules.get modules.get(:configuration).data['config.module']
|
22
|
-
globalScript = ''
|
23
|
-
configurator.getScript(configurator.getGlobalConfiguration) { |configChunk| globalScript += configChunk }
|
24
|
-
configurator.getScript configurator.getConfiguration do |configChunk|
|
25
|
-
allData = YAML.load(globalScript + configChunk)
|
26
|
-
pageData = allData['page']
|
27
|
-
if pageData
|
28
|
-
logger.info "---- publishing #{pageData['id']} ----"
|
29
|
-
pageData['sources'].each do |source|
|
30
|
-
id = source['source']
|
31
|
-
logger.info "collecting #{id} source data"
|
32
|
-
modules.get(id).gatherData pageData, source['parameters']
|
33
|
-
end
|
34
|
-
pageData['publications'].each do |publication|
|
35
|
-
id = publication['destination']
|
36
|
-
logger.info "publishing data to #{id}"
|
37
|
-
dest = modules.get(id)
|
38
|
-
params = publication['parameters']
|
39
|
-
template = ''
|
40
|
-
dest.getScript(dest.getTemplate pageData, params) { |templateChunk| template += templateChunk }
|
41
|
-
dest.publish Liquid::Template.parse(template).render('data' => pageData), pageData, params
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
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.
|
4
|
+
# Copyright 2012 Andrew Heald.
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
gem 'liquid'
|
8
|
+
require 'liquid'
|
9
|
+
require 'yaml'
|
10
|
+
require 'sappho-data-publisher/modules'
|
11
|
+
|
12
|
+
module Sappho
|
13
|
+
module Data
|
14
|
+
module Publisher
|
15
|
+
|
16
|
+
class Publisher
|
17
|
+
|
18
|
+
def publish
|
19
|
+
modules = Modules.instance
|
20
|
+
logger = modules.get :logger
|
21
|
+
configurator = modules.get modules.get(:configuration).data['config.module']
|
22
|
+
globalScript = ''
|
23
|
+
configurator.getScript(configurator.getGlobalConfiguration) { |configChunk| globalScript += configChunk }
|
24
|
+
configurator.getScript configurator.getConfiguration do |configChunk|
|
25
|
+
allData = YAML.load(globalScript + configChunk)
|
26
|
+
pageData = allData['page']
|
27
|
+
if pageData
|
28
|
+
logger.info "---- publishing #{pageData['id']} ----"
|
29
|
+
pageData['sources'].each do |source|
|
30
|
+
id = source['source']
|
31
|
+
logger.info "collecting #{id} source data"
|
32
|
+
modules.get(id).gatherData pageData, source['parameters']
|
33
|
+
end
|
34
|
+
pageData['publications'].each do |publication|
|
35
|
+
id = publication['destination']
|
36
|
+
logger.info "publishing data to #{id}"
|
37
|
+
dest = modules.get(id)
|
38
|
+
params = publication['parameters']
|
39
|
+
template = ''
|
40
|
+
dest.getScript(dest.getTemplate pageData, params) { |templateChunk| template += templateChunk }
|
41
|
+
dest.publish Liquid::Template.parse(template).render('data' => pageData), pageData, params
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,13 +1,18 @@
|
|
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.
|
4
|
-
# Copyright 2012 Andrew Heald.
|
5
|
-
|
6
|
-
module Sappho
|
7
|
-
module Data
|
8
|
-
module Publisher
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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.
|
4
|
+
# Copyright 2012 Andrew Heald.
|
5
|
+
|
6
|
+
module Sappho
|
7
|
+
module Data
|
8
|
+
module Publisher
|
9
|
+
NAME = 'sappho-data-publisher'
|
10
|
+
VERSION = '0.1.7'
|
11
|
+
AUTHORS = ['Andrew Heald']
|
12
|
+
EMAILS = ['andrew@heald.co.uk']
|
13
|
+
HOMEPAGE = 'https://github.com/sappho/sappho-data-publisher/wiki'
|
14
|
+
SUMMARY = 'Publishes aggregated data to formatted pages on a wiki'
|
15
|
+
DESCRIPTION = 'See the project home page for more information'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,42 +1,42 @@
|
|
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.
|
4
|
-
# Copyright 2012 Andrew Heald.
|
5
|
-
|
6
|
-
require 'logger'
|
7
|
-
require 'sappho-data-publisher/modules'
|
8
|
-
require 'sappho-data-publisher/publisher'
|
9
|
-
require 'sappho-data-publisher/configuration'
|
10
|
-
require 'sappho-data-publisher/confluence'
|
11
|
-
require 'sappho-data-publisher/jira'
|
12
|
-
require 'sappho-data-publisher/custom_liquid'
|
13
|
-
require 'sappho-data-publisher/version'
|
14
|
-
|
15
|
-
module Sappho
|
16
|
-
module Data
|
17
|
-
module Publisher
|
18
|
-
|
19
|
-
class CommandLine
|
20
|
-
|
21
|
-
def CommandLine.process
|
22
|
-
$stdout.sync = true
|
23
|
-
logger = Logger.new $stdout
|
24
|
-
logger.level = Logger::INFO
|
25
|
-
logger.formatter = proc { |severity, datetime, progname, msg| "#{msg}\n" }
|
26
|
-
logger.info "sappho-data-publisher version #{VERSION} - #{HOMEPAGE}"
|
27
|
-
modules = Modules.instance
|
28
|
-
modules.set :logger, logger
|
29
|
-
modules.set :configuration, Configuration.new
|
30
|
-
modules.set 'Jira', (jira = Jira.new)
|
31
|
-
modules.set 'AddressBook', jira
|
32
|
-
modules.set 'Confluence', Confluence.new
|
33
|
-
CustomLiquid.setup
|
34
|
-
Publisher.new.publish
|
35
|
-
modules.shutdown
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
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.
|
4
|
+
# Copyright 2012 Andrew Heald.
|
5
|
+
|
6
|
+
require 'logger'
|
7
|
+
require 'sappho-data-publisher/modules'
|
8
|
+
require 'sappho-data-publisher/publisher'
|
9
|
+
require 'sappho-data-publisher/configuration'
|
10
|
+
require 'sappho-data-publisher/confluence'
|
11
|
+
require 'sappho-data-publisher/jira'
|
12
|
+
require 'sappho-data-publisher/custom_liquid'
|
13
|
+
require 'sappho-data-publisher/version'
|
14
|
+
|
15
|
+
module Sappho
|
16
|
+
module Data
|
17
|
+
module Publisher
|
18
|
+
|
19
|
+
class CommandLine
|
20
|
+
|
21
|
+
def CommandLine.process
|
22
|
+
$stdout.sync = true
|
23
|
+
logger = Logger.new $stdout
|
24
|
+
logger.level = Logger::INFO
|
25
|
+
logger.formatter = proc { |severity, datetime, progname, msg| "#{msg}\n" }
|
26
|
+
logger.info "sappho-data-publisher version #{VERSION} - #{HOMEPAGE}"
|
27
|
+
modules = Modules.instance
|
28
|
+
modules.set :logger, logger
|
29
|
+
modules.set :configuration, Configuration.new
|
30
|
+
modules.set 'Jira', (jira = Jira.new)
|
31
|
+
modules.set 'AddressBook', jira
|
32
|
+
modules.set 'Confluence', Confluence.new
|
33
|
+
CustomLiquid.setup
|
34
|
+
Publisher.new.publish
|
35
|
+
modules.shutdown
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
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: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 7
|
10
|
+
version: 0.1.7
|
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-
|
18
|
+
date: 2012-03-01 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rake
|
@@ -61,7 +61,6 @@ extra_rdoc_files: []
|
|
61
61
|
|
62
62
|
files:
|
63
63
|
- bin/sappho-data-publisher
|
64
|
-
- lib/sappho-data-publisher.rb
|
65
64
|
- lib/sappho-data-publisher/configuration.rb
|
66
65
|
- lib/sappho-data-publisher/confluence.rb
|
67
66
|
- lib/sappho-data-publisher/custom_liquid.rb
|
@@ -69,6 +68,7 @@ files:
|
|
69
68
|
- lib/sappho-data-publisher/modules.rb
|
70
69
|
- lib/sappho-data-publisher/publisher.rb
|
71
70
|
- lib/sappho-data-publisher/version.rb
|
71
|
+
- lib/sappho-data-publisher.rb
|
72
72
|
homepage: https://github.com/sappho/sappho-data-publisher/wiki
|
73
73
|
licenses: []
|
74
74
|
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
requirements: []
|
99
99
|
|
100
100
|
rubyforge_project: sappho-data-publisher
|
101
|
-
rubygems_version: 1.8.
|
101
|
+
rubygems_version: 1.8.11
|
102
102
|
signing_key:
|
103
103
|
specification_version: 3
|
104
104
|
summary: Publishes aggregated data to formatted pages on a wiki
|