Class: Gloo::App::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/gloo/app/settings.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode) ⇒ Settings

Load setting from the yml file. The mode parameter is used to determine if we are running in TEST.



23
24
25
26
27
28
# File 'lib/gloo/app/settings.rb', line 23

def initialize( mode )
  @mode = mode
  init_root
  init_path_settings
  
end

Instance Attribute Details

#config_pathObject (readonly)

Returns the value of attribute config_path.



15
16
17
# File 'lib/gloo/app/settings.rb', line 15

def config_path
  @config_path
end

#debugObject (readonly)

Returns the value of attribute debug.



17
18
19
# File 'lib/gloo/app/settings.rb', line 17

def debug
  @debug
end

#debug_pathObject (readonly)

Returns the value of attribute debug_path.



17
18
19
# File 'lib/gloo/app/settings.rb', line 17

def debug_path
  @debug_path
end

#list_indentObject (readonly)

Returns the value of attribute list_indent.



16
17
18
# File 'lib/gloo/app/settings.rb', line 16

def list_indent
  @list_indent
end

#log_pathObject (readonly)

Returns the value of attribute log_path.



15
16
17
# File 'lib/gloo/app/settings.rb', line 15

def log_path
  @log_path
end

#project_pathObject (readonly)

Returns the value of attribute project_path.



15
16
17
# File 'lib/gloo/app/settings.rb', line 15

def project_path
  @project_path
end

#start_withObject (readonly)

Returns the value of attribute start_with.



16
17
18
# File 'lib/gloo/app/settings.rb', line 16

def start_with
  @start_with
end

#tmp_pathObject (readonly)

Returns the value of attribute tmp_path.



16
17
18
# File 'lib/gloo/app/settings.rb', line 16

def tmp_path
  @tmp_path
end

#user_rootObject (readonly)

Returns the value of attribute user_root.



15
16
17
# File 'lib/gloo/app/settings.rb', line 15

def user_root
  @user_root
end

Class Method Details

.colsObject

Get the number of horizontal columns on screen.



81
82
83
# File 'lib/gloo/app/settings.rb', line 81

def self.cols
  TTY::Screen.cols
end

.linesObject

Get the number of vertical lines on screen.



74
75
76
# File 'lib/gloo/app/settings.rb', line 74

def self.lines
  TTY::Screen.rows
end

.page_sizeObject

Get the default page size. This is the number of lines of text we can show.



89
90
91
# File 'lib/gloo/app/settings.rb', line 89

def self.page_size
  Settings.lines - 3
end

.preview_linesObject

How many lines should we use for a preview?



96
97
98
# File 'lib/gloo/app/settings.rb', line 96

def self.preview_lines
  return 7
end

Instance Method Details

#in_test_mode?Boolean

Are we in test mode?

Returns:

  • (Boolean)


33
34
35
# File 'lib/gloo/app/settings.rb', line 33

def in_test_mode?
  return @mode == 'TEST'
end

#project_path_for_mode(settings) ⇒ Object

Get the project path for the current mode.



40
41
42
43
44
# File 'lib/gloo/app/settings.rb', line 40

def project_path_for_mode( settings )
  return File.join( @user_root, 'projects' ) if in_test_mode?

  return settings[ 'gloo' ][ 'project_path' ]
end

#showObject

Show the current application settings. Can be seen in app with ‘help settings’



50
51
52
53
54
55
56
57
58
59
# File 'lib/gloo/app/settings.rb', line 50

def show
  puts "\nApplication Settings:".blue
  puts '  Startup with:  '.yellow + @start_with.white
  puts '  Indent in Listing:  '.yellow + @list_indent.to_s.white
  puts '  Screen Lines:  '.yellow + Gloo::App::Settings.lines.to_s.white
  puts '  Page Size:  '.yellow + Gloo::App::Settings.page_size.to_s.white
  puts ''
  self.show_paths
  puts ''
end

#show_pathsObject

Show path settings



64
65
66
67
68
69
# File 'lib/gloo/app/settings.rb', line 64

def show_paths
  puts '  User Root Path is here:  '.yellow + @user_root.white
  puts '  Projects Path:  '.yellow + @project_path.white
  puts '  Tmp Path:  '.yellow + @tmp_path.white
  puts '  Debug Path:  '.yellow + @debug_path.white
end