Class: Inspec::Resources::AptRepository

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

Direct Known Subclasses

PpaRepository

Instance Method Summary collapse

Constructor Details

#initialize(ppa_name) ⇒ AptRepository

Returns a new instance of AptRepository.



42
43
44
45
46
47
48
49
50
51
# File 'lib/resources/apt.rb', line 42

def initialize(ppa_name)
  @deb_url = nil
  # check if the os is ubuntu or debian
  if inspec.os.debian?
    @deb_url = determine_ppa_url(ppa_name)
  else
    # this resource is only supported on ubuntu and debian
    skip_resource 'The `apt` resource is not supported on your OS yet.'
  end
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


57
58
59
60
61
62
# File 'lib/resources/apt.rb', line 57

def enabled?
  return false if find_repo.count == 0
  actives = find_repo.map { |repo| repo[:active] }
  actives = actives.uniq
  actives.size == 1 && actives[0] = true
end

#exists?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/resources/apt.rb', line 53

def exists?
  find_repo.count > 0
end

#to_sObject



64
65
66
# File 'lib/resources/apt.rb', line 64

def to_s
  "Apt Repository #{@deb_url}"
end