Class: Gloo::App::Settings
- Inherits:
-
Object
- Object
- Gloo::App::Settings
- Defined in:
- lib/gloo/app/settings.rb
Constant Summary collapse
- DEFAULT_THEME =
'dark'.freeze
- THEMES =
%w[dark light].freeze
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.
-
#ext_path ⇒ Object
readonly
Returns the value of attribute ext_path.
-
#list_indent ⇒ Object
readonly
Returns the value of attribute list_indent.
-
#list_levels ⇒ Object
readonly
Returns the value of attribute list_levels.
-
#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.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
-
#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(engine) ⇒ Object
Get the number of horizontal columns on screen.
-
.lines(engine) ⇒ Object
Get the number of vertical lines on screen.
-
.page_size(engine) ⇒ Object
Get the default page size.
-
.preview_lines ⇒ Object
How many lines should we use for a preview?.
Instance Method Summary collapse
-
#initialize(engine, root = nil) ⇒ Settings
constructor
Load setting from the yml file.
-
#override_project_path(path) ⇒ Object
Running in app mode, so overriding the root project path.
-
#show ⇒ Object
Show the current application settings.
-
#show_paths ⇒ Object
Show path settings.
Constructor Details
#initialize(engine, root = nil) ⇒ Settings
Load setting from the yml file. The mode parameter is used to determine if we are running in TEST.
25 26 27 28 29 30 31 32 |
# File 'lib/gloo/app/settings.rb', line 25 def initialize( engine, root=nil ) @engine = engine # @mode = mode init_root( root ) init_path_settings init_user_settings end |
Instance Attribute Details
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
16 17 18 |
# File 'lib/gloo/app/settings.rb', line 16 def config_path @config_path end |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
16 17 18 |
# File 'lib/gloo/app/settings.rb', line 16 def debug @debug end |
#debug_path ⇒ Object (readonly)
Returns the value of attribute debug_path.
16 17 18 |
# File 'lib/gloo/app/settings.rb', line 16 def debug_path @debug_path end |
#ext_path ⇒ Object (readonly)
Returns the value of attribute ext_path.
16 17 18 |
# File 'lib/gloo/app/settings.rb', line 16 def ext_path @ext_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 |
#list_levels ⇒ Object (readonly)
Returns the value of attribute list_levels.
16 17 18 |
# File 'lib/gloo/app/settings.rb', line 16 def list_levels @list_levels end |
#log_path ⇒ Object (readonly)
Returns the value of attribute log_path.
16 17 18 |
# File 'lib/gloo/app/settings.rb', line 16 def log_path @log_path end |
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
16 17 18 |
# File 'lib/gloo/app/settings.rb', line 16 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 |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
16 17 18 |
# File 'lib/gloo/app/settings.rb', line 16 def theme @theme 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.
16 17 18 |
# File 'lib/gloo/app/settings.rb', line 16 def user_root @user_root end |
Class Method Details
.cols(engine) ⇒ Object
Get the number of horizontal columns on screen.
75 76 77 |
# File 'lib/gloo/app/settings.rb', line 75 def self.cols engine engine.platform.cols end |
.lines(engine) ⇒ Object
Get the number of vertical lines on screen.
68 69 70 |
# File 'lib/gloo/app/settings.rb', line 68 def self.lines engine engine.platform.lines end |
.page_size(engine) ⇒ Object
Get the default page size. This is the number of lines of text we can show.
83 84 85 |
# File 'lib/gloo/app/settings.rb', line 83 def self.page_size engine Settings.lines( engine ) - 3 end |
.preview_lines ⇒ Object
How many lines should we use for a preview?
90 91 92 |
# File 'lib/gloo/app/settings.rb', line 90 def self.preview_lines return 7 end |
Instance Method Details
#override_project_path(path) ⇒ Object
Running in app mode, so overriding the root project path.
101 102 103 104 105 |
# File 'lib/gloo/app/settings.rb', line 101 def override_project_path path @engine.log.debug "Root project path is #{path}" @project_path = path end |
#show ⇒ Object
Show the current application settings. Can be seen in app with 'help settings'
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/gloo/app/settings.rb', line 38 def show theme = @engine.theme puts theme.heading( "\n Application Settings:" ) puts theme.accent( ' Startup with: ' ) + theme.emphasis( @start_with.to_s ) puts theme.accent( ' Indent in Listing: ' ) + theme.emphasis( @list_indent.to_s ) puts theme.accent( ' List Levels: ' ) + theme.emphasis( @list_levels.to_s ) puts theme.accent( ' Debug? ' ) + theme.emphasis( @debug.to_s ) puts theme.accent( ' Theme: ' ) + theme.emphasis( @theme ) puts theme.accent( ' Screen Lines: ' ) + theme.emphasis( Gloo::App::Settings.lines( @engine ).to_s ) puts theme.accent( ' Page Size: ' ) + theme.emphasis( Gloo::App::Settings.page_size( @engine ).to_s ) self.show_paths end |
#show_paths ⇒ Object
Show path settings
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/gloo/app/settings.rb', line 54 def show_paths theme = @engine.theme puts theme.heading( "\n Application Paths:" ) puts theme.accent( ' User Root Path is here: ' ) + theme.emphasis( @user_root ) puts theme.accent( ' Projects Path: ' ) + theme.emphasis( @project_path ) puts theme.accent( ' Extensions Path: ' ) + theme.emphasis( @ext_path ) puts theme.accent( ' Tmp Path: ' ) + theme.emphasis( @tmp_path ) puts theme.accent( ' Debug Path: ' ) + theme.emphasis( @debug_path ) puts "\n" end |