From 5b384c177091c00f4dde78be4b0a873160cd39a8 Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Date: Mon, 18 May 2020 14:17:24 +0200 Subject: [PATCH 1/2] B #687: filter by hidden columns --- src/cli/cli_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cli/cli_helper.rb b/src/cli/cli_helper.rb index 4babbd4d9c..f2b4329824 100644 --- a/src/cli/cli_helper.rb +++ b/src/cli/cli_helper.rb @@ -571,8 +571,8 @@ module CLIHelper # @return [Array] Array with selected columns information def data_array(data, options) res_data = data.collect do |d| - @default_columns.collect do |c| - @columns[c][:proc].call(d).to_s if @columns[c] + @columns.collect do |_, params| + params[:proc].call(d).to_s end end @@ -821,7 +821,7 @@ module CLIHelper m = s.match(/^(.*?)#{operators}(.*?)$/) if m - index = @default_columns.index(m[1].to_sym) + index = @columns.keys.index(m[1].to_sym) if index { From 4b6307de106da2874dea7508d43110ae4bc02751 Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Date: Mon, 18 May 2020 14:53:33 +0200 Subject: [PATCH 2/2] B #687: filter by hidden columns --- src/cli/cli_helper.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cli/cli_helper.rb b/src/cli/cli_helper.rb index f2b4329824..b223d7c21e 100644 --- a/src/cli/cli_helper.rb +++ b/src/cli/cli_helper.rb @@ -571,8 +571,8 @@ module CLIHelper # @return [Array] Array with selected columns information def data_array(data, options) res_data = data.collect do |d| - @columns.collect do |_, params| - params[:proc].call(d).to_s + @default_columns.collect do |c| + @columns[c][:proc].call(d).to_s if @columns[c] end end @@ -580,6 +580,10 @@ module CLIHelper filter_data!(res_data, options) if options[:filter] end + return res_data unless options[:list] + + @default_columns = options[:list].collect {|o| o.upcase.to_sym } + res_data end @@ -797,10 +801,6 @@ module CLIHelper rescue StandardError => e CLIHelper.fail(e.message) end - - return unless options[:list] - - @default_columns = options[:list].collect {|o| o.upcase.to_sym } end # Filter data