module OS
  def self.mac?
    /darwin/i === RUBY_PLATFORM
  end

  def self.linux?
    /linux/i === RUBY_PLATFORM
  end

  require "os/mac"
  if OS.mac?
    GITHUB_REPOSITORY = "homebrew"
    ISSUES_URL = "https://git.io/brew-troubleshooting"
    PATH_OPEN = "/usr/bin/open"
    PATH_PATCH = "/usr/bin/patch"
    # compatibility
    ::MACOS_FULL_VERSION = OS::Mac.full_version.to_s
    ::MACOS_VERSION = OS::Mac.version.to_s
    ::OS_VERSION = "OS X #{MACOS_FULL_VERSION}"
  elsif OS.linux?
    GITHUB_REPOSITORY = "linuxbrew"
    ISSUES_URL = "https://github.com/Homebrew/#{GITHUB_REPOSITORY}/blob/master/share/doc/homebrew/Troubleshooting.md#troubleshooting"
    PATH_OPEN = "xdg-open"
    PATH_PATCH = "patch"
    # compatibility
    ::MACOS_FULL_VERSION = OS::Mac.full_version.to_s
    ::MACOS_VERSION = OS::Mac.version.to_s
    ::OS_VERSION = RUBY_PLATFORM
  else
    raise "Unknown operating system"
  end
end

module OS
  def self.mac?
    /darwin/i === RUBY_PLATFORM
  end

  def self.linux?
    /linux/i === RUBY_PLATFORM || /linux/i === RbConfig::CONFIG["host_os"]
  end

  require "os/mac"
  if OS.mac?
    GITHUB_REPOSITORY = "homebrew"
    ISSUES_URL = "https://git.io/brew-troubleshooting"
    PATH_OPEN = "/usr/bin/open"
    PATH_PATCH = "/usr/bin/patch"
    # compatibility
    ::MACOS_FULL_VERSION = OS::Mac.full_version.to_s
    ::MACOS_VERSION = OS::Mac.version.to_s
    ::OS_VERSION = "OS X #{MACOS_FULL_VERSION}"
  elsif OS.linux?
    GITHUB_REPOSITORY = "linuxbrew"
    ISSUES_URL = "https://github.com/Homebrew/#{GITHUB_REPOSITORY}/blob/master/share/doc/homebrew/Troubleshooting.md#troubleshooting"
    PATH_OPEN = "xdg-open"
    PATH_PATCH = "patch"
    # compatibility
    ::MACOS_FULL_VERSION = OS::Mac.full_version.to_s
    ::MACOS_VERSION = OS::Mac.version.to_s
    ::OS_VERSION = RUBY_PLATFORM
  else
    raise "Unknown operating system"
  end
end

Fix OS detection for JRuby on Linuxbrew
Fix OS detection for JRuby on Linuxbrew

Included an extra check for whether the OS was Linux or not. RUBY_PLATFORM
returns "java" on Linux if using JRuby, which is Fedora's default, for
example.

Closes Homebrew/linuxbrew#653.

Signed-off-by: Shaun Jackman <b580dab3251a9622aba3803114310c23fdb42900@gmail.com>
