lib/gitlab/help.rb in gitlab-4.5.0 vs lib/gitlab/help.rb in gitlab-4.6.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'gitlab' require 'gitlab/cli_helpers' module Gitlab::Help extend Gitlab::CLI::Helpers @@ -30,13 +32,11 @@ # Finds the location of 'ri' on a system. # # @return [String] def ri_cmd which_ri = `which ri`.chomp - if which_ri.empty? - raise "'ri' tool not found in $PATH. Please install it to use the help." - end + raise "'ri' tool not found in $PATH. Please install it to use the help." if which_ri.empty? which_ri end # A hash map that contains help topics (Branches, Groups, etc.) @@ -45,22 +45,22 @@ # # @return [Hash<Array>] def help_map @help_map ||= begin actions.each_with_object({}) do |action, hsh| - key = client.method(action). - owner.to_s.gsub(/Gitlab::(?:Client::)?/, '') + key = client.method(action) + .owner.to_s.gsub(/Gitlab::(?:Client::)?/, '') hsh[key] ||= [] hsh[key] << action.to_s end end end # Table with available commands. # # @return [Terminal::Table] - def actions_table(topic=nil) + def actions_table(topic = nil) rows = topic ? help_map[topic] : help_map.keys table do |t| t.title = topic || 'Help Topics' # add_row expects an array and we have strings hence the map. @@ -71,12 +71,12 @@ end end # Returns full namespace of a command (e.g. Gitlab::Client::Branches.cmd) def namespace(cmd) - method_owners.select { |method| method[:name] == cmd }. - map { |method| method[:owner] + '.' + method[:name] }. - shift + method_owners.select { |method| method[:name] == cmd } + .map { |method| 'Gitlab::Client::' + method[:owner] + '.' + method[:name] } + .shift end # Massage output from 'ri'. def change_help_output!(cmd, output_str) output_str.gsub!(/#{cmd}\((.*?)\)/m, cmd + ' \1')