publican_creators 1.2.3 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +237 -228
- data/CONTRIBUTING.md +21 -24
- data/LICENSE.md +635 -635
- data/MAINTENANCE.md +18 -18
- data/README.md +94 -94
- data/bin/publican_creators.rb +22 -22
- data/bin/revision_creator.rb +20 -20
- data/etc/publicancreators.cfg +84 -84
- data/lib/publican_creators.rb +210 -209
- data/lib/publican_creators/change.rb +287 -287
- data/lib/publican_creators/checker.rb +58 -58
- data/lib/publican_creators/create.rb +131 -131
- data/lib/publican_creators/export.rb +236 -236
- data/lib/publican_creators/get.rb +76 -75
- data/lib/publican_creators/notifier.rb +33 -32
- data/lib/publican_creators/prepare.rb +91 -91
- data/lib/publican_creators/revision.rb +56 -56
- data/lib/publican_creators/testlib.rb +37 -37
- data/lib/publican_creators/version.rb +35 -35
- metadata +17 -20
- data/data/publican_creators/publican-revision.png +0 -0
- data/data/publican_creators/publican.png +0 -0
data/lib/publican_creators.rb
CHANGED
@@ -1,209 +1,210 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Copyright (C) 2013-
|
3
|
-
#
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
7
|
-
# (at your option) any later version.
|
8
|
-
#
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
-
# GNU General Public License for more details.
|
13
|
-
#
|
14
|
-
# You should have received a copy of the GNU General Public License
|
15
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
-
|
17
|
-
# Dependencies
|
18
|
-
require_relative 'publican_creators/checker'
|
19
|
-
require_relative 'publican_creators/get'
|
20
|
-
require_relative 'publican_creators/change'
|
21
|
-
require_relative 'publican_creators/export'
|
22
|
-
require_relative 'publican_creators/prepare'
|
23
|
-
require_relative 'publican_creators/notifier'
|
24
|
-
require_relative 'publican_creators/version'
|
25
|
-
require 'fileutils'
|
26
|
-
require 'nokogiri'
|
27
|
-
require 'rainbow/ext/string'
|
28
|
-
require 'xdg'
|
29
|
-
|
30
|
-
# Main Class of PublicanCreators
|
31
|
-
# @return [String] true or false
|
32
|
-
class PublicanCreators
|
33
|
-
puts 'publican_creators'.color(:yellow)
|
34
|
-
puts "Version: #{VERSION}".color(:yellow)
|
35
|
-
puts
|
36
|
-
puts 'Copyright (C) 2015-
|
37
|
-
puts 'Description: This script creates a article or book set with'.color(:yellow)
|
38
|
-
puts 'Publican. Then it modifies it for your needs.'.color(:yellow)
|
39
|
-
puts 'License: GPL-3'.color(:yellow)
|
40
|
-
puts 'Bugs: Please file bugs on https://github.com/saigkill/publican_creators/issues'.color(:yellow)
|
41
|
-
|
42
|
-
puts 'Reading the config file in publicancreators.cfg'.color(:yellow)
|
43
|
-
# @note Run config method who reads in the config file and puts the variables in an array
|
44
|
-
# TODO: Try to fix this in future (conf_ver, use_brand)
|
45
|
-
# rubocop:disable Lint/UselessAssignment
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
puts "
|
81
|
-
puts "
|
82
|
-
puts "
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
#
|
100
|
-
# @param [String]
|
101
|
-
# @param [String]
|
102
|
-
# @param [String]
|
103
|
-
# @param [String]
|
104
|
-
# @param [String]
|
105
|
-
# @param [String]
|
106
|
-
# @param [String]
|
107
|
-
# @param [String]
|
108
|
-
# @param [String]
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
#
|
128
|
-
# @param [String]
|
129
|
-
# @param [String]
|
130
|
-
# @param [String]
|
131
|
-
# @param [String]
|
132
|
-
# @param [String]
|
133
|
-
# @param [String]
|
134
|
-
# @param [String]
|
135
|
-
# @param [String]
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
#
|
142
|
-
#
|
143
|
-
# @param [String]
|
144
|
-
# @param [String]
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
#
|
149
|
-
#
|
150
|
-
# @param [String]
|
151
|
-
# @param [String]
|
152
|
-
# @param [String]
|
153
|
-
# @param [String]
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
#
|
159
|
-
# @param [String]
|
160
|
-
# @param [String]
|
161
|
-
# @param [String]
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
#
|
166
|
-
# @param [String]
|
167
|
-
# @param [String]
|
168
|
-
# @param [String]
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
# @param [String]
|
177
|
-
# @param [String]
|
178
|
-
# @param [String]
|
179
|
-
# @param [String]
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
# the
|
185
|
-
#
|
186
|
-
# @param [String]
|
187
|
-
# @param [String]
|
188
|
-
# @param [String]
|
189
|
-
# @param [String]
|
190
|
-
# @param [String]
|
191
|
-
# @param [String]
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
#
|
198
|
-
# @param [String]
|
199
|
-
# @param [String]
|
200
|
-
# @param [String]
|
201
|
-
# @param [String]
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Copyright (C) 2013-2020 Sascha Manns <Sascha.Manns@outlook.de>
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
# Dependencies
|
18
|
+
require_relative 'publican_creators/checker'
|
19
|
+
require_relative 'publican_creators/get'
|
20
|
+
require_relative 'publican_creators/change'
|
21
|
+
require_relative 'publican_creators/export'
|
22
|
+
require_relative 'publican_creators/prepare'
|
23
|
+
require_relative 'publican_creators/notifier'
|
24
|
+
require_relative 'publican_creators/version'
|
25
|
+
require 'fileutils'
|
26
|
+
require 'nokogiri'
|
27
|
+
require 'rainbow/ext/string'
|
28
|
+
require 'xdg'
|
29
|
+
|
30
|
+
# Main Class of PublicanCreators
|
31
|
+
# @return [String] true or false
|
32
|
+
class PublicanCreators
|
33
|
+
puts 'publican_creators'.color(:yellow)
|
34
|
+
puts "Version: #{VERSION}".color(:yellow)
|
35
|
+
puts
|
36
|
+
puts 'Copyright (C) 2015-2020 Sascha Manns <Sascha.Manns@outlook.de>'.color(:yellow)
|
37
|
+
puts 'Description: This script creates a article or book set with'.color(:yellow)
|
38
|
+
puts 'Publican. Then it modifies it for your needs.'.color(:yellow)
|
39
|
+
puts 'License: GPL-3'.color(:yellow)
|
40
|
+
puts 'Bugs: Please file bugs on https://github.com/saigkill/publican_creators/issues'.color(:yellow)
|
41
|
+
|
42
|
+
puts 'Reading the config file in publicancreators.cfg'.color(:yellow)
|
43
|
+
# @note Run config method who reads in the config file and puts the variables in an array
|
44
|
+
# TODO: Try to fix this in future (conf_ver, use_brand)
|
45
|
+
# rubocop:disable Lint/UselessAssignment
|
46
|
+
xdg = XDG::Environment.new
|
47
|
+
sys_xdg = xdg.config_home
|
48
|
+
config = ParseConfig.new("#{sys_xdg}/publican_creators/publicancreators.cfg")
|
49
|
+
conf_ver = config['conf_ver']
|
50
|
+
name = config['name']
|
51
|
+
email = config['email_private']
|
52
|
+
language = config['language']
|
53
|
+
use_brand = config['use_brand']
|
54
|
+
title_logo = config['title_logo']
|
55
|
+
legal = config['legal']
|
56
|
+
brand = config['brand']
|
57
|
+
company_name = config['company_name']
|
58
|
+
company_division = config['company_division']
|
59
|
+
email_business = config['email_business']
|
60
|
+
brand_dir = config['brand_dir']
|
61
|
+
glob_entities = config['globalentities']
|
62
|
+
articles_dir_business = config['articles_dir']
|
63
|
+
reports_dir_business = config['reports_dir']
|
64
|
+
books_dir_business = config['books_dir']
|
65
|
+
articles_dir_private = config['articles_dir_priv']
|
66
|
+
homework_dir_private = config['homework_dir']
|
67
|
+
books_dir_private = config['books_dir_priv']
|
68
|
+
brand_private = config['brand_private']
|
69
|
+
brand_homework = config['brand_homework']
|
70
|
+
db5 = config['db5']
|
71
|
+
xfc_brand_dir = config['xfc_brand_dir']
|
72
|
+
pdf_view = config['pdfview']
|
73
|
+
|
74
|
+
global_entities = "#{brand_dir}/#{glob_entities}"
|
75
|
+
puts "Your global entities file is there: #{global_entities}"
|
76
|
+
|
77
|
+
# @note Ask for the title and other settings and put them into a array
|
78
|
+
environment, type, opt, title = PublicanCreatorsGet.title
|
79
|
+
|
80
|
+
puts "Environment: #{environment}"
|
81
|
+
puts "Type: #{type}"
|
82
|
+
puts "Optional: #{opt}"
|
83
|
+
puts "Title: #{title}"
|
84
|
+
|
85
|
+
# @note Sets the default values
|
86
|
+
report = 'FALSE'
|
87
|
+
homework = 'FALSE'
|
88
|
+
report = 'TRUE' if opt == 'Report'
|
89
|
+
homework = 'TRUE' if opt == 'Homework'
|
90
|
+
|
91
|
+
# @note Hardcoded variables
|
92
|
+
art_info = "#{title}/#{language}/Article_Info.xml"
|
93
|
+
book_info = "#{title}/#{language}/Book_Info.xml"
|
94
|
+
rev_hist = "#{title}/#{language}/Revision_History.xml"
|
95
|
+
a_group = "#{title}/#{language}/Author_Group.xml"
|
96
|
+
ent = "#{title}/#{language}/#{title}.ent"
|
97
|
+
builds = "#{title}/#{language}/Rakefile"
|
98
|
+
|
99
|
+
# Run one of the both methods to get the variable targetdir
|
100
|
+
# @param [String] environment Comes from PublicanCreatorsGet.title
|
101
|
+
# @param [String] type Comes from PublicanCreatorsGet.title
|
102
|
+
# @param [String] report true or false
|
103
|
+
# @param [String] reports_dir_business comes from publicancreators.cfg
|
104
|
+
# @param [String] articles_dir_business comes from publicancreators.cfg
|
105
|
+
# @param [String] books_dir_business comes from publicancreators.cfg
|
106
|
+
# @param [String] articles_dir_private comes from publicancreators.cfg
|
107
|
+
# @param [String] homework true or false
|
108
|
+
# @param [String] homework_dir_private comes from publicancreators.cfg
|
109
|
+
# @param [String] books_dir_private comes from publicancreators.cfg
|
110
|
+
targetdir = PublicanCreatorsPrepare.targetdir(environment, type, report,
|
111
|
+
reports_dir_business,
|
112
|
+
articles_dir_business,
|
113
|
+
books_dir_business, homework,
|
114
|
+
articles_dir_private,
|
115
|
+
homework_dir_private,
|
116
|
+
books_dir_private)
|
117
|
+
|
118
|
+
# Checks if the needed directory targetdir is available. Otherwise it creates one.
|
119
|
+
puts "Creating directory #{targetdir}"
|
120
|
+
# @param [String] targetdir comes from PublicanCreatorsPrepare.prepare_work or .prepare_private
|
121
|
+
Checker.check_dir(targetdir)
|
122
|
+
|
123
|
+
# @note Change to target directory
|
124
|
+
puts 'Change to this directory'
|
125
|
+
# @param [String] targetdir comes from PublicanCreatorsPrepare.prepare_work or .prepare_private
|
126
|
+
FileUtils.cd(targetdir) do
|
127
|
+
# This method checks the environment and runs the method for
|
128
|
+
# @param [String] environment Comes from PublicanCreatorsGet.title
|
129
|
+
# @param [String] title Comes from PublicanCreatorsGet.title
|
130
|
+
# @param [String] type Comes from PublicanCreatorsGet.title
|
131
|
+
# @param [String] language Comes from publicancreators.cfg
|
132
|
+
# @param [String] brand e.g. Debian or nothing for using publicans default brand (config file)
|
133
|
+
# @param [String] db5 DocBook5 as default? (config file)
|
134
|
+
# @param [String] homework true or false
|
135
|
+
# @param [String] brand_homework e.g. ils (config file)
|
136
|
+
# @param [String] brand_private e.g. manns (config file)
|
137
|
+
PublicanCreatorsChange.check_environment(environment, title, type, language,
|
138
|
+
brand, db5, homework,
|
139
|
+
brand_homework, brand_private)
|
140
|
+
|
141
|
+
# By working for my employer i'm creating publications which refers to a global entity file.
|
142
|
+
# This method adds the entities from that file into the local one. It returns a success or fail.
|
143
|
+
# @param [String] environment Work or Private
|
144
|
+
# @param [String] global_entities path to a global entities file (config file)
|
145
|
+
# @param [String] ent Path to Entityfile
|
146
|
+
PublicanCreatorsChange.add_entity(environment, global_entities, ent)
|
147
|
+
|
148
|
+
# In this method the standard-holder from the local entity-file will be replaced with the company_name or if it
|
149
|
+
# is a private work the name of the present user. It returns a sucess or fail.
|
150
|
+
# @param [String] title comes from titleget[3]
|
151
|
+
# @param [String] environment Work or Private
|
152
|
+
# @param [String] name your name (config file)
|
153
|
+
# @param [String] company_name (config file)
|
154
|
+
# @param [String] ent Path to Entityfile
|
155
|
+
PublicanCreatorsChange.change_holder(title, environment, name, company_name,
|
156
|
+
ent)
|
157
|
+
|
158
|
+
# This method removes the XI-Includes for the legal notice. It returns a sucess or fail.
|
159
|
+
# @param [String] environment Work or Private
|
160
|
+
# @param [String] type Book or Article
|
161
|
+
# @param [String] legal remove legalnotice from article? (config file)
|
162
|
+
# @param [String] art_info Path to Article_Info.xml
|
163
|
+
PublicanCreatorsChange.remove_legal(environment, type, legal, art_info)
|
164
|
+
|
165
|
+
# Checks if bookinfo or artinfo is needed, then it starts remove_orgname
|
166
|
+
# @param [String] art_info path to Article_Info (hardcoded)
|
167
|
+
# @param [String] book_info path to Book_Info (hardcoded)
|
168
|
+
# @param [String] title_logo remove titlelogo from articlepage (config file)
|
169
|
+
# @param [String] type Book or Article
|
170
|
+
PublicanCreatorsChange.remove_orgname_prepare(book_info, art_info, title_logo,
|
171
|
+
type)
|
172
|
+
|
173
|
+
# This method splits the name variable into firstname and surname. These variables are setted into the
|
174
|
+
# Revision_History. If the environment is "Work" your email_business will be used, otherwise your private
|
175
|
+
# email_address. It returns a sucess or fail.
|
176
|
+
# @param [String] environment Work or Private
|
177
|
+
# @param [String] name your name (config file)
|
178
|
+
# @param [String] email_business business email address (config file)
|
179
|
+
# @param [String] email private email address (config file)
|
180
|
+
# @param [String] rev_hist Path to Revision_History.xml
|
181
|
+
PublicanCreatorsChange.fix_revhist(environment, name, email_business, email,
|
182
|
+
rev_hist)
|
183
|
+
|
184
|
+
# This method replaces the standard values from Author_Group to the present user issues. It will be launched for
|
185
|
+
# the Work environment. It returns a sucess or fail.
|
186
|
+
# @param [String] name your name (config file)
|
187
|
+
# @param [String] email_business business email address (config file)
|
188
|
+
# @param [String] company_name your company's name (config file)
|
189
|
+
# @param [String] company_division your companiy's division
|
190
|
+
# @param [String] email your private email address
|
191
|
+
# @param [String] environment Work or Private
|
192
|
+
# @param [String] a_group Path to Author_Group.xml
|
193
|
+
PublicanCreatorsChange.fix_authorgroup(name, email_business, company_name,
|
194
|
+
company_division, email, environment,
|
195
|
+
a_group)
|
196
|
+
|
197
|
+
# Exports a predefined Shellscript to the target directory. It returns a sucess or fail.
|
198
|
+
# @param [String] title comes from PublicanCreatorsGet.title
|
199
|
+
# @param [String] builds path to buildscript (hardcoded)
|
200
|
+
# @param [String] language comes from config file in format de-DE
|
201
|
+
# @param [String] xfc_brand_dir if present the path to your branded xfc stylesheets (config file)
|
202
|
+
# @param [String] pdf_view your prefered PDF-Viewer (config file)
|
203
|
+
PublicanCreatorsExport.export_buildscript(title, builds, language,
|
204
|
+
xfc_brand_dir, pdf_view)
|
205
|
+
|
206
|
+
puts "Now you can find your documentation there: #{targetdir}/#{title}".color(:green)
|
207
|
+
Notifier.run
|
208
|
+
puts "Thanks for using: publican_creators #{PublicanCreators::Version::STRING}".color(:green)
|
209
|
+
end
|
210
|
+
end
|
@@ -1,287 +1,287 @@
|
|
1
|
-
# Copyright (C) 2013-
|
2
|
-
#
|
3
|
-
# This program is free software: you can redistribute it and/or modify
|
4
|
-
# it under the terms of the GNU General Public License as published by
|
5
|
-
# the Free Software Foundation, either version 3 of the License, or
|
6
|
-
# (at your option) any later version.
|
7
|
-
#
|
8
|
-
# This program is distributed in the hope that it will be useful,
|
9
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
-
# GNU General Public License for more details.
|
12
|
-
#
|
13
|
-
# You should have received a copy of the GNU General Public License
|
14
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
-
|
16
|
-
# Dependencies
|
17
|
-
|
18
|
-
require 'nokogiri'
|
19
|
-
require_relative 'create'
|
20
|
-
require_relative 'checker'
|
21
|
-
|
22
|
-
# Module what contains all methods who are doing changes in files
|
23
|
-
module PublicanCreatorsChange
|
24
|
-
# Method for replacing content in agroup
|
25
|
-
# @param [String] nice_description is the default text in the target file
|
26
|
-
# @param [String] value_name the replace text
|
27
|
-
# @param [String] file Target file like Author_Group.xml
|
28
|
-
# @return [String] true or false
|
29
|
-
def self.add_result(nice_description, value_name, file)
|
30
|
-
text = File.read(file)
|
31
|
-
new_value = text.gsub(nice_description, value_name)
|
32
|
-
puts new_value
|
33
|
-
File.open(file, 'w') do |file1|
|
34
|
-
file1.puts new_value
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# This method checks the environment and runs the method for
|
39
|
-
# @param [String] environment shows if you actually want to create a private or Business Publication. If Work is
|
40
|
-
# given it reads your global entity file and appends it on the ent file.
|
41
|
-
# @param [String] title comes from the get method. This param represents the name or title of your work. It
|
42
|
-
# is used in all important code places.
|
43
|
-
# @param [String] type represents the Document-Type like Article or Book.
|
44
|
-
# @param [String] language is just the ISO Code of your target language like: de-DE, en-GB or such things.
|
45
|
-
# @param [String] brand can be a special customized brand for your company to fit the styleguide.
|
46
|
-
# @param [String] db5 just sets your preferences.
|
47
|
-
# @param [String] brand_homework can be a special customized brand for distance learning schools.
|
48
|
-
# @param [String] brand_private is used in all methods with a "private" in the name. If this brand is set it will
|
49
|
-
# be used instead of the original publican brand.
|
50
|
-
# @param [String] homework if homework is set
|
51
|
-
# @return [String] true or false
|
52
|
-
def self.check_environment(environment, title, type, language, brand, db5, homework, brand_homework, brand_private)
|
53
|
-
if environment == 'Work'
|
54
|
-
PublicanCreatorsCreate.init_docu_work(title, type, language, brand, db5)
|
55
|
-
else
|
56
|
-
PublicanCreatorsCreate.init_docu_private(title, type, homework, language, brand_homework, brand_private, db5)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# By working for my employer i'm creating publications which refers to a global entity file.
|
61
|
-
# This method adds the entities from that file into the local one. It returns a success or fail.
|
62
|
-
# @param [String] environment shows if you actually want to create a private or Business Publication. If Work
|
63
|
-
# is given it reads your global entity file and appends it on the ent file.
|
64
|
-
# @param [String] global_entities is just the path to the global entity file.
|
65
|
-
# @param [String] ent Path to the entity file
|
66
|
-
# @return [String] true or false
|
67
|
-
def self.add_entity(environment, global_entities, ent)
|
68
|
-
if environment == 'Work'
|
69
|
-
if global_entities.empty?
|
70
|
-
puts 'Nothing to do'
|
71
|
-
else
|
72
|
-
puts 'Adding global entities...'
|
73
|
-
# @note Adding global entities
|
74
|
-
open(ent, 'a') do |add|
|
75
|
-
add << "\n"
|
76
|
-
add << "<!-- COMMON ENTITIES -->\n"
|
77
|
-
end
|
78
|
-
input = File.open(global_entities)
|
79
|
-
data_to_copy = input.read
|
80
|
-
output = File.open(ent, 'a')
|
81
|
-
output.write(data_to_copy)
|
82
|
-
input.close
|
83
|
-
output.close
|
84
|
-
end
|
85
|
-
else
|
86
|
-
puts 'Nothing to do'
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# In this method the standard-holder from the local entity-file will be replaced with the company_name or if it is a
|
91
|
-
# private work the name of the present user. It returns a sucess or fail.
|
92
|
-
# @note If the environment "Work" is given the entity file will be set as HOLDER otherwise it sets your name.
|
93
|
-
# @param [String] title comes from the get method.
|
94
|
-
# @param [String] environment shows if you actually want to create a private
|
95
|
-
# or Business Publication. If Work is given it reads your
|
96
|
-
# global entity file and appends it on the ent file.
|
97
|
-
# @param [String] name is your name.
|
98
|
-
# @param [String] company_name is the name of your company
|
99
|
-
# @param [String] ent Path to the entity file
|
100
|
-
# @return [String] true or false
|
101
|
-
def self.change_holder(title, environment, name, company_name, ent)
|
102
|
-
# @note Replace the Holder with the real one
|
103
|
-
puts 'Replace holder field with the present user'
|
104
|
-
namefill = if environment == 'Work'
|
105
|
-
company_name.to_s
|
106
|
-
else
|
107
|
-
name.to_s
|
108
|
-
end
|
109
|
-
change_holder_do(namefill, title, ent)
|
110
|
-
end
|
111
|
-
|
112
|
-
# This method does the changes
|
113
|
-
# @param [String] namefill can be the name or the company_name depends on
|
114
|
-
# environment
|
115
|
-
# @param [String] title comes from the get method. This @param represents the
|
116
|
-
# name or title of your work. It is used in all important code
|
117
|
-
# places.
|
118
|
-
# @param [String] ent Path to the entity file
|
119
|
-
# @return [String] true or false
|
120
|
-
def self.change_holder_do(namefill, title, ent)
|
121
|
-
text = File.read(ent)
|
122
|
-
new_contents = text.gsub("| You need to change the HOLDER entity in the de-DE/#{title}.ent file |", namefill.to_s)
|
123
|
-
puts new_contents
|
124
|
-
File.open(ent, 'w') { |file| file.puts new_contents }
|
125
|
-
end
|
126
|
-
|
127
|
-
# This method removes the <orgname> node from the XML file. Remove titlepage logo because of doing this with the
|
128
|
-
# publican branding files. This method will applied if environment is Work, "type" is Article and title_logo is
|
129
|
-
# "false". It returns a sucess or fail.
|
130
|
-
# TODO: Try to fix this in future
|
131
|
-
# rubocop:disable Style/GuardClause
|
132
|
-
# @param [String] info can be bookinfo or artinfo
|
133
|
-
# @param [String] title_logo means that you can set if you want to use Publican's Title Logo or use your own Title
|
134
|
-
# Logo with your Stylesheets.
|
135
|
-
# @return [String] true or false
|
136
|
-
def self.remove_orgname(info, title_logo)
|
137
|
-
if title_logo == 'false'
|
138
|
-
puts 'Remove title logo from Article_Info or Books_Info'
|
139
|
-
puts info
|
140
|
-
doc = Nokogiri::XML(IO.read(info))
|
141
|
-
doc.search('orgname').each do |node|
|
142
|
-
node.remove
|
143
|
-
node.content = 'Children removed'
|
144
|
-
end
|
145
|
-
IO.write(info, doc.to_xml)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
# Checks if bookinfo or artinfo is needed, then it starts remove_orgname
|
150
|
-
# @param [String] bookinfo Book_Info. Which is used there depends on the param "type".
|
151
|
-
# @param [String] artinfo Article_Info. Which is used there depends on the param "type".
|
152
|
-
# @param [String] title_logo means that you can set if you want to use Publican's Title Logo or use your
|
153
|
-
# own Title Logo with your Stylesheets.
|
154
|
-
# @param [String] type represents the Document-Type like Article or Book.
|
155
|
-
def self.remove_orgname_prepare(bookinfo, artinfo, title_logo, type)
|
156
|
-
info = artinfo if type == 'Article'
|
157
|
-
info = bookinfo if type == 'Book'
|
158
|
-
remove_orgname(info, title_logo)
|
159
|
-
end
|
160
|
-
|
161
|
-
# This method replaces the old productversion to the new revision
|
162
|
-
# @param [String] language The default language from the config file
|
163
|
-
# @param [String] revision The new revision number
|
164
|
-
# @param [String] edition The new edition number
|
165
|
-
# @return [String] true or false
|
166
|
-
def self.replace_productnumber(revision, edition, language)
|
167
|
-
puts 'Replacing the productnumber'
|
168
|
-
info = if File.exist?("#{language}/Article_Info.xml")
|
169
|
-
"#{language}/Article_Info.xml"
|
170
|
-
else
|
171
|
-
"#{language}/Book_Info.xml"
|
172
|
-
end
|
173
|
-
doc = Nokogiri::XML(IO.read(info))
|
174
|
-
doc.search('productnumber').each do |node|
|
175
|
-
node.content = revision.to_s
|
176
|
-
end
|
177
|
-
doc.search('edition').each do |node|
|
178
|
-
node.content = edition.to_s
|
179
|
-
end
|
180
|
-
IO.write(info, doc.to_xml)
|
181
|
-
end
|
182
|
-
|
183
|
-
# This method removes the XI-Includes for the legal notice. It returns a sucess or fail.
|
184
|
-
# @param [String] environment shows if you actually want to create a private or Business Publication. If Work is
|
185
|
-
# given it reads your global entity file and appends it on the ent file.
|
186
|
-
# @param [String] type represents the Document-Type like Article or Book.
|
187
|
-
# @param [String] legal means if you don't like to have a Legal Notice on Publican's default place you can
|
188
|
-
# define it there. Actually it just works with Articles. In my case i'm using the
|
189
|
-
# Legal Notice inside the Article's Structure.
|
190
|
-
# @param [String] artinfo Article_Info. Which is used there depends on the param "type".
|
191
|
-
# @return [String] true or false
|
192
|
-
def self.remove_legal(environment, type, legal, artinfo)
|
193
|
-
if environment == 'Work'
|
194
|
-
if type == 'Article'
|
195
|
-
if legal == 'true'
|
196
|
-
# @note Remove the Legal Notice XI-Include in case it is an article.
|
197
|
-
# XCOM articles using another way to add them.
|
198
|
-
puts 'Remove XI-Includes for Legal Notice...'
|
199
|
-
text = File.read(artinfo)
|
200
|
-
# rubocop:disable Metrics/LineLength
|
201
|
-
new_contents = text.gsub('<xi:include href="Common_Content/Legal_Notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />', '')
|
202
|
-
puts new_contents
|
203
|
-
File.open(artinfo, 'w') { |file| file.puts new_contents }
|
204
|
-
end
|
205
|
-
else
|
206
|
-
puts 'Nothing to do'
|
207
|
-
end
|
208
|
-
else
|
209
|
-
puts 'Nothing to do'
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
# This method splits the name variable into firstname and surname. These variables are setted into the
|
214
|
-
# Revision_History. If the environment is "Work" your email_business will be used, otherwise your private
|
215
|
-
# email_address. It returns a sucess or fail.
|
216
|
-
# @param [String] revhist Path to the Revision_History
|
217
|
-
# @param [String] environment shows if you actually want to create a private or Business Publication. If Work is
|
218
|
-
# given it reads your global entity file and appends it on the ent file.
|
219
|
-
# @param [String] name is your name.
|
220
|
-
# @param [String] email_business is your business email address.
|
221
|
-
# @param [String] email is your private email address.
|
222
|
-
# @return [String] true or false
|
223
|
-
def self.fix_revhist(environment, name, email_business, email, revhist)
|
224
|
-
firstname, surname = get_name(name)
|
225
|
-
# @note Revision_History: Change default stuff to the present user
|
226
|
-
puts 'Replace the default content with the new content from the user
|
227
|
-
(Revision History)'
|
228
|
-
add_result('Enter your first name here.', firstname.to_s, revhist)
|
229
|
-
add_result('Enter your surname here.', surname.to_s, revhist)
|
230
|
-
add_result('Initial creation by publican', 'Initial creation', revhist)
|
231
|
-
|
232
|
-
if environment == 'Work'
|
233
|
-
add_result('Enter your email address here.', email_business.to_s, revhist)
|
234
|
-
else
|
235
|
-
add_result('Enter your email address here.', email.to_s, revhist)
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
# This method replaces the standard values from Author_Group to the present user issues. It will be launched for
|
240
|
-
# the Work environment. It returns a sucess or fail.
|
241
|
-
# TODO: Try to fix this in future
|
242
|
-
# rubocop:disable Metrics/AbcSize
|
243
|
-
# @param [String] name is your name.
|
244
|
-
# @param [String] email_business is your business email address.
|
245
|
-
# @param [String] company_name is just your companies name.
|
246
|
-
# @param [String] company_division is your companies part/division.
|
247
|
-
# @param [String] email is your private email address.
|
248
|
-
# @param [String] environment shows if you actually want to create a private
|
249
|
-
# or Business Publication. If Work is given it reads your
|
250
|
-
# global entity file and appends it on the ent file.
|
251
|
-
# @param [String] agroup Path to Author_Group.xml
|
252
|
-
# @return [String] true or false
|
253
|
-
def self.fix_authorgroup(name, email_business, company_name, company_division,
|
254
|
-
email, environment, agroup)
|
255
|
-
firstname, surname = get_name(name)
|
256
|
-
# @note Author Group: Change the default stuff to the present user
|
257
|
-
puts 'Replace the default content with the new content from the user
|
258
|
-
(Authors_Group)'
|
259
|
-
add_result('Enter your first name here.', firstname.to_s, agroup)
|
260
|
-
add_result('Enter your surname here.', surname.to_s, agroup)
|
261
|
-
add_result('Initial creation by publican', 'Initial creation', agroup)
|
262
|
-
|
263
|
-
if environment == 'Work'
|
264
|
-
add_result('Enter your email address here.', email_business.to_s, agroup)
|
265
|
-
add_result('Enter your organisation\'s name here.', company_name.to_s,
|
266
|
-
agroup)
|
267
|
-
add_result('Enter your organisational division here.',
|
268
|
-
company_division.to_s, agroup)
|
269
|
-
else
|
270
|
-
add_result('Enter your email address here.', email.to_s, agroup)
|
271
|
-
add_result('Enter your organisation\'s name here.', '', agroup)
|
272
|
-
add_result('Enter your organisational division here.', '', agroup)
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
# Method for splitting the name variable into firstname and surname
|
277
|
-
# @param [String] name The name from config file
|
278
|
-
# @return [String] true or false
|
279
|
-
def self.get_name(name)
|
280
|
-
namechomp = name.chomp
|
281
|
-
# @note Split the variable to the array title[*]
|
282
|
-
name = namechomp.split(' ')
|
283
|
-
firstname = name[0]
|
284
|
-
surname = name[1]
|
285
|
-
[firstname, surname]
|
286
|
-
end
|
287
|
-
end
|
1
|
+
# Copyright (C) 2013-2020 Sascha Manns <Sascha.Manns@outlook.de>
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
# Dependencies
|
17
|
+
|
18
|
+
require 'nokogiri'
|
19
|
+
require_relative 'create'
|
20
|
+
require_relative 'checker'
|
21
|
+
|
22
|
+
# Module what contains all methods who are doing changes in files
|
23
|
+
module PublicanCreatorsChange
|
24
|
+
# Method for replacing content in agroup
|
25
|
+
# @param [String] nice_description is the default text in the target file
|
26
|
+
# @param [String] value_name the replace text
|
27
|
+
# @param [String] file Target file like Author_Group.xml
|
28
|
+
# @return [String] true or false
|
29
|
+
def self.add_result(nice_description, value_name, file)
|
30
|
+
text = File.read(file)
|
31
|
+
new_value = text.gsub(nice_description, value_name)
|
32
|
+
puts new_value
|
33
|
+
File.open(file, 'w') do |file1|
|
34
|
+
file1.puts new_value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# This method checks the environment and runs the method for
|
39
|
+
# @param [String] environment shows if you actually want to create a private or Business Publication. If Work is
|
40
|
+
# given it reads your global entity file and appends it on the ent file.
|
41
|
+
# @param [String] title comes from the get method. This param represents the name or title of your work. It
|
42
|
+
# is used in all important code places.
|
43
|
+
# @param [String] type represents the Document-Type like Article or Book.
|
44
|
+
# @param [String] language is just the ISO Code of your target language like: de-DE, en-GB or such things.
|
45
|
+
# @param [String] brand can be a special customized brand for your company to fit the styleguide.
|
46
|
+
# @param [String] db5 just sets your preferences.
|
47
|
+
# @param [String] brand_homework can be a special customized brand for distance learning schools.
|
48
|
+
# @param [String] brand_private is used in all methods with a "private" in the name. If this brand is set it will
|
49
|
+
# be used instead of the original publican brand.
|
50
|
+
# @param [String] homework if homework is set
|
51
|
+
# @return [String] true or false
|
52
|
+
def self.check_environment(environment, title, type, language, brand, db5, homework, brand_homework, brand_private)
|
53
|
+
if environment == 'Work'
|
54
|
+
PublicanCreatorsCreate.init_docu_work(title, type, language, brand, db5)
|
55
|
+
else
|
56
|
+
PublicanCreatorsCreate.init_docu_private(title, type, homework, language, brand_homework, brand_private, db5)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# By working for my employer i'm creating publications which refers to a global entity file.
|
61
|
+
# This method adds the entities from that file into the local one. It returns a success or fail.
|
62
|
+
# @param [String] environment shows if you actually want to create a private or Business Publication. If Work
|
63
|
+
# is given it reads your global entity file and appends it on the ent file.
|
64
|
+
# @param [String] global_entities is just the path to the global entity file.
|
65
|
+
# @param [String] ent Path to the entity file
|
66
|
+
# @return [String] true or false
|
67
|
+
def self.add_entity(environment, global_entities, ent)
|
68
|
+
if environment == 'Work'
|
69
|
+
if global_entities.empty?
|
70
|
+
puts 'Nothing to do'
|
71
|
+
else
|
72
|
+
puts 'Adding global entities...'
|
73
|
+
# @note Adding global entities
|
74
|
+
open(ent, 'a') do |add|
|
75
|
+
add << "\n"
|
76
|
+
add << "<!-- COMMON ENTITIES -->\n"
|
77
|
+
end
|
78
|
+
input = File.open(global_entities)
|
79
|
+
data_to_copy = input.read
|
80
|
+
output = File.open(ent, 'a')
|
81
|
+
output.write(data_to_copy)
|
82
|
+
input.close
|
83
|
+
output.close
|
84
|
+
end
|
85
|
+
else
|
86
|
+
puts 'Nothing to do'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# In this method the standard-holder from the local entity-file will be replaced with the company_name or if it is a
|
91
|
+
# private work the name of the present user. It returns a sucess or fail.
|
92
|
+
# @note If the environment "Work" is given the entity file will be set as HOLDER otherwise it sets your name.
|
93
|
+
# @param [String] title comes from the get method.
|
94
|
+
# @param [String] environment shows if you actually want to create a private
|
95
|
+
# or Business Publication. If Work is given it reads your
|
96
|
+
# global entity file and appends it on the ent file.
|
97
|
+
# @param [String] name is your name.
|
98
|
+
# @param [String] company_name is the name of your company
|
99
|
+
# @param [String] ent Path to the entity file
|
100
|
+
# @return [String] true or false
|
101
|
+
def self.change_holder(title, environment, name, company_name, ent)
|
102
|
+
# @note Replace the Holder with the real one
|
103
|
+
puts 'Replace holder field with the present user'
|
104
|
+
namefill = if environment == 'Work'
|
105
|
+
company_name.to_s
|
106
|
+
else
|
107
|
+
name.to_s
|
108
|
+
end
|
109
|
+
change_holder_do(namefill, title, ent)
|
110
|
+
end
|
111
|
+
|
112
|
+
# This method does the changes
|
113
|
+
# @param [String] namefill can be the name or the company_name depends on
|
114
|
+
# environment
|
115
|
+
# @param [String] title comes from the get method. This @param represents the
|
116
|
+
# name or title of your work. It is used in all important code
|
117
|
+
# places.
|
118
|
+
# @param [String] ent Path to the entity file
|
119
|
+
# @return [String] true or false
|
120
|
+
def self.change_holder_do(namefill, title, ent)
|
121
|
+
text = File.read(ent)
|
122
|
+
new_contents = text.gsub("| You need to change the HOLDER entity in the de-DE/#{title}.ent file |", namefill.to_s)
|
123
|
+
puts new_contents
|
124
|
+
File.open(ent, 'w') { |file| file.puts new_contents }
|
125
|
+
end
|
126
|
+
|
127
|
+
# This method removes the <orgname> node from the XML file. Remove titlepage logo because of doing this with the
|
128
|
+
# publican branding files. This method will applied if environment is Work, "type" is Article and title_logo is
|
129
|
+
# "false". It returns a sucess or fail.
|
130
|
+
# TODO: Try to fix this in future
|
131
|
+
# rubocop:disable Style/GuardClause
|
132
|
+
# @param [String] info can be bookinfo or artinfo
|
133
|
+
# @param [String] title_logo means that you can set if you want to use Publican's Title Logo or use your own Title
|
134
|
+
# Logo with your Stylesheets.
|
135
|
+
# @return [String] true or false
|
136
|
+
def self.remove_orgname(info, title_logo)
|
137
|
+
if title_logo == 'false'
|
138
|
+
puts 'Remove title logo from Article_Info or Books_Info'
|
139
|
+
puts info
|
140
|
+
doc = Nokogiri::XML(IO.read(info))
|
141
|
+
doc.search('orgname').each do |node|
|
142
|
+
node.remove
|
143
|
+
node.content = 'Children removed'
|
144
|
+
end
|
145
|
+
IO.write(info, doc.to_xml)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# Checks if bookinfo or artinfo is needed, then it starts remove_orgname
|
150
|
+
# @param [String] bookinfo Book_Info. Which is used there depends on the param "type".
|
151
|
+
# @param [String] artinfo Article_Info. Which is used there depends on the param "type".
|
152
|
+
# @param [String] title_logo means that you can set if you want to use Publican's Title Logo or use your
|
153
|
+
# own Title Logo with your Stylesheets.
|
154
|
+
# @param [String] type represents the Document-Type like Article or Book.
|
155
|
+
def self.remove_orgname_prepare(bookinfo, artinfo, title_logo, type)
|
156
|
+
info = artinfo if type == 'Article'
|
157
|
+
info = bookinfo if type == 'Book'
|
158
|
+
remove_orgname(info, title_logo)
|
159
|
+
end
|
160
|
+
|
161
|
+
# This method replaces the old productversion to the new revision
|
162
|
+
# @param [String] language The default language from the config file
|
163
|
+
# @param [String] revision The new revision number
|
164
|
+
# @param [String] edition The new edition number
|
165
|
+
# @return [String] true or false
|
166
|
+
def self.replace_productnumber(revision, edition, language)
|
167
|
+
puts 'Replacing the productnumber'
|
168
|
+
info = if File.exist?("#{language}/Article_Info.xml")
|
169
|
+
"#{language}/Article_Info.xml"
|
170
|
+
else
|
171
|
+
"#{language}/Book_Info.xml"
|
172
|
+
end
|
173
|
+
doc = Nokogiri::XML(IO.read(info))
|
174
|
+
doc.search('productnumber').each do |node|
|
175
|
+
node.content = revision.to_s
|
176
|
+
end
|
177
|
+
doc.search('edition').each do |node|
|
178
|
+
node.content = edition.to_s
|
179
|
+
end
|
180
|
+
IO.write(info, doc.to_xml)
|
181
|
+
end
|
182
|
+
|
183
|
+
# This method removes the XI-Includes for the legal notice. It returns a sucess or fail.
|
184
|
+
# @param [String] environment shows if you actually want to create a private or Business Publication. If Work is
|
185
|
+
# given it reads your global entity file and appends it on the ent file.
|
186
|
+
# @param [String] type represents the Document-Type like Article or Book.
|
187
|
+
# @param [String] legal means if you don't like to have a Legal Notice on Publican's default place you can
|
188
|
+
# define it there. Actually it just works with Articles. In my case i'm using the
|
189
|
+
# Legal Notice inside the Article's Structure.
|
190
|
+
# @param [String] artinfo Article_Info. Which is used there depends on the param "type".
|
191
|
+
# @return [String] true or false
|
192
|
+
def self.remove_legal(environment, type, legal, artinfo)
|
193
|
+
if environment == 'Work'
|
194
|
+
if type == 'Article'
|
195
|
+
if legal == 'true'
|
196
|
+
# @note Remove the Legal Notice XI-Include in case it is an article.
|
197
|
+
# XCOM articles using another way to add them.
|
198
|
+
puts 'Remove XI-Includes for Legal Notice...'
|
199
|
+
text = File.read(artinfo)
|
200
|
+
# rubocop:disable Metrics/LineLength
|
201
|
+
new_contents = text.gsub('<xi:include href="Common_Content/Legal_Notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />', '')
|
202
|
+
puts new_contents
|
203
|
+
File.open(artinfo, 'w') { |file| file.puts new_contents }
|
204
|
+
end
|
205
|
+
else
|
206
|
+
puts 'Nothing to do'
|
207
|
+
end
|
208
|
+
else
|
209
|
+
puts 'Nothing to do'
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
# This method splits the name variable into firstname and surname. These variables are setted into the
|
214
|
+
# Revision_History. If the environment is "Work" your email_business will be used, otherwise your private
|
215
|
+
# email_address. It returns a sucess or fail.
|
216
|
+
# @param [String] revhist Path to the Revision_History
|
217
|
+
# @param [String] environment shows if you actually want to create a private or Business Publication. If Work is
|
218
|
+
# given it reads your global entity file and appends it on the ent file.
|
219
|
+
# @param [String] name is your name.
|
220
|
+
# @param [String] email_business is your business email address.
|
221
|
+
# @param [String] email is your private email address.
|
222
|
+
# @return [String] true or false
|
223
|
+
def self.fix_revhist(environment, name, email_business, email, revhist)
|
224
|
+
firstname, surname = get_name(name)
|
225
|
+
# @note Revision_History: Change default stuff to the present user
|
226
|
+
puts 'Replace the default content with the new content from the user
|
227
|
+
(Revision History)'
|
228
|
+
add_result('Enter your first name here.', firstname.to_s, revhist)
|
229
|
+
add_result('Enter your surname here.', surname.to_s, revhist)
|
230
|
+
add_result('Initial creation by publican', 'Initial creation', revhist)
|
231
|
+
|
232
|
+
if environment == 'Work'
|
233
|
+
add_result('Enter your email address here.', email_business.to_s, revhist)
|
234
|
+
else
|
235
|
+
add_result('Enter your email address here.', email.to_s, revhist)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
# This method replaces the standard values from Author_Group to the present user issues. It will be launched for
|
240
|
+
# the Work environment. It returns a sucess or fail.
|
241
|
+
# TODO: Try to fix this in future
|
242
|
+
# rubocop:disable Metrics/AbcSize
|
243
|
+
# @param [String] name is your name.
|
244
|
+
# @param [String] email_business is your business email address.
|
245
|
+
# @param [String] company_name is just your companies name.
|
246
|
+
# @param [String] company_division is your companies part/division.
|
247
|
+
# @param [String] email is your private email address.
|
248
|
+
# @param [String] environment shows if you actually want to create a private
|
249
|
+
# or Business Publication. If Work is given it reads your
|
250
|
+
# global entity file and appends it on the ent file.
|
251
|
+
# @param [String] agroup Path to Author_Group.xml
|
252
|
+
# @return [String] true or false
|
253
|
+
def self.fix_authorgroup(name, email_business, company_name, company_division,
|
254
|
+
email, environment, agroup)
|
255
|
+
firstname, surname = get_name(name)
|
256
|
+
# @note Author Group: Change the default stuff to the present user
|
257
|
+
puts 'Replace the default content with the new content from the user
|
258
|
+
(Authors_Group)'
|
259
|
+
add_result('Enter your first name here.', firstname.to_s, agroup)
|
260
|
+
add_result('Enter your surname here.', surname.to_s, agroup)
|
261
|
+
add_result('Initial creation by publican', 'Initial creation', agroup)
|
262
|
+
|
263
|
+
if environment == 'Work'
|
264
|
+
add_result('Enter your email address here.', email_business.to_s, agroup)
|
265
|
+
add_result('Enter your organisation\'s name here.', company_name.to_s,
|
266
|
+
agroup)
|
267
|
+
add_result('Enter your organisational division here.',
|
268
|
+
company_division.to_s, agroup)
|
269
|
+
else
|
270
|
+
add_result('Enter your email address here.', email.to_s, agroup)
|
271
|
+
add_result('Enter your organisation\'s name here.', '', agroup)
|
272
|
+
add_result('Enter your organisational division here.', '', agroup)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
# Method for splitting the name variable into firstname and surname
|
277
|
+
# @param [String] name The name from config file
|
278
|
+
# @return [String] true or false
|
279
|
+
def self.get_name(name)
|
280
|
+
namechomp = name.chomp
|
281
|
+
# @note Split the variable to the array title[*]
|
282
|
+
name = namechomp.split(' ')
|
283
|
+
firstname = name[0]
|
284
|
+
surname = name[1]
|
285
|
+
[firstname, surname]
|
286
|
+
end
|
287
|
+
end
|