Module: PublicanCreatorsPrepare

Defined in:
lib/publican_creators/prepare.rb

Overview

The module Prepare contains some methods for preparing the directories. They will be used in the make directory function

Class Method Summary collapse

Class Method Details

.targetdir(environment, type, report, reports_dir_business, articles_dir_bus, books_dir_business, homework, articles_dir_private, homework_dir_private, books_dir_private) ⇒ String

This method sets the needed targetdir depending on the environment

Parameters:

  • environment (String)

    Work or Private

  • type (String)

    represents the Document-Type like Article or Book.

  • reports_dir_business (String)

    contains the directory to your reports

  • articles_dir_bus (String)

    represents the directory for your articles

  • report (String)

    contains a true or false. There you can set if the new Publication is a Report or not.

  • books_dir_business (String)

    contains the directory for your business books

  • homework (String)

    contains true or false. If your present Publication is a homework you can set it there.

  • articles_dir_private (String)

    contains the path to your private articles_dir

  • homework_dir_private (String)

    contains the path to your homework dir.

  • books_dir_private (String)

    contains the path to your private books_dir

Returns:

  • (String)

    targetdir



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/publican_creators/prepare.rb', line 38

def self.targetdir(environment, type, report, reports_dir_business,
                   articles_dir_bus, books_dir_business, homework,
                   articles_dir_private, homework_dir_private, books_dir_private)
  home = Dir.home
  # TODO: Try to fix this in future
  # rubocop:disable Style/IfInsideElse
  if environment == 'Work'
    if type == 'Article'
      targetdir_work(report, reports_dir_business, articles_dir_bus)
    else
      books_dir = "#{home}/#{books_dir_business}"
      return books_dir
    end
  else
    if type == 'Article'
      targetdir_private(homework, articles_dir_private, homework_dir_private)
    else
      books_dir = "#{home}/#{books_dir_private}"
      return books_dir
    end
  end
end

.targetdir_private(homework, articles_dir_private, homework_dir_private) ⇒ Object

Prepares the articles_dir for home environment

Parameters:

  • homework (String)

    contains true or false. If your present Publication is a homework you can set it there.

  • articles_dir_private (String)

    contains the path to your private articles_dir

  • homework_dir_private (String)

    contains the path to your homework dir.



82
83
84
85
86
87
88
89
90
# File 'lib/publican_creators/prepare.rb', line 82

def self.targetdir_private(homework, articles_dir_private, homework_dir_private)
  home = Dir.home
  articles_dir = if homework == 'FALSE'
                   "#{home}/#{articles_dir_private}"
                 else
                   "#{home}/#{homework_dir_private}"
                 end
  return articles_dir
end

.targetdir_work(report, reports_dir_business, articles_dir_bus) ⇒ Object

Prepares the articles_dir for work environment

Parameters:

  • report (String)

    contains a true or false. There you can set if the new Publication is a Report or not.

  • reports_dir_business (String)

    contains the directory to your reports

  • articles_dir_bus (String)

    represents the directory for your articles



66
67
68
69
70
71
72
73
74
# File 'lib/publican_creators/prepare.rb', line 66

def self.targetdir_work(report, reports_dir_business, articles_dir_bus)
  home = Dir.home
  articles_dir = if report == 'TRUE'
                   "#{home}/#{reports_dir_business}"
                 else
                   "#{home}/#{articles_dir_bus}"
                 end
  return articles_dir
end