Created
June 1, 2018 23:05
-
-
Save ShadowfeindX/83053062280318b0601c885fe9d02326 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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