Sha256: 76185168145cb630433d336231c6eff617721aeacf4a9b78472a264554d479b0

Contents?: true

Size: 1.72 KB

Versions: 4

Compression:

Stored size: 1.72 KB

Contents

require "singleton"
require_relative "name_file_finder"

class Application
  include Singleton

  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 :uses # Array of uses
  attr_accessor :project_path, :script_path, :config_path, :test_name

  def initialize
    reset
  end

  def reset
    @letter = {
      good: ".",
      bad: "F",
      error: "?",
      none: " ",
      ok: "\u{2714}",
      cross: "\u{2716}"
    }
    @running_basedir = Dir.getwd
    @output_basedir = "var"
    @default = {name: "teuton", format: :txt, debug: false}
    @options = {
      "lang" => "en",
      "color" => true,
      "panel" => false
    }
    @verbose = true

    @global = {}
    @ialias = {}
    @uses = [] # TODO
  end

  def debug
    @default[:debug]
  end

  def name
    @default[:name]
  end

  def quiet?
    return true if Application.instance.options["quiet"]
    return true unless Application.instance.verbose

    false
  end

  ##
  # Preprocess input options:
  # * Convert input case options String to an Array of integers
  # * Read color input option
  def add_input_params(projectpath, options)
    @options.merge! options
    Rainbow.enabled = @options["color"]

    finder = NameFileFinder.new(@options)
    finder.find_filenames_for(projectpath)
    @project_path = finder.project_path
    @script_path = finder.script_path
    @config_path = finder.config_path
    @test_name = finder.test_name

    unless @options["case"].nil?
      numbers = @options["case"].split(",")
      @options["case"] = numbers.collect!(&:to_i)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
teuton-2.9.2 lib/teuton/deprecated/application.rb
teuton-2.9.1 lib/teuton/deprecated/application.rb
teuton-2.9.0 lib/teuton/deprecated/application.rb
teuton-2.8.0 lib/teuton/utils/application.rb