Sha256: 42e249c63c7803e7b61db3094ac1ae74d6cd94affa19fca10972fafc08d560d0

Contents?: true

Size: 980 Bytes

Versions: 6

Compression:

Stored size: 980 Bytes

Contents

require "singleton"
require "inifile"
require "rainbow"
require_relative "logger"
require_relative "version"

# Global parameters
class Application
  include Singleton
  attr_reader :config

  def initialize
    reset
  end

  def reset
    filename = File.join(Dir.pwd,
      Asker::CONFIGFILE)
    unless File.exist? filename
      filename = File.join(File.dirname(__FILE__),
        "files",
        Asker::CONFIGFILE)
    end

    begin
      @config = IniFile.load(filename)
    rescue => e
      Logger.error e.display
      Logger.error "Application: Revise configuration file (#{filename})"
      exit 1
    end
    stages = @config["questions"]["stages"].split(",")
    @config["questions"]["stages"] = stages.map(&:to_sym)

    fractions = @config["questions"]["fractions"].split(",")
    @config["questions"]["fractions"] = fractions + Array.new(5, "0")

    Rainbow.enabled = false
    Rainbow.enabled = true if @config["global"]["color"].downcase == "yes"
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
asker-tool-2.9.4 lib/asker/application.rb
asker-tool-2.9.3 lib/asker/application.rb
asker-tool-2.9.2 lib/asker/application.rb
asker-tool-2.9.1 lib/asker/application.rb
asker-tool-2.9.0 lib/asker/application.rb
asker-tool-2.8.0 lib/asker/application.rb