class TAPI::Serverspec::Type::Java

Public Instance Methods

installed?(version: nil, flavor: nil) click to toggle source
# File lib/tapi/serverspec/type/java.rb, line 7
def installed?(version: nil, flavor: nil)
  return false unless cmd_line_tool_installed?
  return false if version && !version_installed?(version)
  return false if flavor && !flavor_installed?(flavor)

  true
end

Private Instance Methods

cmd_line_tool_installed?() click to toggle source
# File lib/tapi/serverspec/type/java.rb, line 17
def cmd_line_tool_installed?
  cmd_java = 'java -version'
  ::Serverspec::Type::Command.new(cmd_java).exit_status == 0
end
flavor_installed?(flavor) click to toggle source
# File lib/tapi/serverspec/type/java.rb, line 27
def flavor_installed?(flavor)
  unless flavor == :oracle
    raise ArgumentError, 'the only supported flavor is :oracle'
  end

  cmd_flavor =
    'java -version 2>&1 | grep "Java(TM) SE Runtime Environment"'

  ::Serverspec::Type::Command.new(cmd_flavor).exit_status == 0
end
to_s?() click to toggle source
# File lib/tapi/serverspec/type/java.rb, line 38
def to_s?
  'Java'
end
version_installed?(version) click to toggle source
# File lib/tapi/serverspec/type/java.rb, line 22
def version_installed?(version)
  cmd_version = "java -version 2>&1 | grep #{version}"
  ::Serverspec::Type::Command.new(cmd_version).exit_status == 0
end