class Serverspec::Type::NfsExport

Public Class Methods

new(name = nil, options = {}) click to toggle source
Calls superclass method
# File lib/serverspec_extra_types/types/nfs_export.rb, line 9
def initialize(name = nil, options = {})
  super(name, options)
  @export = name
end

Public Instance Methods

exists?() click to toggle source
# File lib/serverspec_extra_types/types/nfs_export.rb, line 14
def exists?
  get_inspection.success?
end
get_inspection() click to toggle source

rubocop:disable Naming/AccessorMethodName

# File lib/serverspec_extra_types/types/nfs_export.rb, line 46
def get_inspection
  command = "grep #{@export} /etc/exports"
  @get_inspection ||= @runner.run_command(command)
end
has_host?(host_id, option = nil) click to toggle source
# File lib/serverspec_extra_types/types/nfs_export.rb, line 18
def has_host?(host_id, option = nil)
  if option
    check_options(host_id, option)
  else
    hosts.key?(host_id)
  end
end
host(host_id) click to toggle source
# File lib/serverspec_extra_types/types/nfs_export.rb, line 37
def host(host_id)
  hosts[host_id]
end
hosts() click to toggle source
# File lib/serverspec_extra_types/types/nfs_export.rb, line 26
def hosts
  unless @hosts
    @hosts = {}
    inspection.split(' ')[1..-1].each do |item|
      (host, options) = item.split('(')
      @hosts[host] = options.split(')')[0].split(',')
    end
  end
  @hosts
end
inspection() click to toggle source
# File lib/serverspec_extra_types/types/nfs_export.rb, line 41
def inspection
  @inspection ||= get_inspection.stdout
end

Private Instance Methods

check_options(host_id, opts) click to toggle source

rubocop:enable Naming/AccessorMethodName

# File lib/serverspec_extra_types/types/nfs_export.rb, line 54
 def check_options(host_id, opts)
   options = opts.include?(',') ? opts.spilt(',') : opts
   if options.is_a? Array
     host(host_id).split(',').include?(options)
   else
     host(host_id).include?(options)
   end
end