publican_creators 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,17 @@
1
- # PublicanCreatorsChecker
2
- # @author Sascha Manns
3
- # @abstract Class for checking directories and creating them
1
+ # Copyright (C) 2013-2017 Sascha Manns <Sascha.Manns@mailbox.org>
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-2017 Sascha Manns <Sascha.Manns@mailbox.org>
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-2017 Sascha Manns <Sascha.Manns@mailbox.org>
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
@@ -1,13 +1,22 @@
1
- # PublicanCreatorsGet
2
- # @author Sascha Manns
3
- # @abstract Class for gathering information from config file and user input
1
+ # Copyright (C) 2013-2017 Sascha Manns <Sascha.Manns@mailbox.org>
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
18
  require 'parseconfig'
19
+ require 'xdg'
11
20
 
12
21
  # This method provides methods for user inputs
13
22
  module PublicanCreatorsGet
@@ -21,14 +30,14 @@ module PublicanCreatorsGet
21
30
  --field="Type:CBE" --field="Optional:CBE" --field="Enter a title name \
22
31
  (with underscores instead of blanks and without umlauts):TEXT" \
23
32
  --field="Please file bugs or feature requests \
24
- on http://saigkill-bugs.myjetbrains.com/youtrack/:LBL" --button="Go!" "Work,Private" \
33
+ on https://bugs.launchpad.net/publicancreators:LBL" --button="Go!" "Work,Private" \
25
34
  "Article,Book" "Normal,Report,Homework"`
26
35
  # @note Format: Work/Private Article/Book title!Normal Report Homework
27
36
  # @note Cleanup the array
28
37
  environment, type, opt, titlefix = titlein.chomp.split('|')
29
38
 
30
39
  # @note replace blanks with underscores
31
- title = titlefix.gsub(/ /, '_')
40
+ title = titlefix.tr(' ', '_')
32
41
 
33
42
  [environment, type, opt, title]
34
43
  end
@@ -58,8 +67,8 @@ entering Revision textes with blanks.:LBL" --button="Go!"`
58
67
  # @return [String] language
59
68
  def self.config_revision
60
69
  include ParseConfig
61
- home = Dir.home
62
- config = ParseConfig.new("#{home}/.publican_creators/publicancreators.cfg")
70
+ sys_xdg = XDG['CONFIG_HOME']
71
+ config = ParseConfig.new("#{sys_xdg}/publican_creators/publicancreators.cfg")
63
72
  language = config['language']
64
73
  puts language
65
74
  end
@@ -1,26 +1,32 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
- # @author Sascha Manns
4
- # @abstract Notifier Module for latex_curriculum_vitae
1
+ # Copyright (C) 2013-2017 Sascha Manns <Sascha.Manns@mailbox.org>
5
2
  #
6
- # Copyright (C) 2015-2016 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
-
11
- # Module for notify the user
12
17
  require 'notifier'
18
+ require 'xdg'
13
19
 
20
+ # Module for notify the user
14
21
  module Notifier
15
22
  def self.run
16
- home = Dir.home
17
- prefix = "#{home}/.rvm/rubies/default"
18
- datadir = "#{prefix}/share"
19
- img = "#{datadir}/.publican_creators/publican.png"
23
+ data_xdg = XDG['DATA_HOME']
24
+ install_path = "#{data_xdg}/icons/"
25
+ img = "#{install_path}/publican.png"
20
26
  Notifier.notify(
21
- :image => "#{img}",
22
- :title => "Your Documentation",
23
- :message => "The preparation of your Documentation is finished."
27
+ image: img.to_s,
28
+ title: 'Your Documentation',
29
+ message: 'The preparation of your Documentation is finished.'
24
30
  )
25
31
  end
26
- end
32
+ end
@@ -1,9 +1,17 @@
1
- # PublicanCreatorsPrepare
2
- # @author Sascha Manns
3
- # @abstract Class for preparing the configuration
1
+ # Copyright (C) 2013-2017 Sascha Manns <Sascha.Manns@mailbox.org>
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
 
@@ -11,6 +19,7 @@
11
19
  # will be used in the make directory function
12
20
  module PublicanCreatorsPrepare
13
21
  # This method sets the needed targetdir depending on the environment
22
+ # @param [String] environment Work or Private
14
23
  # @param [String] type represents the Document-Type like Article or Book.
15
24
  # @param [String] reports_dir_business contains the directory to your reports
16
25
  # @param [String] articles_dir_bus represents the directory for your articles
@@ -27,9 +36,11 @@ module PublicanCreatorsPrepare
27
36
  # books_dir
28
37
  # @return [String] targetdir
29
38
  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)
39
+ articles_dir_bus, books_dir_business, homework,
40
+ articles_dir_private, homework_dir_private, books_dir_private)
32
41
  home = Dir.home
42
+ # TODO: Try to fix this in future
43
+ # rubocop:disable Style/IfInsideElse
33
44
  if environment == 'Work'
34
45
  if type == 'Article'
35
46
  targetdir_work(report, reports_dir_business, articles_dir_bus)
@@ -39,8 +50,7 @@ module PublicanCreatorsPrepare
39
50
  end
40
51
  else
41
52
  if type == 'Article'
42
- targetdir_private(homework, articles_dir_private,
43
- homework_dir_private)
53
+ targetdir_private(homework, articles_dir_private, homework_dir_private)
44
54
  else
45
55
  books_dir = "#{home}/#{books_dir_private}"
46
56
  return books_dir
@@ -49,17 +59,17 @@ module PublicanCreatorsPrepare
49
59
  end
50
60
 
51
61
  # 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
62
  # @param [String] report contains a true or false. There you can set if the
55
63
  # new Publication is a Report or not.
64
+ # @param [String] reports_dir_business contains the directory to your reports
65
+ # @param [String] articles_dir_bus represents the directory for your articles
56
66
  def self.targetdir_work(report, reports_dir_business, articles_dir_bus)
57
67
  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
68
+ articles_dir = if report == 'TRUE'
69
+ "#{home}/#{reports_dir_business}"
70
+ else
71
+ "#{home}/#{articles_dir_bus}"
72
+ end
63
73
  return articles_dir
64
74
  end
65
75
 
@@ -69,14 +79,13 @@ module PublicanCreatorsPrepare
69
79
  # @param [String] articles_dir_private contains the path to your private
70
80
  # articles_dir
71
81
  # @param [String] homework_dir_private contains the path to your homework dir.
72
- def self.targetdir_private(homework, articles_dir_private,
73
- homework_dir_private)
82
+ def self.targetdir_private(homework, articles_dir_private, homework_dir_private)
74
83
  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
84
+ articles_dir = if homework == 'FALSE'
85
+ "#{home}/#{articles_dir_private}"
86
+ else
87
+ "#{home}/#{homework_dir_private}"
88
+ end
80
89
  return articles_dir
81
90
  end
82
91
  end
@@ -1,36 +1,33 @@
1
- # @author Sascha Manns
2
- # @abstract Class RevisionCreator for PublicanCreator
1
+ # Copyright (C) 2013-2017 Sascha Manns <Sascha.Manns@mailbox.org>
3
2
  #
4
- # Copyright (C) 2015-2017 Sascha Manns <Sascha.Manns@mailbox.org>
5
- # 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.
6
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
+
7
16
  # Dependencies
8
17
  require 'fileutils'
9
18
  require 'rainbow/ext/string'
10
- require File.expand_path(File.join(File.dirname(__FILE__), 'change.rb'))
11
- require File.expand_path(File.join(File.dirname(__FILE__), 'get.rb'))
19
+ require_relative 'change'
20
+ require_relative 'get'
12
21
 
13
22
  # A class for creating a revison to a publican project
14
23
  class RevisionCreator
15
24
  # @note Ask for the revision information
16
- null, directory, member1, member2, member3, member4, member5,
17
- revnumber = PublicanCreatorsGet.revision
25
+ # rubocop:disable Layout/UselessAssignment
26
+ null, directory, member1, member2, member3, member4, member5, revnumber = PublicanCreatorsGet.revision
18
27
  language = PublicanCreatorsGet.config_revision
19
28
 
20
29
  revision, edition = revnumber.split('-')
21
30
 
22
- puts "Directory: #{directory}"
23
- puts "Member1: #{member1}"
24
- puts "Member2: #{member2}"
25
- puts "Member3: #{member3}"
26
- puts "Member4: #{member4}"
27
- puts "Member5: #{member5}"
28
- puts "Language: #{language}"
29
- puts "Revnumber: #{revnumber}"
30
- puts "Revision: #{revision}"
31
- puts "Edition: #{edition}"
32
- puts null
33
-
34
31
  # This method prepares the string for adding a new revision
35
32
  # @param [String] member1 is the first string into revdescription
36
33
  # @param [String] member2 is the second string into revdescription
@@ -40,8 +37,7 @@ class RevisionCreator
40
37
  # @param [String] revnumber is the revision number
41
38
  # @param [String] language is the language. Comes from config file.
42
39
  # @return [String] string is that string for creating the commit
43
- def self.prepare_revision(member1, member2, member3, member4, member5,
44
- revnumber, language)
40
+ def self.prepare_revision(member1, member2, member3, member4, member5, revnumber, language)
45
41
  string = "--member \"#{member1}\""
46
42
  string << " --member \"#{member2}\"" if member2 != ''
47
43
  string << " --member \"#{member3}\"" if member3 != ''
@@ -53,8 +49,7 @@ class RevisionCreator
53
49
 
54
50
  # This method changes to the target directory
55
51
  FileUtils.cd(directory) do
56
- string = prepare_revision(member1, member2, member3, member4, member5,
57
- revnumber, language)
52
+ string = prepare_revision(member1, member2, member3, member4, member5, revnumber, language)
58
53
  PublicanCreatorsChange.replace_productnumber(revision, edition, language)
59
54
  system("publican add_revision #{string}")
60
55
  end
@@ -1,10 +1,17 @@
1
- # Testing Module for PublicanCreators
2
- # PublicanCreatorsChange
3
- # @author Sascha Manns
4
- # @abstract Class for all file changes
1
+ # Copyright (C) 2013-2017 Sascha Manns <Sascha.Manns@mailbox.org>
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 'fileutils'