Module: Sunspot::Solr::Java

Defined in:
lib/sunspot/solr/java.rb

Class Method Summary collapse

Class Method Details

.ensure_install!Object


7
8
9
10
11
12
13
# File 'lib/sunspot/solr/java.rb', line 7

def ensure_install!
  if installed?
    true
  else
    raise Sunspot::Solr::Server::JavaMissing, "You need a Java Runtime Environment to run the Solr server"
  end
end

.installed?Boolean


15
16
17
18
# File 'lib/sunspot/solr/java.rb', line 15

def installed?
  system("java", "-version", [:out, :err] => null_device)
  $?.exitstatus.zero?
end

.null_deviceObject


20
21
22
# File 'lib/sunspot/solr/java.rb', line 20

def null_device
  RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ ? "NUL" : "/dev/null"
end