Sha256: df5ee5f801bda3a1aefd28344c1ec9291a85f733567e1a176ab876f939f71c82

Contents?: true

Size: 949 Bytes

Versions: 3

Compression:

Stored size: 949 Bytes

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,
                         Version::CONFIGFILE)
    filename = File.join(File.dirname(__FILE__),
                         'files',
                          Version::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)
    Rainbow.enabled = false
    Rainbow.enabled = true if @config['global']['color'].downcase == 'yes'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
asker-tool-2.2.5 lib/asker/application.rb
asker-tool-2.2.4 lib/asker/application.rb
asker-tool-2.2.3 lib/asker/application.rb