Module: Checker

Defined in:
lib/publican_creators/checker.rb

Overview

Module for different checks

Class Method Summary collapse

Class Method Details

.check_dir(todos) ⇒ String

Checks if the targetdirectory are present. If not, it creates one. It returns a success or fail.

Parameters:

  • todos (String)

    contains the target directory

Returns:

  • (String)

    true or false



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/publican_creators/checker.rb', line 27

def self.check_dir(todos)
  # @note Checking if dir exists
  # TODO: Try to fix this in future
  # rubocop:disable Style/GuardClause
  if Dir.exist?(todos)
    puts 'Found directory. Im using it.'
  else
    puts 'No directory found. Im creating it.'
    # @note Creates the new directory
    FileUtils.mkdir_p(todos)
    if Dir.exist?(todos)
      puts 'Created new directory...'
    else
      raise('Cant create directory')
    end
  end
end

.check_result(title) ⇒ String

This method will be launched from the init_docu_* methods. It returns a success, otherwise it raises with a error. name or title of your work. It is used in all important code places.

Parameters:

  • title (String)

    comes from the get method. This @param represents the

Returns:

  • (String)

    true or false



50
51
52
53
54
55
56
57
# File 'lib/publican_creators/checker.rb', line 50

def self.check_result(title)
  # @note checking if new documentation directory exists
  if Dir.exist?(title)
    puts 'Creating documentation was a success...'
  else
    raise('Cant create documentation. Please try it manual with publican...')
  end
end