Module: Vedeu::Configuration Private
- Extended by:
- Configuration
- Included in:
- Configuration
- Defined in:
- lib/vedeu/configuration/configuration.rb,
lib/vedeu/configuration/api.rb,
lib/vedeu/configuration/cli.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Provides access to Vedeu’s configuration, which was set with sensible defaults (influenced by environment variables), overridden by client application settings (via the configuration API), or any command-line arguments provided.
Defined Under Namespace
Class Method Summary collapse
-
.colour_mode ⇒ Fixnum
private
Returns the chosen colour mode.
-
.configure(args = [], &block) ⇒ Hash
private
Configure Vedeu with sensible defaults.
-
.debug? ⇒ Boolean
(also: #debug)
private
Returns whether debugging is enabled or disabled.
-
.default_system_keys ⇒ Hash
private
Vedeu’s default system keys.
-
.defaults ⇒ Hash
private
private
The Vedeu default options, which of course are influenced by environment variables also.
-
.detect_colour_mode ⇒ Fixnum
private
private
Attempt to determine the terminal colour mode via environment variables, or be optimistic and settle for 256 colours.
-
.detect_debug_mode ⇒ Boolean
private
private
Determine the debug mode via an environment variable.
-
.detect_trace_mode ⇒ Boolean
private
private
Determine the trace mode via an environment variable.
-
.interactive? ⇒ Boolean
(also: #interactive)
private
Returns whether the application is interactive (required user input) or standalone (will run until terminates of natural causes.) Default is true; meaning the application will require user input.
-
.once? ⇒ Boolean
(also: #once)
private
Returns whether the application will run through its main loop once or not.
-
.options ⇒ Hash
private
private
Returns all the options current configured.
-
.reset ⇒ Hash
private
Resets all options to Vedeu defaults.
-
.system_keys ⇒ Hash
private
Returns.
-
.terminal_mode ⇒ Symbol
private
Returns the terminal mode for the application.
-
.trace? ⇒ Boolean
(also: #trace)
private
Returns whether tracing is enabled or disabled.
Instance Method Summary collapse
-
#colour_mode ⇒ Fixnum
private
Returns the chosen colour mode.
-
#configure(args = [], &block) ⇒ Hash
private
Configure Vedeu with sensible defaults.
-
#debug? ⇒ Boolean
(also: #debug)
private
Returns whether debugging is enabled or disabled.
-
#default_system_keys ⇒ Hash
private
Vedeu’s default system keys.
-
#defaults ⇒ Hash
private
private
The Vedeu default options, which of course are influenced by environment variables also.
-
#detect_colour_mode ⇒ Fixnum
private
private
Attempt to determine the terminal colour mode via environment variables, or be optimistic and settle for 256 colours.
-
#detect_debug_mode ⇒ Boolean
private
private
Determine the debug mode via an environment variable.
-
#detect_trace_mode ⇒ Boolean
private
private
Determine the trace mode via an environment variable.
-
#interactive? ⇒ Boolean
(also: #interactive)
private
Returns whether the application is interactive (required user input) or standalone (will run until terminates of natural causes.) Default is true; meaning the application will require user input.
-
#once? ⇒ Boolean
(also: #once)
private
Returns whether the application will run through its main loop once or not.
-
#options ⇒ Hash
private
private
Returns all the options current configured.
-
#reset ⇒ Hash
private
Resets all options to Vedeu defaults.
-
#system_keys ⇒ Hash
private
Returns.
-
#terminal_mode ⇒ Symbol
private
Returns the terminal mode for the application.
-
#trace? ⇒ Boolean
(also: #trace)
private
Returns whether tracing is enabled or disabled.
Class Method Details
.colour_mode ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the chosen colour mode.
35 36 37 |
# File 'lib/vedeu/configuration/configuration.rb', line 35 def colour_mode [:colour_mode] end |
.configure(args = [], &block) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Configure Vedeu with sensible defaults. If the client application sets options, override the defaults with those, and if command-line arguments are provided at application invocation, override any options with the arguments provided.
24 25 26 27 28 29 30 |
# File 'lib/vedeu/configuration/configuration.rb', line 24 def configure(args = [], &block) .merge!(API.configure(&block)) if block_given? .merge!(CLI.configure(args)) if args.any? end |
.debug? ⇒ Boolean Also known as: debug
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether debugging is enabled or disabled. Default is false; meaning nothing apart from warnings are written to the log file.
43 44 45 |
# File 'lib/vedeu/configuration/configuration.rb', line 43 def debug? [:debug] end |
.default_system_keys ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Vedeu’s default system keys. Use #system_keys.
103 104 105 106 107 108 109 110 |
# File 'lib/vedeu/configuration/configuration.rb', line 103 def default_system_keys { exit: 'q', focus_next: :tab, focus_prev: :shift_tab, mode_switch: :escape, } end |
.defaults ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The Vedeu default options, which of course are influenced by environment variables also.
127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/vedeu/configuration/configuration.rb', line 127 def defaults { colour_mode: detect_colour_mode, debug: detect_debug_mode, interactive: true, once: false, system_keys: default_system_keys, terminal_mode: :raw, trace: detect_trace_mode, } end |
.detect_colour_mode ⇒ Fixnum (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Attempt to determine the terminal colour mode via environment variables, or be optimistic and settle for 256 colours.
:nocov:
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/vedeu/configuration/configuration.rb', line 145 def detect_colour_mode return 16777216 if ENV['VEDEU_TESTMODE'] if ENV['VEDEU_TERM'] case ENV['VEDEU_TERM'] when /-256color$/ then 256 when /-truecolor$/ then 16777216 else 256 end elsif ENV['TERM'] case ENV['TERM'] when /-256color$/, 'xterm' then 256 when /-color$/, 'rxvt' then 16 else 256 end else 256 end end |
.detect_debug_mode ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determine the debug mode via an environment variable.
:nocov:
174 175 176 177 178 179 180 |
# File 'lib/vedeu/configuration/configuration.rb', line 174 def detect_debug_mode return false if ENV['VEDEU_TESTMODE'] return true if ENV['VEDEU_DEBUG'] false end |
.detect_trace_mode ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determine the trace mode via an environment variable.
:nocov:
188 189 190 191 192 193 194 |
# File 'lib/vedeu/configuration/configuration.rb', line 188 def detect_trace_mode return false if ENV['VEDEU_TESTMODE'] return true if ENV['VEDEU_TRACE'] false end |
.interactive? ⇒ Boolean Also known as: interactive
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether the application is interactive (required user input) or standalone (will run until terminates of natural causes.) Default is true; meaning the application will require user input.
53 54 55 |
# File 'lib/vedeu/configuration/configuration.rb', line 53 def interactive? [:interactive] end |
.once? ⇒ Boolean Also known as: once
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether the application will run through its main loop once or not. Default is false; meaning the application will loop forever or until terminated by the user.
63 64 65 |
# File 'lib/vedeu/configuration/configuration.rb', line 63 def once? [:once] end |
.options ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns all the options current configured.
118 119 120 |
# File 'lib/vedeu/configuration/configuration.rb', line 118 def ||= defaults end |
.reset ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Resets all options to Vedeu defaults.
95 96 97 |
# File 'lib/vedeu/configuration/configuration.rb', line 95 def reset = defaults end |
.system_keys ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns
71 72 73 |
# File 'lib/vedeu/configuration/configuration.rb', line 71 def system_keys [:system_keys] end |
.terminal_mode ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the terminal mode for the application. Default is ‘:raw`.
78 79 80 |
# File 'lib/vedeu/configuration/configuration.rb', line 78 def terminal_mode [:terminal_mode] end |
.trace? ⇒ Boolean Also known as: trace
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether tracing is enabled or disabled. Tracing is very noisy in the log file (logging method calls and events trigger). Default is false; meaning tracing is disabled.
87 88 89 |
# File 'lib/vedeu/configuration/configuration.rb', line 87 def trace? [:trace] end |
Instance Method Details
#colour_mode ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the chosen colour mode.
35 36 37 |
# File 'lib/vedeu/configuration/configuration.rb', line 35 def colour_mode [:colour_mode] end |
#configure(args = [], &block) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Configure Vedeu with sensible defaults. If the client application sets options, override the defaults with those, and if command-line arguments are provided at application invocation, override any options with the arguments provided.
24 25 26 27 28 29 30 |
# File 'lib/vedeu/configuration/configuration.rb', line 24 def configure(args = [], &block) .merge!(API.configure(&block)) if block_given? .merge!(CLI.configure(args)) if args.any? end |
#debug? ⇒ Boolean Also known as: debug
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether debugging is enabled or disabled. Default is false; meaning nothing apart from warnings are written to the log file.
43 44 45 |
# File 'lib/vedeu/configuration/configuration.rb', line 43 def debug? [:debug] end |
#default_system_keys ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Vedeu’s default system keys. Use #system_keys.
103 104 105 106 107 108 109 110 |
# File 'lib/vedeu/configuration/configuration.rb', line 103 def default_system_keys { exit: 'q', focus_next: :tab, focus_prev: :shift_tab, mode_switch: :escape, } end |
#defaults ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The Vedeu default options, which of course are influenced by environment variables also.
127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/vedeu/configuration/configuration.rb', line 127 def defaults { colour_mode: detect_colour_mode, debug: detect_debug_mode, interactive: true, once: false, system_keys: default_system_keys, terminal_mode: :raw, trace: detect_trace_mode, } end |
#detect_colour_mode ⇒ Fixnum (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Attempt to determine the terminal colour mode via environment variables, or be optimistic and settle for 256 colours.
:nocov:
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/vedeu/configuration/configuration.rb', line 145 def detect_colour_mode return 16777216 if ENV['VEDEU_TESTMODE'] if ENV['VEDEU_TERM'] case ENV['VEDEU_TERM'] when /-256color$/ then 256 when /-truecolor$/ then 16777216 else 256 end elsif ENV['TERM'] case ENV['TERM'] when /-256color$/, 'xterm' then 256 when /-color$/, 'rxvt' then 16 else 256 end else 256 end end |
#detect_debug_mode ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determine the debug mode via an environment variable.
:nocov:
174 175 176 177 178 179 180 |
# File 'lib/vedeu/configuration/configuration.rb', line 174 def detect_debug_mode return false if ENV['VEDEU_TESTMODE'] return true if ENV['VEDEU_DEBUG'] false end |
#detect_trace_mode ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determine the trace mode via an environment variable.
:nocov:
188 189 190 191 192 193 194 |
# File 'lib/vedeu/configuration/configuration.rb', line 188 def detect_trace_mode return false if ENV['VEDEU_TESTMODE'] return true if ENV['VEDEU_TRACE'] false end |
#interactive? ⇒ Boolean Also known as: interactive
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether the application is interactive (required user input) or standalone (will run until terminates of natural causes.) Default is true; meaning the application will require user input.
53 54 55 |
# File 'lib/vedeu/configuration/configuration.rb', line 53 def interactive? [:interactive] end |
#once? ⇒ Boolean Also known as: once
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether the application will run through its main loop once or not. Default is false; meaning the application will loop forever or until terminated by the user.
63 64 65 |
# File 'lib/vedeu/configuration/configuration.rb', line 63 def once? [:once] end |
#options ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns all the options current configured.
118 119 120 |
# File 'lib/vedeu/configuration/configuration.rb', line 118 def ||= defaults end |
#reset ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Resets all options to Vedeu defaults.
95 96 97 |
# File 'lib/vedeu/configuration/configuration.rb', line 95 def reset = defaults end |
#system_keys ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns
71 72 73 |
# File 'lib/vedeu/configuration/configuration.rb', line 71 def system_keys [:system_keys] end |
#terminal_mode ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the terminal mode for the application. Default is ‘:raw`.
78 79 80 |
# File 'lib/vedeu/configuration/configuration.rb', line 78 def terminal_mode [:terminal_mode] end |
#trace? ⇒ Boolean Also known as: trace
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether tracing is enabled or disabled. Tracing is very noisy in the log file (logging method calls and events trigger). Default is false; meaning tracing is disabled.
87 88 89 |
# File 'lib/vedeu/configuration/configuration.rb', line 87 def trace? [:trace] end |