Class: Inspec::Resources::AptRepository

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

Direct Known Subclasses

PpaRepository

Instance Method Summary collapse

Constructor Details

#initialize(ppa_name) ⇒ AptRepository

Returns a new instance of AptRepository.



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

def initialize(ppa_name)
  @ppa_name = 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
63
# File 'lib/inspec/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/inspec/resources/apt.rb', line 53

def exists?
  find_repo.count > 0
end

#resource_idObject



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

def resource_id
  @deb_url || @ppa_name || "apt repository"
end

#to_sObject



69
70
71
# File 'lib/inspec/resources/apt.rb', line 69

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