lib/travis/tools/system.rb in travis-1.11.1 vs lib/travis/tools/system.rb in travis-1.12.0

- old
+ new

@@ -1,18 +1,20 @@ +# frozen_string_literal: true + module Travis module Tools module System - extend self + module_function def recent_version?(version, minimum) version = version.split('.').map { |s| s.to_i } minimum = minimum.split('.').map { |s| s.to_i } (version <=> minimum) >= 0 end def windows? - File::ALT_SEPARATOR == "\\" + File::ALT_SEPARATOR == '\\' end def mac? RUBY_PLATFORM =~ /darwin/i end @@ -20,11 +22,11 @@ def linux? RUBY_PLATFORM =~ /linux/i end def unix? - not windows? + !windows? end def os os_name ? "#{os_name} #{os_version}".strip : os_type end @@ -50,11 +52,11 @@ def ruby_engine defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby' end def ruby_version - "%s-p%s" % [RUBY_VERSION, RUBY_PATCHLEVEL] + format('%s-p%s', RUBY_VERSION, RUBY_PATCHLEVEL) end def ruby case ruby_engine when 'ruby' then "Ruby #{ruby_version}" @@ -63,25 +65,28 @@ else "#{ruby_engine} like Ruby #{ruby_version}" end end def rubygems - return "no RubyGems" unless defined? Gem + return 'no RubyGems' unless defined? Gem + "RubyGems #{Gem::VERSION}" end def description(*args) - [ full_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 "command -v #{command} 2>/dev/null >/dev/null" } end def running?(app) return false unless unix? + system "/usr/bin/pgrep -u $(whoami) #{app} >/dev/null" end end end end