<commit_before>require 'boucher/compute'
require 'boucher/servers'

module Boucher
  module SecurityGroups
    SECURITY_GROUP_TABLE_FORMAT = "%-12s  %-12s  %-50s\n"
    RULE_TABLE_FORMAT = "%-18s  %-19s  %-10s %-10s %-10s\n"

    module Printing
      def self.print_table(security_groups, servers_for_groups)
        puts "----------------------------------------------------------------------"
        security_groups.each do |security_group|
          puts "GROUP:"
          printf SECURITY_GROUP_TABLE_FORMAT, "ID", "Name", "Servers"
          printf SECURITY_GROUP_TABLE_FORMAT,
            security_group.group_id,
            security_group.name,
            server_names(servers_for_groups[security_group.name])
          puts "\n"
          puts "RULES FOR GROUP:"
          printf RULE_TABLE_FORMAT, "Incoming Groups", "Incoming IP", "Protocol", "Min Port", "Max Port"
          security_group.ip_permissions.each do |rule|
            printf RULE_TABLE_FORMAT, rule_groups(rule), rule_ip(rule), rule["ipProtocol"], rule["fromPort"], rule["toPort"]
          end
          puts "----------------------------------------------------------------------"
          puts "\n"
        end
      end
      def self.rule_groups(ip_permissions)
        names = ip_permissions["groups"].map do |group|
          group["groupName"]
        end
        if names.empty?
          "______"
        else
          names.join("\n")
        end
      end

      def self.rule_ip(ip_permission)
        ip = (ip_permission["ipRanges"].first || {})["cidrIp"]
        ip || "______"


      end
<commit_msg>formatting for multiple incoming groups<commit_after>require 'boucher/compute'
require 'boucher/servers'

module Boucher
  module SecurityGroups
    SECURITY_GROUP_TABLE_FORMAT = "%-12s  %-12s  %-50s\n"
    RULE_WIDTH = 18
    RULE_TABLE_FORMAT = "%-#{RULE_WIDTH}s  %-19s  %-10s %-10s %-10s\n"

    module Printing
      def self.print_table(security_groups, servers_for_groups)
        puts "----------------------------------------------------------------------"
        security_groups.each do |security_group|
          puts "GROUP:"
          printf SECURITY_GROUP_TABLE_FORMAT, "ID", "Name", "Servers"
          printf SECURITY_GROUP_TABLE_FORMAT,
            security_group.group_id,
            security_group.name,
            server_names(servers_for_groups[security_group.name])
          puts "\n"
          puts "RULES FOR GROUP:"
          printf RULE_TABLE_FORMAT, "Incoming Groups", "Incoming IP", "Protocol", "Min Port", "Max Port"
          security_group.ip_permissions.each do |rule|
            printf RULE_TABLE_FORMAT, rule_groups(rule), rule_ip(rule), rule["ipProtocol"], rule["fromPort"], rule["toPort"]
          end
          puts "----------------------------------------------------------------------"
          puts "\n"
        end
      end
      def self.rule_groups(ip_permissions)
        names = ip_permissions["groups"].map do |group|
          group["groupName"].ljust(RULE_WIDTH)
        end
        if names.empty?
          "______"
        else
          names.join("\n")
        end
      end

      def self.rule_ip(ip_permission)
        ip = (ip_permission["ipRanges"].first || {})["cidrIp"]
        ip || "______"


      end

{'fraction_non_alphanumeric': 0.1874044634668297, 'fraction_numerical': 0.009782940996637114, 'mean_word_length': 1.751892346509672, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5371017', 'n_tokens_mistral': 968, 'n_tokens_neox': 947, 'n_words': 192}