Class: Application
- Inherits:
-
Object
- Object
- Application
- Includes:
- Singleton
- Defined in:
- lib/asker/application.rb
Overview
Global parameters
Constant Summary collapse
- VERSION =
Application version
'2.1.6'
- NAME =
Application name
'asker'
- GEM =
Gem name
'asker-tool'
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize ⇒ Application
constructor
Initialize Application singleton.
-
#reset ⇒ Object
Initialize config values from external “config.ini” file.
Constructor Details
#initialize ⇒ Application
Initialize Application singleton
18 19 20 |
# File 'lib/asker/application.rb', line 18 def initialize reset end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
14 15 16 |
# File 'lib/asker/application.rb', line 14 def config @config end |
Instance Method Details
#reset ⇒ Object
Initialize config values from external “config.ini” file. rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/asker/application.rb', line 26 def reset filename = File.join(Dir.pwd, 'config.ini') unless File.exist? filename filename = File.join(File.dirname(__FILE__), 'files', 'config.ini') end 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 |