module Gemshine::UI
Constants
- MSG_BUNDLE_ERROR
- MSG_BUNDLE_OUTDATED
- MSG_BUNDLE_UP_TO_DATE
- MSG_GATHER_OUTDATED
- MSG_MISSING_GEMFILE
- MSG_PATH_STATS
- MSG_UP_TO_DATE
Public Instance Methods
detect_outdated_color(installed, latest)
click to toggle source
# File lib/gemshine/ui.rb, line 39 def detect_outdated_color(installed, latest) installed_parts = installed.split('.') latest_parts = latest.split('.') outdated_position = 2 version_comparison = installed_parts.zip(latest_parts).map { |a, b| b ||= '0' ; a < b } version_comparison.each_with_index do |outdated_digit, i| if outdated_digit outdated_position = i break end end digit_color outdated_position end
gem_table(rows)
click to toggle source
# File lib/gemshine/ui.rb, line 19 def gem_table(rows) if rows.empty? log_up_to_date return end rows.sort! table = Terminal::Table.new title: set_color(@project_name, :cyan, :bold), headings: table_headings, style: { width: 70 } do |t| t.rows = rows t.add_separator t.add_row ["#{set_color(rows.size, :bold)} outdated gems", '', '', ''] end puts puts table end
log_bundle_message(message)
click to toggle source
# File lib/gemshine/ui.rb, line 76 def log_bundle_message(message) log_status 'warning', MSG_BUNDLE_ERROR, :red say_status 'message', message.strip!, :yellow end
log_missing()
click to toggle source
# File lib/gemshine/ui.rb, line 71 def log_missing log_status 'skip', MSG_MISSING_GEMFILE, :red log_project_name :yellow end
log_path_stats()
click to toggle source
# File lib/gemshine/ui.rb, line 56 def log_path_stats puts say_status 'stats', "#{@projects} #{MSG_PATH_STATS}", :yellow end
log_project()
click to toggle source
# File lib/gemshine/ui.rb, line 61 def log_project log_status 'info', MSG_GATHER_OUTDATED, :blue log_project_name :cyan end
log_up_to_date()
click to toggle source
# File lib/gemshine/ui.rb, line 66 def log_up_to_date puts say_status 'nice', MSG_UP_TO_DATE, :magenta end
run_bundle_outdated()
click to toggle source
# File lib/gemshine/ui.rb, line 13 def run_bundle_outdated pwd = Dir.pwd run "cd #{@project_dir} && bundle outdated && cd #{pwd}", capture: true end
Private Instance Methods
digit_color(position)
click to toggle source
# File lib/gemshine/ui.rb, line 92 def digit_color(position) position == 0 ? :red : :yellow end
log_project_name(color)
click to toggle source
# File lib/gemshine/ui.rb, line 101 def log_project_name(color) say_status 'project', @project_name, color puts end
log_status(type, message, color)
click to toggle source
# File lib/gemshine/ui.rb, line 96 def log_status(type, message, color) puts say_status type, set_color(message, :bold), color end
table_headings()
click to toggle source
# File lib/gemshine/ui.rb, line 83 def table_headings c_name = set_color('Gem', :bold) c_defined = set_color('Defined', :bold) c_installed = set_color('Installed', :bold) c_latest = set_color('Latest', :bold) [c_name, c_defined, c_installed, c_latest] end