Class: Scriptster::Configuration
- Inherits:
-
Object
- Object
- Scriptster::Configuration
- Defined in:
- lib/scriptster/configuration.rb
Overview
The configuration obejct used in the configure method.
Instance Attribute Summary collapse
-
#colours ⇒ Symbol, Proc
Desired colour theme (either predefined or custom Proc).
-
#file ⇒ String, ...
A log file that all messages will be written to.
-
#log_format ⇒ String
Template for each line in the logs.
-
#name ⇒ String
The name of the script to be displayed in the logs.
-
#theme ⇒ Object
writeonly
Sets the attribute theme.
-
#timestamps ⇒ Boolean
Include timestamps in log messages.
-
#verbosity ⇒ Symbol
The minimum verbosity to of messages to be displayed.
Instance Method Summary collapse
-
#apply ⇒ Object
Put the settings from this object in effect.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
40 41 42 43 44 45 46 47 |
# File 'lib/scriptster/configuration.rb', line 40 def initialize @name = File.basename($0) @verbosity = :verbose @file = nil = true @colours = :dark @log_format = "%{timestamp} %{name} %{type} %{message}" end |
Instance Attribute Details
#colours ⇒ Symbol, Proc
Desired colour theme (either predefined or custom Proc).
37 38 39 |
# File 'lib/scriptster/configuration.rb', line 37 def colours @colours end |
#file ⇒ String, ...
A log file that all messages will be written to.
37 38 39 |
# File 'lib/scriptster/configuration.rb', line 37 def file @file end |
#log_format ⇒ String
Template for each line in the logs
37 38 39 |
# File 'lib/scriptster/configuration.rb', line 37 def log_format @log_format end |
#name ⇒ String
The name of the script to be displayed in the logs.
37 38 39 |
# File 'lib/scriptster/configuration.rb', line 37 def name @name end |
#theme=(value) ⇒ Object (writeonly)
Sets the attribute theme
38 39 40 |
# File 'lib/scriptster/configuration.rb', line 38 def theme=(value) @theme = value end |
#timestamps ⇒ Boolean
Include timestamps in log messages.
37 38 39 |
# File 'lib/scriptster/configuration.rb', line 37 def end |
#verbosity ⇒ Symbol
The minimum verbosity to of messages to be displayed.
37 38 39 |
# File 'lib/scriptster/configuration.rb', line 37 def verbosity @verbosity end |
Instance Method Details
#apply ⇒ Object
Put the settings from this object in effect.
This function will distribute the configuration to the appropriate objects and modules.
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/scriptster/configuration.rb', line 53 def apply Logger.set_name @name if @name Logger.set_verbosity @verbosity if @verbosity Logger.set_file @file if @file Logger.set_format @log_format if @log_format if @colours.is_a? Proc @colours.call else ColourThemes.send @colours.to_sym end end |