Class: Gloo::App::Settings
- Inherits:
-
Object
- Object
- Gloo::App::Settings
- Defined in:
- lib/gloo/app/settings.rb
Instance Attribute Summary collapse
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#debug_path ⇒ Object
readonly
Returns the value of attribute debug_path.
-
#list_indent ⇒ Object
readonly
Returns the value of attribute list_indent.
-
#log_path ⇒ Object
readonly
Returns the value of attribute log_path.
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
-
#start_with ⇒ Object
readonly
Returns the value of attribute start_with.
-
#tmp_path ⇒ Object
readonly
Returns the value of attribute tmp_path.
-
#user_root ⇒ Object
readonly
Returns the value of attribute user_root.
Class Method Summary collapse
-
.cols ⇒ Object
Get the number of horizontal columns on screen.
-
.lines ⇒ Object
Get the number of vertical lines on screen.
-
.page_size ⇒ Object
Get the default page size.
-
.preview_lines ⇒ Object
How many lines should we use for a preview?.
Instance Method Summary collapse
-
#in_test_mode? ⇒ Boolean
Are we in test mode?.
-
#initialize(mode) ⇒ Settings
constructor
Load setting from the yml file.
-
#project_path_for_mode(settings) ⇒ Object
Get the project path for the current mode.
-
#show ⇒ Object
Show the current application settings.
-
#show_paths ⇒ Object
Show path settings.
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 init_user_settings end |
Instance Attribute Details
#config_path ⇒ Object (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 |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
17 18 19 |
# File 'lib/gloo/app/settings.rb', line 17 def debug @debug end |
#debug_path ⇒ Object (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_indent ⇒ Object (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_path ⇒ Object (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_path ⇒ Object (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_with ⇒ Object (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_path ⇒ Object (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_root ⇒ Object (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
.cols ⇒ Object
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 |
.lines ⇒ Object
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_size ⇒ Object
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_lines ⇒ Object
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?
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 |
#show ⇒ Object
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_paths ⇒ Object
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 |