Class: ColorTail::Configuration
- Inherits:
-
Object
- Object
- ColorTail::Configuration
- Defined in:
- lib/colortail/configuration.rb
Instance Method Summary collapse
- #colorit(group, groupings) ⇒ Object
- #display_match_groups ⇒ Object
-
#initialize(conf) ⇒ Configuration
constructor
A new instance of Configuration.
-
#load_opts(group) ⇒ Object
Load everything from the config file here since the colorit() method isn’t available in the configuration object until after a new object has been instantiated.
Constructor Details
#initialize(conf) ⇒ Configuration
Returns a new instance of Configuration.
4 5 6 7 8 9 10 11 |
# File 'lib/colortail/configuration.rb', line 4 def initialize(conf) @config_file = conf if File.exists?(conf) @config = File.read(conf) else raise FileDoesNotExist, "Config file #{file} cannot be found." end end |
Instance Method Details
#colorit(group, groupings) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/colortail/configuration.rb', line 13 def colorit(group, groupings) if groupings.class == Hash if groupings.has_key?( group ) return groupings[group] else raise ComplexRecord, "No such group '#{group}' in config file" end else raise ComplexRecord, "Config file syntax error" end end |
#display_match_groups ⇒ Object
37 38 39 40 41 42 |
# File 'lib/colortail/configuration.rb', line 37 def display_match_groups() puts "The following match groups are available through your config files:" Groupings.each_key do |group| puts " * #{group}" end end |
#load_opts(group) ⇒ Object
Load everything from the config file here since the colorit() method isn’t available in the configuration object until after a new object has been instantiated.
28 29 30 31 32 33 34 35 |
# File 'lib/colortail/configuration.rb', line 28 def load_opts(group) colorset = [] if File.exists?(@config_file) load @config_file colorset = self.colorit( group, Groupings ) end return colorset end |