<commit_before>require 'yaml'
require 'docker-compose/generator/version'
require 'docker-compose/generator/service'

module DockerCompose
  # Static Generator Class
  # Used to create and keep track of services
  module Generator
    # Services Cache
    #
    # @param [Hash]
    @services = {}

    # Create a new service
    #
    # @param [String] name
    #   The name of the service in docker
    # @param [String] image
    #   The Image that the service will use in docker
    # @return [Service]
    def self.create_service(name, image)
      @services[name] = Service.new(name, image)
    end

    # Does this service exist?
    #
    # @param [String] name
    #   The name of the service to check for
    # @return [Boolean]
    def self.service?(name)
      (@services[name])
    end

    # Return a Service
    #
    # @param [String] name
    #   The name of the service to return
    #
    # @return [Service]
    def self.get_service(name)
      @services[name] if self.service?(name)
    end

    # Convert The Services to Yaml
    def self.to_yaml
      yaml = {}

      @services.each do |key, obj|
        yaml[key] = obj.attrs
      end

      yaml.to_yaml
    end

    # Reset the List of Services
    def self.reset!
      @services = {}
    end

    # Import
    #
    # @param [Hash] yaml_object
    #   The yaml object to convert to services
    def self.import(yaml_object)
      yaml_object.each do |key, value|
        service = self.create_service(key, value['image'])
        service.import(value)
      end
    end
  end
end<commit_msg>Importing Support<commit_after>require 'yaml'
require 'docker-compose/generator/version'
require 'docker-compose/generator/service'

module DockerCompose
  # Static Generator Class
  # Used to create and keep track of services
  module Generator
    # Services Cache
    #
    # @param [Hash]
    @services = {}

    # Create a new service
    #
    # @param [String] name
    #   The name of the service in docker
    # @param [String] image
    #   The Image that the service will use in docker
    # @return [Service]
    def self.create_service(name, image)
      @services[name] = Service.new(name, image)
    end

    # Does this service exist?
    #
    # @param [String] name
    #   The name of the service to check for
    # @return [Boolean]
    def self.service?(name)
      (@services[name])
    end

    # Return a Service
    #
    # @param [String] name
    #   The name of the service to return
    #
    # @return [Service]
    def self.get_service(name)
      @services[name] if self.service?(name)
    end

    # Convert The Services to Yaml
    def self.to_yaml
      yaml = {}

      @services.each do |key, obj|
        yaml[key] = obj.attrs
      end

      yaml.to_yaml
    end

    # Reset the List of Services
    def self.reset!
      @services = {}
    end

    # Import
    #
    # @param [Hash] yaml_object
    #   The yaml object to convert to services
    def self.import(yaml_object)
      yaml_object.each do |key, value|
        service = create_service(key, value['image'])
        service.import(value)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09276378705769844, 'fraction_numerical': 0.0, 'mean_word_length': 2.2518134715025906, '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': '2623372', 'n_tokens_mistral': 991, 'n_tokens_neox': 954, 'n_words': 308}