<commit_before>require 'forwardable'
require 'kelbim/wrapper/listener-collection'
require 'kelbim/logger'

module Kelbim
  class ELBWrapper
    class LoadBalancerCollection
      class LoadBalancer
        extend Forwardable
        include Logger::ClientHelper

        def_delegators(
          :@load_balancer,
          :vpc_id, :name)

        def initialize(load_balancer, options)
          @load_balancer = load_balancer
          @options = options
        end

        def listeners
          ListenerCollection.new(@load_balancer.listeners, self, @options)
        end

        def eql?(dsl)
          @load_balancer.health_check.sort == dsl.health_check.sort or return false

          if self.vpc_id
            subnet_ids = @load_balancer.subnets.map {|i| i.id }
            subnet_ids.sort == dsl.subnets.sort or return false

            aws_sg_ids = @load_balancer.security_group_ids.sort
            dsl_sg_ids = dsl.security_groups.map {|i|
              sg_names = @options.security_group_names[self.vpc_id] || {}
              sg_names.key(i) || i
            }.sort

            aws_sg_ids == dsl_sg_ids or return false
          else
            az_names = @load_balancer.availability_zones.map {|i| i.name }
            az_names.sort == dsl.availability_zones.sort or return false
          end  

          aws_instance_ids = @load_balancer.instances.map {|i| i.id }.sort

          dsl_instance_ids = dsl.instances.map {|i|
            instance_names = @options.instance_names[self.vpc_id] || {}
            instance_names.key(i) || i
          }.sort

          aws_instance_ids == dsl_instance_ids
        end

        def update(dsl)
          log(:info, 'Update LoadBalancer', :red, "#{self.vpc_id || :classic} > #{name}")
          # XXX:
        end

        def delete
          log(:info, 'Delete LoadBalancer', :red, "#{self.vpc_id || :classic} > #{name}")
          # XXX: @load_balancers.delete
        end
      end # LoadBalancer
    end # LoadBalancerCollection
  end # ELBWrapper
end # Kelbim<commit_msg>impl db delete<commit_after>require 'forwardable'
require 'kelbim/wrapper/listener-collection'
require 'kelbim/logger'

module Kelbim
  class ELBWrapper
    class LoadBalancerCollection
      class LoadBalancer
        extend Forwardable
        include Logger::ClientHelper

        def_delegators(
          :@load_balancer,
          :vpc_id, :name)

        def initialize(load_balancer, options)
          @load_balancer = load_balancer
          @options = options
        end

        def listeners
          ListenerCollection.new(@load_balancer.listeners, self, @options)
        end

        def eql?(dsl)
          @load_balancer.health_check.sort == dsl.health_check.sort or return false

          if self.vpc_id
            subnet_ids = @load_balancer.subnets.map {|i| i.id }
            subnet_ids.sort == dsl.subnets.sort or return false

            aws_sg_ids = @load_balancer.security_group_ids.sort
            dsl_sg_ids = dsl.security_groups.map {|i|
              sg_names = @options.security_group_names[self.vpc_id] || {}
              sg_names.key(i) || i
            }.sort

            aws_sg_ids == dsl_sg_ids or return false
          else
            az_names = @load_balancer.availability_zones.map {|i| i.name }
            az_names.sort == dsl.availability_zones.sort or return false
          end  

          aws_instance_ids = @load_balancer.instances.map {|i| i.id }.sort

          dsl_instance_ids = dsl.instances.map {|i|
            instance_names = @options.instance_names[self.vpc_id] || {}
            instance_names.key(i) || i
          }.sort

          aws_instance_ids == dsl_instance_ids
        end

        def update(dsl)
          log(:info, 'Update LoadBalancer', :red, "#{self.vpc_id || :classic} > #{name}")
          # XXX:
        end

        def delete
          log(:info, 'Delete LoadBalancer', :red, "#{self.vpc_id || :classic} > #{name}")

          unless @options.dry_run
            @load_balancer.delete
            @options.updated = true
          end
        end
      end # LoadBalancer
    end # LoadBalancerCollection
  end # ELBWrapper
end # Kelbim
{'fraction_non_alphanumeric': 0.09520383693045563, 'fraction_numerical': 0.0, 'mean_word_length': 2.0400874635568513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4721004', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1283, 'n_words': 259}