Sha256: ba5486e40d05df607c3b0f495f3e58e59b6fddcd894180f96c55f9951df56a83

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

require 'singleton'

# This Singleton contains application params
class Application
  include Singleton

  VERSION = '2.1.9' # Application version
  NAME = 'teuton' # Application name

  attr_reader   :letter
  attr_reader   :running_basedir, :output_basedir
  attr_reader   :default
  attr_accessor :options
  attr_accessor :verbose
  attr_accessor :global # Global configuration params
  attr_accessor :ialias # Internal alias
  attr_accessor :macros # Array of macros
  attr_accessor :groups # Array of groups
  attr_accessor :uses # Array of uses
  attr_accessor :hall_of_fame
  attr_accessor :project_path, :script_path, :config_path, :test_name

  ##
  # Initialize Application instance
  def initialize
    reset
  end

  ##
  # Reset param values
  # rubocop:disable Metrics/MethodLength
  def reset
    @letter = { good: '.', bad: 'F', error: '?', none: ' ' }
    @running_basedir = Dir.getwd
    @output_basedir = 'var'
    @default = { name: 'teuton', format: :txt, debug: false }
    @options = { 'lang' => 'en' }
    @verbose = true

    @global = {}
    @ialias = {}
    @macros = {}
    @groups = []
    @uses = [] # TODO
    @hall_of_fame = []
  end
  # rubocop:enable Metrics/MethodLength

  ##
  # Return debug param
  # @return Boolean
  def debug
    @default[:debug]
  end

  ##
  # Return name param
  # @return String
  def name
    @default[:name]
  end

  ##
  # Return quiet param
  # @return Boolean
  def quiet?
    return true if Application.instance.options['quiet']
    return true unless Application.instance.verbose

    false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
teuton-2.1.9 lib/teuton/application.rb