Class: Metis::Context
- Inherits:
-
Object
- Object
- Metis::Context
- Defined in:
- lib/metis/context.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#definitions ⇒ Object
readonly
Returns the value of attribute definitions.
Instance Method Summary collapse
-
#initialize(configuration_file = nil) ⇒ Context
constructor
A new instance of Context.
- #load ⇒ Object
- #load_check_config ⇒ Object
- #load_checks ⇒ Object
Constructor Details
#initialize(configuration_file = nil) ⇒ Context
Returns a new instance of Context.
6 7 8 9 10 11 12 |
# File 'lib/metis/context.rb', line 6 def initialize(configuration_file=nil) @definitions = Hash.new @configuration_file = configuration_file if configuration_file && File.exists?(configuration_file) @configuration = Metis::Configuration.new @configuration.from_file(configuration_file) if @configuration_file end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
4 5 6 |
# File 'lib/metis/context.rb', line 4 def configuration @configuration end |
#definitions ⇒ Object (readonly)
Returns the value of attribute definitions.
4 5 6 |
# File 'lib/metis/context.rb', line 4 def definitions @definitions end |
Instance Method Details
#load ⇒ Object
14 15 16 17 18 |
# File 'lib/metis/context.rb', line 14 def load load_checks load_check_config true end |
#load_check_config ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/metis/context.rb', line 36 def load_check_config @configuration.blocks.each do |check_name,blocks| raise "Unknown check definition: #{check_name}" unless @definitions[check_name] blocks.each { |block| @definitions[check_name].instance_eval(&block) } end true end |
#load_checks ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/metis/context.rb', line 20 def load_checks @configuration.checks_include_directories.each do |dir| Dir.glob(File.join(dir, "**/*.rb")).each do |filename| next if @configuration.ignore_filename_patterns.detect { |p| filename =~ p } checklist = Metis::CheckDefinitionList.new checklist.from_file(filename) definitions.merge!(checklist.defines) do |key, oldval, newval| puts "Overriding duplicate definition #{key}, new definition found in #{filename}" newval end end end end |