1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/bundler/support/command_execution.rb
Hiroshi SHIBATA 7585bc3187 Merge Bundler 2.1.0.pre.3
Features:
    - Add caller information to some deprecation messages to make them easier to fix [#7361](https://github.com/bundler/bundler/pull/7361)
    - Reconcile `bundle cache` vs `bundle package` everywhere. Now in docs, CLI help and everywhere else `bundle cache` is the preferred version and `bundle package` remains as an alias [#7389](https://github.com/bundler/bundler/pull/7389)
    - Display some basic `bundler` documentation together with ruby's RDoc based documentation [#7394](https://github.com/bundler/bundler/pull/7394)

  Bugfixes:
    - Fix typos deprecation message and upgrading docs [#7374](https://github.com/bundler/bundler/pull/7374)
    - Deprecation warnings about `taint` usage on ruby 2.7 [#7385](https://github.com/bundler/bundler/pull/7385)
    - Fix `--help` flag not correctly delegating to `man` when used with command aliases [#7388](https://github.com/bundler/bundler/pull/7388)
    - `bundle add` should cache newly added gems if an application cache exists [#7393](https://github.com/bundler/bundler/pull/7393)
    - Stop using an insecure folder as a "fallback home" when user home is not defined [#7416](https://github.com/bundler/bundler/pull/7416)
    - Fix `bundler/inline` warning about `Bundler.root` redefinition [#7417](https://github.com/bundler/bundler/pull/7417)
2019-11-11 18:56:25 +09:00

44 lines
1 KiB
Ruby

# frozen_string_literal: true
module Spec
CommandExecution = Struct.new(:command, :working_directory, :exitstatus, :stdout, :stderr) do
def to_s
c = Shellwords.shellsplit(command.strip).map {|s| s.include?("\n") ? " \\\n <<EOS\n#{s.gsub(/^/, " ").chomp}\nEOS" : Shellwords.shellescape(s) }
c = c.reduce("") do |acc, elem|
concat = acc + " " + elem
last_line = concat.match(/.*\z/)[0]
if last_line.size >= 100
acc + " \\\n " + elem
else
concat
end
end
"$ #{c.strip}"
end
alias_method :inspect, :to_s
def stdboth
@stdboth ||= [stderr, stdout].join("\n").strip
end
def to_s_verbose
[
to_s,
stdout,
stderr,
exitstatus ? "# $? => #{exitstatus}" : "",
].reject(&:empty?).join("\n")
end
def success?
return true unless exitstatus
exitstatus == 0
end
def failure?
return true unless exitstatus
exitstatus > 0
end
end
end