Skip to content

Instantly share code, notes, and snippets.

@ShadowfeindX
Created June 1, 2018 23:05
Show Gist options
  • Save ShadowfeindX/83053062280318b0601c885fe9d02326 to your computer and use it in GitHub Desktop.
Save ShadowfeindX/83053062280318b0601c885fe9d02326 to your computer and use it in GitHub Desktop.
# This class knows about supported JRubyArt operating systems
class HostOS
def self.os
detect_os = RbConfig::CONFIG['host_os']
case detect_os
when /mac|darwin/ then :mac
when /gnueabihf/ then :arm
when /linux/ then :linux
when /solaris|bsd/ then :unix
else
WIN_PATTERNS.find { |reg| reg.match?(detect_os) } # <- issue here
raise "unsupported os: #{detect_os.inspect}" if Regexp.last_match.nil? # <- this will never be true
:windows
end
end
end
# Solution I suppose
windows = WIN_PATTERNS.detect { |reg| reg.match?(detect_os) }
raise "unsupported os: #{detect_os.inspect}" unless windows
:windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment