Class: Application

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/asker/application.rb

Overview

Global parameters

Constant Summary collapse

VERSION =

Application version

'2.2.0'
NAME =

Application name

'asker'
HOMEPAGE =
"https://github.com/dvarrui/#{NAME}/tree/v2.2"
GEM =

Gem name

'asker-tool'
CONFIGFILE =

Config filename

'asker.ini'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplication

Initialize Application singleton



20
21
22
# File 'lib/asker/application.rb', line 20

def initialize
  reset
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



16
17
18
# File 'lib/asker/application.rb', line 16

def config
  @config
end

Instance Method Details

#resetObject

Initialize config values from external “config.ini” file. rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/asker/application.rb', line 28

def reset
  filename = File.join(Dir.pwd, CONFIGFILE)
  filename = File.join(File.dirname(__FILE__), 'files', 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