module Checker

Module for different checks

Public Class Methods

check_dir(todos) click to toggle source

Checks if the targetdirectory are present. If not, it creates one. It returns a success or fail. @param [String] todos contains the target directory @return [String] true or false

# 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) click to toggle source

This method will be launched from the init_docu_* methods. It returns a success, otherwise it raises with a error. @param [String] title comes from the get method. This @param represents the name or title of your work. It is used in all important code places. @return [String] true or false

# 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