lib/travis/tools/system.rb in travis-1.6.2.travis.366.4 vs lib/travis/tools/system.rb in travis-1.6.2.travis.367.4

- old
+ new

@@ -13,18 +13,36 @@ def linux? RUBY_PLATFORM =~ /linux/i end + def unix? + not windows? + end + def os - @os ||= windows? ? "Windows" : `uname`.chomp + os_name ? "#{os_name} #{os_version}".strip : os_type end def full_os - @full_os ||= mac? ? "#{`sw_vers -productName`.chomp} #{`sw_vers -productVersion`.chomp}" : os + os_name == os_type ? os : "#{os} like #{os_type}" end + def os_version + @os_version ||= has?(:sw_vers) && `sw_vers -productVersion`.chomp + @os_version ||= has?(:lsb_release) && `lsb_release -r -s`.chomp + end + + def os_name + @os_name ||= has?(:sw_vers) && `sw_vers -productName`.chomp + @os_name ||= has?(:lsb_release) && `lsb_release -i -s`.chomp + end + + def os_type + @os_type ||= `uname`.chomp + end + def ruby_engine defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby' end def ruby_version @@ -44,10 +62,16 @@ return "no RubyGems" unless defined? Gem "RubyGems #{Gem::VERSION}" end def description(*args) - [ os, ruby, rubygems, *args.flatten].compact.uniq.join("; ") + [ full_os, ruby, rubygems, *args.flatten].compact.uniq.join("; ") + end + + def has?(command) + return false unless unix? + @has ||= {} + @has.fetch(command) { @has[command] = system "which #{command} 2>/dev/null >/dev/null" } end end end end