1
|
|
|
# Create Module for PublicanCreators |
2
|
|
|
# PublicanCreatorsChange |
3
|
|
|
# @author Sascha Manns |
4
|
|
|
# @abstract Class for all file changes |
5
|
|
|
# |
6
|
|
|
# Copyright (C) 2015-2017 Sascha Manns <[email protected]> |
7
|
|
|
# License: MIT |
8
|
|
|
|
9
|
|
|
# Dependencies |
10
|
|
|
require 'nokogiri' |
11
|
|
|
require 'publican_creators/checker' |
12
|
|
|
|
13
|
|
|
# Class for creating stuff |
14
|
|
|
class PublicanCreatorsCreate |
15
|
|
|
# Method for creating initial documentation for work. It asks for title, type, |
16
|
|
|
# language, brand and db5 variable, creates a launch-string from them and |
17
|
|
|
# launches publican. |
18
|
|
|
# @param [String] title comes from the get method. This @param represents the |
19
|
|
|
# name or title of your work. It is used in all important code |
20
|
|
|
# places. |
21
|
|
|
# @param [String] type represents the Document-Type like Article or Book. |
22
|
|
|
# @param [String] language is just the ISO Code of your target language like: |
23
|
|
|
# de-DE, en-GB or such things. |
24
|
|
|
# @param [String] brand can be a special customized brand for your company to |
25
|
|
|
# fit the styleguide. |
26
|
|
|
# @param [String] db5 just sets your preferences. If you like to have DocBook |
27
|
|
|
# 5.x as default you can set it there. |
28
|
|
|
# @return [String] true or false |
29
|
|
|
# @note That method returns just a success or a fail. After the main part of |
30
|
|
|
# the method it starts another method "PublicanCreatorsChange.check_result". |
31
|
|
|
# This method checks if the directory with the content of the parameter title |
32
|
|
|
# is available. |
33
|
|
|
def self.init_docu_work(title, type, language, brand, db5) |
34
|
|
|
puts 'Creating initial documentation ...' |
35
|
|
|
# Set standard string |
36
|
|
|
string = "--lang #{language} --name #{title}" |
37
|
|
|
# Add Article if type is Article |
38
|
|
|
string << ' --type Article' if type == 'Article' |
39
|
|
|
# Set business brand if given |
40
|
|
|
string << " --brand #{brand}" if brand != '' |
41
|
|
|
# @note Check if DocBook 5 wished as default, if yes it adds the parameter |
42
|
|
|
# dtdver 5.0 to string |
43
|
|
|
string << ' --dtdver 5.0' if db5 == 'true' |
44
|
|
|
create_docu(string, title) |
45
|
|
|
end |
46
|
|
|
|
47
|
|
|
# Method for creating initial documentation for private. It asks for title, |
48
|
|
|
# type, language, homework, brand_homework, brand_private |
49
|
|
|
# and db5 variable, creates a launch-string from them and launches publican. |
50
|
|
|
# @param [String] title comes from the get method. This parameter represents |
51
|
|
|
# the name or title of your work. It is used in all |
52
|
|
|
# important code places. |
53
|
|
|
# @param [String] type represents the Document-Type like Article or Book. |
54
|
|
|
# @param [String] brand_private is used in all methods with a "private" in the |
55
|
|
|
# name. If this brand is set it will be used instead of |
56
|
|
|
# the original publican brand. |
57
|
|
|
# @param [String] language is just the ISO Code of your target language like: |
58
|
|
|
# de-DE, en-GB or such things. |
59
|
|
|
# @param [String] brand_homework can be a special customized brand for |
60
|
|
|
# distance learning schools. |
61
|
|
|
# @param [String] db5 just sets your preferences. If you like to have DocBook |
62
|
|
|
# 5.x as default you can set it there. |
63
|
|
|
# @return [String] true or false |
64
|
|
|
# @note That method returns just a success or a fail. After the main part of |
65
|
|
|
# the method it starts another method "PublicanCreatorsChange.check_result". |
66
|
|
|
# This method checks if the directory with the content of the parameter title |
67
|
|
|
# is available. |
68
|
|
|
def self.init_docu_private(title, type, homework, language, brand_homework, |
69
|
|
|
brand_private, db5) |
70
|
|
|
puts 'Creating initial documentation ...' |
71
|
|
|
|
72
|
|
|
if type == 'Article' |
73
|
|
|
string = private_article(language, title, brand_private, |
74
|
|
|
brand_homework, homework) |
75
|
|
|
else |
76
|
|
|
# @note Initial creation of documentation with publican |
77
|
|
|
string = "--lang #{language} --name #{title}" |
78
|
|
|
string << " --brand #{brand_private}" if brand_private != '' |
79
|
|
|
end |
80
|
|
|
# @note Check if DocBook 5 wished as default, if yes it adds the parameter |
81
|
|
|
# dtdver 5.0 to string |
82
|
|
|
string << ' --dtdver 5.0' if db5 == 'true' |
83
|
|
|
create_docu(string, title) |
84
|
|
|
end |
85
|
|
|
|
86
|
|
|
# Method for preparing the string for private articles |
87
|
|
|
# @param [String] language is just the ISO Code of your target language like: |
88
|
|
|
# de-DE, en-GB or such things. |
89
|
|
|
# @param [String] title comes from the get method. This parameter represents |
90
|
|
|
# the name or title of your work. It is used in all |
91
|
|
|
# important code places. |
92
|
|
|
# @param [String] brand_private is used in all methods with a "private" in the |
93
|
|
|
# name. If this brand is set it will be used instead of |
94
|
|
|
# the original publican brand. |
95
|
|
|
# @param [String] brand_homework can be a special customized brand for |
96
|
|
|
# distance learning schools. |
97
|
|
|
# @param [String] homework true if homework set |
98
|
|
|
def self.private_article(language, title, brand_private, brand_homework, |
99
|
|
|
homework) |
100
|
|
|
# @note Initial creation of documentation with publican |
101
|
|
|
string = "--type Article --lang #{language} --name #{title}" |
102
|
|
|
# Use brand_private if brand_private is set |
103
|
|
|
if brand_private != '' && homework == 'FALSE' |
104
|
|
|
string << " --brand #{brand_private}" |
105
|
|
|
end |
106
|
|
|
# Use brand_homework if its set |
107
|
|
|
if brand_homework != '' && homework == 'TRUE' |
108
|
|
|
string << " --brand #{brand_homework}" |
109
|
|
|
end |
110
|
|
|
return string |
111
|
|
|
end |
112
|
|
|
|
113
|
|
|
# This method uses the input of init_docu methods to create the documentation |
114
|
|
|
# @param [String] string This input comes from init_docu |
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 |
117
|
|
|
# code places. |
118
|
|
|
# @return [String] true or false |
119
|
|
|
def self.create_docu(string, title) |
120
|
|
|
system("publican create #{string}") |
121
|
|
|
# @param [String] title comes from the get method. This param represents |
122
|
|
|
# the name or title of your work. It is used in all important code places. |
123
|
|
|
Checker.check_result(title) |
124
|
|
|
end |
125
|
|
|
end |
126
|
|
|
|