From 1069139a339a6a7d0d6169c634e572659f749ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 24 Jul 2019 16:09:35 +0200 Subject: [bundler/bundler] Extract some methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Guillermo Guerrero Co-authored-by: David Rodríguez https://github.com/bundler/bundler/commit/027aba0cff --- lib/bundler/cli/outdated.rb | 50 ++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 804e8072d4..ad58be0b9f 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -105,11 +105,7 @@ module Bundler display_nothing_outdated_message else unless options[:parseable] - if options[:pre] - Bundler.ui.info "Outdated gems included in the bundle (including pre-releases):" - else - Bundler.ui.info "Outdated gems included in the bundle:" - end + Bundler.ui.info(header_outdated_message) end if options_include_groups @@ -125,11 +121,7 @@ module Bundler next if (!options[:groups] && !contains_group) || gems.nil? unless options[:parseable] - if groups - Bundler.ui.info "===== #{groups_text("Group", groups)} =====" - else - Bundler.ui.info "===== Without group =====" - end + Bundler.ui.info(header_group_message(groups)) end print_gems(gems) @@ -148,6 +140,34 @@ module Bundler "#{group_text}#{groups.split(",").size > 1 ? "s" : ""} \"#{groups}\"" end + def header_outdated_message + if options[:pre] + "Outdated gems included in the bundle (including pre-releases):" + else + "Outdated gems included in the bundle:" + end + end + + def header_group_message(groups) + if groups + "===== #{groups_text("Group", groups)} =====" + else + "===== Without group =====" + end + end + + def nothing_outdated_message + if filter_options_patch.any? + display = filter_options_patch.map do |o| + o.sub("filter-", "") + end.join(" or ") + + "No #{display} updates to display.\n" + else + "Bundle up to date!\n" + end + end + def retrieve_active_spec(strict, definition, current_spec) return unless current_spec.match_platform(Bundler.local_platform) @@ -166,15 +186,7 @@ module Bundler def display_nothing_outdated_message unless options[:parseable] - if filter_options_patch.any? - display = filter_options_patch.map do |o| - o.sub("filter-", "") - end.join(" or ") - - Bundler.ui.info "No #{display} updates to display.\n" - else - Bundler.ui.info "Bundle up to date!\n" - end + Bundler.ui.info(nothing_outdated_message) end end -- cgit v1.2.3