Sha256: 36e593d778076dfde98ae19da5d2bc7c0c39517a2f478b67543ad285e8afa385

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require 'singleton'
require 'inifile'
require 'rainbow'
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)
    filename = File.join(File.dirname(__FILE__),
                         'files',
                          Asker::CONFIGFILE) unless File.exist? filename

    begin
      @config = IniFile.load(filename)
    rescue StandardError => e
      puts e.display
      puts Rainbow('[ERROR] Revise configuration file:').red.bright
      puts Rainbow("        #{filename}").red.bright
      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')
    # require 'debug'; binding.break

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
asker-tool-2.5.4 lib/asker/application.rb
asker-tool-2.5.3 lib/asker/application.rb
asker-tool-2.5.2 lib/asker/application.rb
asker-tool-2.5.1 lib/asker/application.rb
asker-tool-2.5.0 lib/asker/application.rb
asker-tool-2.4.5 lib/asker/application.rb
asker-tool-2.4.4 lib/asker/application.rb
asker-tool-2.4.3 lib/asker/application.rb
asker-tool-2.4.2 lib/asker/application.rb