1
|
|
|
# PublicanCreatorsPrepare |
2
|
|
|
# @author Sascha Manns |
3
|
|
|
# @abstract Class for preparing the configuration |
4
|
|
|
# |
5
|
|
|
# Copyright (C) 2015-2017 Sascha Manns <[email protected]> |
6
|
|
|
# License: MIT |
7
|
|
|
|
8
|
|
|
# Dependencies |
9
|
|
|
|
10
|
|
|
# The module Prepare contains some methods for preparing the directories. They |
11
|
|
|
# will be used in the make directory function |
12
|
|
|
module PublicanCreatorsPrepare |
13
|
|
|
# This method sets the needed targetdir depending on the environment |
14
|
|
|
# @param [String] type represents the Document-Type like Article or Book. |
15
|
|
|
# @param [String] reports_dir_business contains the directory to your reports |
16
|
|
|
# @param [String] articles_dir_bus represents the directory for your articles |
17
|
|
|
# @param [String] report contains a true or false. There you can set if the |
18
|
|
|
# new Publication is a Report or not. |
19
|
|
|
# @param [String] books_dir_business contains the directory for your business |
20
|
|
|
# books |
21
|
|
|
# @param [String] homework contains true or false. If your present Publication |
22
|
|
|
# is a homework you can set it there. |
23
|
|
|
# @param [String] articles_dir_private contains the path to your private |
24
|
|
|
# articles_dir |
25
|
|
|
# @param [String] homework_dir_private contains the path to your homework dir. |
26
|
|
|
# @param [String] books_dir_private contains the path to your private |
27
|
|
|
# books_dir |
28
|
|
|
# @return [String] targetdir |
29
|
|
|
def self.targetdir(environment, type, report, reports_dir_business, |
30
|
|
|
articles_dir_bus, books_dir_business, homework, |
31
|
|
|
articles_dir_private, homework_dir_private, books_dir_private) |
32
|
|
|
home = Dir.home |
33
|
|
|
if environment == 'Work' |
34
|
|
|
if type == 'Article' |
35
|
|
|
targetdir_work(report, reports_dir_business, articles_dir_bus) |
36
|
|
|
else |
37
|
|
|
books_dir = "#{home}/#{books_dir_business}" |
38
|
|
|
return books_dir |
39
|
|
|
end |
40
|
|
|
else |
41
|
|
|
if type == 'Article' |
42
|
|
|
targetdir_private(homework, articles_dir_private, |
43
|
|
|
homework_dir_private) |
44
|
|
|
else |
45
|
|
|
books_dir = "#{home}/#{books_dir_private}" |
46
|
|
|
return books_dir |
47
|
|
|
end |
48
|
|
|
end |
49
|
|
|
end |
50
|
|
|
|
51
|
|
|
# Prepares the articles_dir for work environment |
52
|
|
|
# @param [String] reports_dir_business contains the directory to your reports |
53
|
|
|
# @param [String] articles_dir_bus represents the directory for your articles |
54
|
|
|
# @param [String] report contains a true or false. There you can set if the |
55
|
|
|
# new Publication is a Report or not. |
56
|
|
View Code Duplication |
def self.targetdir_work(report, reports_dir_business, articles_dir_bus) |
|
|
|
|
57
|
|
|
home = Dir.home |
58
|
|
|
if report == 'TRUE' |
59
|
|
|
articles_dir = "#{home}/#{reports_dir_business}" |
60
|
|
|
else |
61
|
|
|
articles_dir = "#{home}/#{articles_dir_bus}" |
62
|
|
|
end |
63
|
|
|
return articles_dir |
64
|
|
|
end |
65
|
|
|
|
66
|
|
|
# Prepares the articles_dir for home environment |
67
|
|
|
# @param [String] homework contains true or false. If your present Publication |
68
|
|
|
# is a homework you can set it there. |
69
|
|
|
# @param [String] articles_dir_private contains the path to your private |
70
|
|
|
# articles_dir |
71
|
|
|
# @param [String] homework_dir_private contains the path to your homework dir. |
72
|
|
View Code Duplication |
def self.targetdir_private(homework, articles_dir_private, |
|
|
|
|
73
|
|
|
homework_dir_private) |
74
|
|
|
home = Dir.home |
75
|
|
|
if homework == 'FALSE' |
76
|
|
|
articles_dir = "#{home}/#{articles_dir_private}" |
77
|
|
|
else |
78
|
|
|
articles_dir = "#{home}/#{homework_dir_private}" |
79
|
|
|
end |
80
|
|
|
return articles_dir |
81
|
|
|
end |
82
|
|
|
end |
83
|
|
|
|