Class: PuppetLint::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet-lint/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/puppet-lint/configuration.rb', line 17

def method_missing(method, *args, &block)
  if method.to_s =~ /^(\w+)=$/
    option = $1
    add_option(option.to_s) if settings[option].nil?
    settings[option] = args[0]
  else
    nil
  end
end

Class Method Details

.add_check(check) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/puppet-lint/configuration.rb', line 3

def self.add_check(check)
  define_method("#{check}_enabled?") do
    settings["#{check}_disabled"] == true ? false : true
  end

  define_method("disable_#{check}") do
    settings["#{check}_disabled"] = true
  end

  define_method("enable_#{check}") do
    settings["#{check}_disabled"] = false
  end
end

.add_option(option) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/puppet-lint/configuration.rb', line 31

def self.add_option(option)
  define_method("#{option}=") do |value|
    settings[option] = value
  end

  define_method(option) do
    settings[option]
  end
end

Instance Method Details

#add_check(check, &b) ⇒ Object



41
42
43
44
# File 'lib/puppet-lint/configuration.rb', line 41

def add_check(check, &b)
  self.class.add_check(check)
  check_method[check] = b
end

#add_option(option) ⇒ Object



27
28
29
# File 'lib/puppet-lint/configuration.rb', line 27

def add_option(option)
  self.class.add_option(option)
end

#check_methodObject



50
51
52
# File 'lib/puppet-lint/configuration.rb', line 50

def check_method
  @check_method ||= {}
end

#checksObject



54
55
56
# File 'lib/puppet-lint/configuration.rb', line 54

def checks
  check_method.keys
end

#defaultsObject



58
59
60
61
62
63
64
65
# File 'lib/puppet-lint/configuration.rb', line 58

def defaults
  settings.clear
  self.with_filename = false
  self.fail_on_warnings = false
  self.error_level = :all
  self.log_format = ''
  self.with_context = false
end

#settingsObject



46
47
48
# File 'lib/puppet-lint/configuration.rb', line 46

def settings
  @settings ||= {}
end