publican_creators 1.1.1 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,23 @@
1
- # Changer Module for PublicanCreators
2
- # PublicanCreatorsChange
3
- # @author Sascha Manns
4
- # @abstract Class for all file changes
1
+ # Copyright (C) 2013-2020 Sascha Manns <Sascha.Manns@outlook.de>
5
2
  #
6
- # Copyright (C) 2015-2017 Sascha Manns <samannsml@directbox.com>
7
- # License: MIT
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/>.
8
15
 
9
16
  # Dependencies
10
17
 
11
18
  require 'nokogiri'
12
- require 'publican_creators/create'
13
- require 'publican_creators/checker'
14
- require 'manns_shared'
19
+ require_relative 'create'
20
+ require_relative 'checker'
15
21
 
16
22
  # Module what contains all methods who are doing changes in files
17
23
  module PublicanCreatorsChange
@@ -30,49 +36,34 @@ module PublicanCreatorsChange
30
36
  end
31
37
 
32
38
  # This method checks the environment and runs the method for
33
- # @param [String] environment shows if you actually want to create a private
34
- # or Business Publication. If Work is given it
35
- # reads your global entity file and appends it on
36
- # the ent file.
37
- # @param [String] title comes from the get method. This param represents the
38
- # name or title of your work. It is used in all important
39
- # code places.
40
- # @param [String] type represents the Document-Type like Article or Book.
41
- # @param [String] language is just the ISO Code of your target language like:
42
- # de-DE, en-GB or such things.
43
- # @param [String] brand can be a special customized brand for your company to
44
- # fit the styleguide.
45
- # @param [String] db5 just sets your preferences. If you like to have DocBook
46
- # 5.x as default you can set it there.
47
- # @param [String] brand_homework can be a special customized brand for
48
- # distance learning schools.
49
- # @param [String] brand_private is used in all methods with a "private" in the
50
- # name. If this brand is set it will be used instead of the
51
- # original publican brand.
52
- # @param [String] homework if homework is set
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
53
51
  # @return [String] true or false
54
- def self.check_environment(environment, title, type, language, brand, db5,
55
- homework, brand_homework, brand_private)
52
+ def self.check_environment(environment, title, type, language, brand, db5, homework, brand_homework, brand_private)
56
53
  if environment == 'Work'
57
54
  PublicanCreatorsCreate.init_docu_work(title, type, language, brand, db5)
58
55
  else
59
- PublicanCreatorsCreate.init_docu_private(title, type, homework, language,
60
- brand_homework, brand_private,
61
- db5)
56
+ PublicanCreatorsCreate.init_docu_private(title, type, homework, language, brand_homework, brand_private, db5)
62
57
  end
63
58
  end
64
59
 
65
- # By working for my employer i'm creating publications which refers to a
66
- # global entity file.
67
- # This method adds the entities from that file into the local one. It returns
68
- # a success or fail.
69
- # @param [String] environment shows if you actually want to create a private
70
- # or Business Publication. If Work is given it reads your
71
- # global entity file and appends it on the ent file.
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.
72
64
  # @param [String] global_entities is just the path to the global entity file.
73
65
  # @param [String] ent Path to the entity file
74
66
  # @return [String] true or false
75
- # This method smells of :reek:UncommunicativeVariableName
76
67
  def self.add_entity(environment, global_entities, ent)
77
68
  if environment == 'Work'
78
69
  if global_entities.empty?
@@ -80,9 +71,9 @@ module PublicanCreatorsChange
80
71
  else
81
72
  puts 'Adding global entities...'
82
73
  # @note Adding global entities
83
- open(ent, 'a') do |f|
84
- f << "\n"
85
- f << "<!-- COMMON ENTITIES -->\n"
74
+ open(ent, 'a') do |add|
75
+ add << "\n"
76
+ add << "<!-- COMMON ENTITIES -->\n"
86
77
  end
87
78
  input = File.open(global_entities)
88
79
  data_to_copy = input.read
@@ -96,12 +87,10 @@ module PublicanCreatorsChange
96
87
  end
97
88
  end
98
89
 
99
- # In this method the standard-holder from the local entity-file will be
100
- # replaced with the company_name or if it is a private work the name of the
101
- # present user. It returns a sucess or fail.
102
- # @param [String] title comes from the get method. This @param represents the
103
- # name or title of your work. It is used in all important code
104
- # places.
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.
105
94
  # @param [String] environment shows if you actually want to create a private
106
95
  # or Business Publication. If Work is given it reads your
107
96
  # global entity file and appends it on the ent file.
@@ -109,16 +98,14 @@ module PublicanCreatorsChange
109
98
  # @param [String] company_name is the name of your company
110
99
  # @param [String] ent Path to the entity file
111
100
  # @return [String] true or false
112
- # @note If the environment "Work" is given the entity file will be set as
113
- # HOLDER otherwise it sets your name.
114
101
  def self.change_holder(title, environment, name, company_name, ent)
115
102
  # @note Replace the Holder with the real one
116
103
  puts 'Replace holder field with the present user'
117
- if environment == 'Work'
118
- namefill = "#{company_name}"
119
- else
120
- namefill = "#{name}"
121
- end
104
+ namefill = if environment == 'Work'
105
+ company_name.to_s
106
+ else
107
+ name.to_s
108
+ end
122
109
  change_holder_do(namefill, title, ent)
123
110
  end
124
111
 
@@ -132,21 +119,19 @@ module PublicanCreatorsChange
132
119
  # @return [String] true or false
133
120
  def self.change_holder_do(namefill, title, ent)
134
121
  text = File.read(ent)
135
- new_contents = text.gsub("| You need to change the HOLDER entity in the \
136
- de-DE/#{title}.ent file |", "#{namefill}")
122
+ new_contents = text.gsub("| You need to change the HOLDER entity in the de-DE/#{title}.ent file |", namefill.to_s)
137
123
  puts new_contents
138
124
  File.open(ent, 'w') { |file| file.puts new_contents }
139
125
  end
140
126
 
141
- # This method removes the <orgname> node from the XML file. Remove titlepage
142
- # logo because of doing this with the publican branding files. This method
143
- # will applied if environment is Work, "type" is Article and title_logo is
144
- # "false".
145
- # It returns a sucess or fail.
146
- # @param [String] info can be bookinfo or artinfo
147
- # @param [String] title_logo means that you can set if you want to use
148
- # Publican's Title Logo or use your own Title Logo with your
149
- # Stylesheets.
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.
150
135
  # @return [String] true or false
151
136
  def self.remove_orgname(info, title_logo)
152
137
  if title_logo == 'false'
@@ -162,19 +147,17 @@ de-DE/#{title}.ent file |", "#{namefill}")
162
147
  end
163
148
 
164
149
  # Checks if bookinfo or artinfo is needed, then it starts remove_orgname
165
- # @param [String] bookinfo Book_Info. Which is used there depends on the
166
- # param "type".
167
- # @param [String] artinfo Article_Info. Which is used there depends on the
168
- # param "type".
169
- # @param [String] title_logo means that you can set if you want to use
170
- # Publican's Title Logo or use your own Title Logo with your
171
- # Stylesheets.
172
- # @param [String] type represents the Document-Type like Article or Book.
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.
173
155
  def self.remove_orgname_prepare(bookinfo, artinfo, title_logo, type)
174
156
  info = artinfo if type == 'Article'
175
157
  info = bookinfo if type == 'Book'
176
158
  remove_orgname(info, title_logo)
177
159
  end
160
+
178
161
  # This method replaces the old productversion to the new revision
179
162
  # @param [String] language The default language from the config file
180
163
  # @param [String] revision The new revision number
@@ -182,33 +165,29 @@ de-DE/#{title}.ent file |", "#{namefill}")
182
165
  # @return [String] true or false
183
166
  def self.replace_productnumber(revision, edition, language)
184
167
  puts 'Replacing the productnumber'
185
- if File.exist?("#{language}/Article_Info.xml")
186
- info = "#{language}/Article_Info.xml"
187
- else
188
- info = "#{language}/Book_Info.xml"
189
- end
168
+ info = if File.exist?("#{language}/Article_Info.xml")
169
+ "#{language}/Article_Info.xml"
170
+ else
171
+ "#{language}/Book_Info.xml"
172
+ end
190
173
  doc = Nokogiri::XML(IO.read(info))
191
174
  doc.search('productnumber').each do |node|
192
- node.content = "#{revision}"
175
+ node.content = revision.to_s
193
176
  end
194
177
  doc.search('edition').each do |node|
195
- node.content = "#{edition}"
178
+ node.content = edition.to_s
196
179
  end
197
180
  IO.write(info, doc.to_xml)
198
181
  end
199
182
 
200
- # This method removes the XI-Includes for the legal notice
201
- # It returns a sucess or fail.
202
- # @param [String] environment shows if you actually want to create a private
203
- # or Business Publication. If Work is given it reads your
204
- # global entity file and appends it on the ent file.
205
- # @param [String] type represents the Document-Type like Article or Book.
206
- # @param [String] legal means if you don't like to have a Legal Notice on
207
- # Publican's default place you can define it there. Actually
208
- # it just works with Articles. In my case i'm using the
209
- # Legal Notice inside the Article's Structure.
210
- # @param [String] artinfo Article_Info. Which is used there depends on the
211
- # param "type".
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".
212
191
  # @return [String] true or false
213
192
  def self.remove_legal(environment, type, legal, artinfo)
214
193
  if environment == 'Work'
@@ -231,37 +210,36 @@ de-DE/#{title}.ent file |", "#{namefill}")
231
210
  end
232
211
  end
233
212
 
234
- # This method splits the name variable into firstname and surname. These
235
- # variables are setted into the Revision_History. If the environment is "Work"
236
- # your email_business will be used, otherwise your private email_address.
237
- # It returns a sucess or fail.
238
- # @param [String] revhist Path to the Revision_History
239
- # @param [String] environment shows if you actually want to create a private
240
- # or Business Publication. If Work is given it reads your
241
- # global entity file and appends it on the ent file.
242
- # @param [String] name is your name.
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.
243
220
  # @param [String] email_business is your business email address.
244
- # @param [String] email is your private email address.
221
+ # @param [String] email is your private email address.
245
222
  # @return [String] true or false
246
223
  def self.fix_revhist(environment, name, email_business, email, revhist)
247
224
  firstname, surname = get_name(name)
248
225
  # @note Revision_History: Change default stuff to the present user
249
226
  puts 'Replace the default content with the new content from the user
250
227
  (Revision History)'
251
- add_result('Enter your first name here.', "#{firstname}", revhist)
252
- add_result('Enter your surname here.', "#{surname}", revhist)
228
+ add_result('Enter your first name here.', firstname.to_s, revhist)
229
+ add_result('Enter your surname here.', surname.to_s, revhist)
253
230
  add_result('Initial creation by publican', 'Initial creation', revhist)
254
231
 
255
232
  if environment == 'Work'
256
- add_result('Enter your email address here.', "#{email_business}", revhist)
233
+ add_result('Enter your email address here.', email_business.to_s, revhist)
257
234
  else
258
- add_result('Enter your email address here.', "#{email}", revhist)
235
+ add_result('Enter your email address here.', email.to_s, revhist)
259
236
  end
260
237
  end
261
238
 
262
- # This method replaces the standard values from Author_Group to the present
263
- # user issues. It will be launched for the Work environment. It returns a
264
- # sucess or fail.
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
265
243
  # @param [String] name is your name.
266
244
  # @param [String] email_business is your business email address.
267
245
  # @param [String] company_name is just your companies name.
@@ -273,23 +251,23 @@ de-DE/#{title}.ent file |", "#{namefill}")
273
251
  # @param [String] agroup Path to Author_Group.xml
274
252
  # @return [String] true or false
275
253
  def self.fix_authorgroup(name, email_business, company_name, company_division,
276
- email, environment, agroup)
254
+ email, environment, agroup)
277
255
  firstname, surname = get_name(name)
278
256
  # @note Author Group: Change the default stuff to the present user
279
257
  puts 'Replace the default content with the new content from the user
280
258
  (Authors_Group)'
281
- add_result('Enter your first name here.', "#{firstname}", agroup)
282
- add_result('Enter your surname here.', "#{surname}", agroup)
259
+ add_result('Enter your first name here.', firstname.to_s, agroup)
260
+ add_result('Enter your surname here.', surname.to_s, agroup)
283
261
  add_result('Initial creation by publican', 'Initial creation', agroup)
284
262
 
285
263
  if environment == 'Work'
286
- add_result('Enter your email address here.', "#{email_business}", agroup)
287
- add_result('Enter your organisation\'s name here.', "#{company_name}",
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,
288
266
  agroup)
289
267
  add_result('Enter your organisational division here.',
290
- "#{company_division}", agroup)
268
+ company_division.to_s, agroup)
291
269
  else
292
- add_result('Enter your email address here.', "#{email}", agroup)
270
+ add_result('Enter your email address here.', email.to_s, agroup)
293
271
  add_result('Enter your organisation\'s name here.', '', agroup)
294
272
  add_result('Enter your organisational division here.', '', agroup)
295
273
  end
@@ -1,9 +1,17 @@
1
- # PublicanCreatorsChecker
2
- # @author Sascha Manns
3
- # @abstract Class for checking directories and creating them
1
+ # Copyright (C) 2013-2020 Sascha Manns <Sascha.Manns@outlook.de>
4
2
  #
5
- # Copyright (C) 2015-2017 Sascha Manns <Sascha.Manns@mailbox.org>
6
- # License: MIT
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/>.
7
15
 
8
16
  # Dependencies
9
17
 
@@ -18,6 +26,8 @@ module Checker
18
26
  # @return [String] true or false
19
27
  def self.check_dir(todos)
20
28
  # @note Checking if dir exists
29
+ # TODO: Try to fix this in future
30
+ # rubocop:disable Style/GuardClause
21
31
  if Dir.exist?(todos)
22
32
  puts 'Found directory. Im using it.'
23
33
  else
@@ -27,7 +37,7 @@ module Checker
27
37
  if Dir.exist?(todos)
28
38
  puts 'Created new directory...'
29
39
  else
30
- fail('Cant create directory')
40
+ raise('Cant create directory')
31
41
  end
32
42
  end
33
43
  end
@@ -42,7 +52,7 @@ module Checker
42
52
  if Dir.exist?(title)
43
53
  puts 'Creating documentation was a success...'
44
54
  else
45
- fail('Cant create documentation. Please try it manual with publican...')
55
+ raise('Cant create documentation. Please try it manual with publican...')
46
56
  end
47
57
  end
48
58
  end
@@ -1,14 +1,21 @@
1
- # Create Module for PublicanCreators
2
- # PublicanCreatorsChange
3
- # @author Sascha Manns
4
- # @abstract Class for all file changes
1
+ # Copyright (C) 2013-2020 Sascha Manns <Sascha.Manns@outlook.de>
5
2
  #
6
- # Copyright (C) 2015-2017 Sascha Manns <Sascha.Manns@mailbox.org>
7
- # License: MIT
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/>.
8
15
 
9
16
  # Dependencies
10
17
  require 'nokogiri'
11
- require 'publican_creators/checker'
18
+ require_relative 'checker'
12
19
 
13
20
  # Class for creating stuff
14
21
  class PublicanCreatorsCreate
@@ -51,6 +58,7 @@ class PublicanCreatorsCreate
51
58
  # the name or title of your work. It is used in all
52
59
  # important code places.
53
60
  # @param [String] type represents the Document-Type like Article or Book.
61
+ # @param [String] homework can be true or false
54
62
  # @param [String] brand_private is used in all methods with a "private" in the
55
63
  # name. If this brand is set it will be used instead of
56
64
  # the original publican brand.
@@ -65,8 +73,7 @@ class PublicanCreatorsCreate
65
73
  # the method it starts another method "PublicanCreatorsChange.check_result".
66
74
  # This method checks if the directory with the content of the parameter title
67
75
  # is available.
68
- def self.init_docu_private(title, type, homework, language, brand_homework,
69
- brand_private, db5)
76
+ def self.init_docu_private(title, type, homework, language, brand_homework, brand_private, db5)
70
77
  puts 'Creating initial documentation ...'
71
78
 
72
79
  if type == 'Article'
@@ -95,8 +102,7 @@ class PublicanCreatorsCreate
95
102
  # @param [String] brand_homework can be a special customized brand for
96
103
  # distance learning schools.
97
104
  # @param [String] homework true if homework set
98
- def self.private_article(language, title, brand_private, brand_homework,
99
- homework)
105
+ def self.private_article(language, title, brand_private, brand_homework, homework)
100
106
  # @note Initial creation of documentation with publican
101
107
  string = "--type Article --lang #{language} --name #{title}"
102
108
  # Use brand_private if brand_private is set
@@ -1,17 +1,23 @@
1
- # PublicanCreatorsExport
2
- # @author Sascha Manns
3
- # @abstract Class for exporting bash scripts
1
+ # Copyright (C) 2013-2020 Sascha Manns <Sascha.Manns@outlook.de>
4
2
  #
5
- # Copyright (C) 2015-2017 Sascha Manns <Sascha.Manns@mailbox.org>
6
- # License: MIT
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/>.
7
15
 
8
16
  # Dependencies
9
17
 
10
- require 'publican_creators/change'
18
+ require_relative 'change'
11
19
  require 'fileutils'
12
20
  require 'rainbow/ext/string'
13
-
14
- # rubocop:disable Metrics/MethodLength
15
21
  # Module for running exports to a file
16
22
  module PublicanCreatorsExport
17
23
  # Exports a predefined Shellscript to the target directory.
@@ -29,9 +35,9 @@ module PublicanCreatorsExport
29
35
  # @return [String] true or false
30
36
  def self.export_buildscript(title, builds, language, xfc_brand_dir, pdfview)
31
37
  puts 'Export the buildscript into new directory...'
32
- FileUtils.touch "#{builds}"
33
- # rubocop:disable Metrics/LineLength
34
- File.write "#{builds}", <<EOF
38
+ FileUtils.touch builds.to_s
39
+ # rubocop:disable Layout/IndentHeredoc
40
+ File.write builds.to_s, <<BUILDSCRIPT
35
41
  # -*- ruby -*-
36
42
  # encoding: utf-8
37
43
  require 'fileutils'
@@ -225,6 +231,6 @@ desc 'Run convert to all formats'
225
231
  task :export_all => [:export_most, :export_wml, :export_man, :export_txt, :export_epub, :export_eclipse] do
226
232
  puts 'Successfull exported to all formats'
227
233
  end
228
- EOF
234
+ BUILDSCRIPT
229
235
  end
230
236
  end