Class: GrubConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/resources/grub_conf.rb

Overview

rubocop:disable Metrics/ClassLength

Instance Method Summary collapse

Constructor Details

#initialize(path = nil, kernel = nil) ⇒ GrubConfig

Returns a new instance of GrubConfig.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/resources/grub_conf.rb', line 24

def initialize(path = nil, kernel = nil)
  family = inspec.os[:family]
  case family
  when 'redhat', 'fedora', 'centos'
    release = inspec.os[:release].to_f
    supported = true
    if release < 7
      @conf_path = path || '/etc/grub.conf'
      @version = 'legacy'
    else
      @conf_path = path || '/boot/grub/grub.cfg'
      @defaults_path = '/etc/default/grub'
      @version = 'grub2'
    end
  when 'ubuntu'
    @conf_path = path || '/boot/grub/grub.cfg'
    @defaults_path = '/etc/default/grub'
    @version = 'grub2'
    supported = true
  end
  @kernel = kernel || 'default'
  return skip_resource 'The `grub_config` resource is not supported on your OS yet.' if supported.nil?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



48
49
50
# File 'lib/resources/grub_conf.rb', line 48

def method_missing(name)
  read_params[name.to_s]
end

Instance Method Details

#to_sObject



52
53
54
# File 'lib/resources/grub_conf.rb', line 52

def to_s
  'Grub Config'
end