Class: Application

Inherits:
Object
  • Object
show all
Includes:
Singleton, Teuton
Defined in:
lib/teuton/application.rb

Overview

This Singleton contains application params

Constant Summary

Constants included from Teuton

Teuton::APPNAME, Teuton::DOCKERNAME, Teuton::GEMNAME, Teuton::HOMEPAGE, Teuton::VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Teuton

check, create, readme, run

Constructor Details

#initializeApplication

Initialize Application instance



27
28
29
# File 'lib/teuton/application.rb', line 27

def initialize
  reset
end

Instance Attribute Details

#config_pathObject

Returns the value of attribute config_path.



23
24
25
# File 'lib/teuton/application.rb', line 23

def config_path
  @config_path
end

#defaultObject (readonly)

Returns the value of attribute default.



14
15
16
# File 'lib/teuton/application.rb', line 14

def default
  @default
end

#globalObject

Global configuration params



17
18
19
# File 'lib/teuton/application.rb', line 17

def global
  @global
end

#groupsObject

Array of groups



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

def groups
  @groups
end

#hall_of_fameObject

Returns the value of attribute hall_of_fame.



22
23
24
# File 'lib/teuton/application.rb', line 22

def hall_of_fame
  @hall_of_fame
end

#ialiasObject

Internal alias



18
19
20
# File 'lib/teuton/application.rb', line 18

def ialias
  @ialias
end

#letterObject (readonly)

Returns the value of attribute letter.



12
13
14
# File 'lib/teuton/application.rb', line 12

def letter
  @letter
end

#macrosObject

Array of macros



19
20
21
# File 'lib/teuton/application.rb', line 19

def macros
  @macros
end

#optionsObject

Returns the value of attribute options.



15
16
17
# File 'lib/teuton/application.rb', line 15

def options
  @options
end

#output_basedirObject (readonly)

Returns the value of attribute output_basedir.



13
14
15
# File 'lib/teuton/application.rb', line 13

def output_basedir
  @output_basedir
end

#project_pathObject

Returns the value of attribute project_path.



23
24
25
# File 'lib/teuton/application.rb', line 23

def project_path
  @project_path
end

#running_basedirObject (readonly)

Returns the value of attribute running_basedir.



13
14
15
# File 'lib/teuton/application.rb', line 13

def running_basedir
  @running_basedir
end

#script_pathObject

Returns the value of attribute script_path.



23
24
25
# File 'lib/teuton/application.rb', line 23

def script_path
  @script_path
end

#test_nameObject

Returns the value of attribute test_name.



23
24
25
# File 'lib/teuton/application.rb', line 23

def test_name
  @test_name
end

#usesObject

Array of uses



21
22
23
# File 'lib/teuton/application.rb', line 21

def uses
  @uses
end

#verboseObject

Returns the value of attribute verbose.



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

def verbose
  @verbose
end

Instance Method Details

#add_input_params(projectpath, options) ⇒ Object

Preprocess input options:

  • Convert input case options String to an Array of integers

  • Read color input option

rubocop:disable Metrics/AbcSize



80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/teuton/application.rb', line 80

def add_input_params(projectpath, options)
  @options.merge! options
  NameFileFinder.find_filenames_for(projectpath)
  @options['color'] = true if @options['color'].nil?
  Rainbow.enabled = @options['color']
  @options['panel'] = false if @options['panel'].nil?

  return if @options['case'].nil?

  a = @options['case'].split(',')
  @options['case'] = a.collect!(&:to_i)
end

#debugObject

Return debug param

Returns:

  • Boolean



54
55
56
# File 'lib/teuton/application.rb', line 54

def debug
  @default[:debug]
end

#nameObject

Return name param

Returns:

  • String



61
62
63
# File 'lib/teuton/application.rb', line 61

def name
  @default[:name]
end

#quiet?Boolean

Return quiet param

Returns:

  • (Boolean)

    Boolean



68
69
70
71
72
73
# File 'lib/teuton/application.rb', line 68

def quiet?
  return true if Application.instance.options['quiet']
  return true unless Application.instance.verbose

  false
end

#resetObject

Reset param values rubocop:disable Metrics/MethodLength



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/teuton/application.rb', line 34

def reset
  @letter = { good: '.', bad: 'F', error: '?', none: ' ' }
  @running_basedir = Dir.getwd
  @output_basedir = 'var'
  @default = { name: 'teuton', format: :txt, debug: false }
  @options = { 'lang' => 'en' }
  @verbose = true

  @global = {}
  @ialias = {}
  @macros = {}
  @groups = []
  @uses = [] # TODO
  @hall_of_fame = []
end