<commit_before>module Conjure
  module Provision
    module Docker
      class Image
        attr_reader :image_name

        def initialize(docker_host, image_name)
          @docker_host = docker_host
          @name = image_name
        end

        def start_volume(options = {})
          @docker_host.started_container_id @name, "/bin/true", daemon_options(options)
        end

        def start_daemon(command, options = {})
          container_id = @docker_host.started_container_id @name, command, daemon_options(options)
          sleep 2
          ip_address = @docker_host.container_ip_address container_id
          raise "Container failed to start" unless ip_address.present?
          ip_address
        end

        private

        def volume_options(options)
          "-d " + run_options(options)
        end

        def daemon_options(options)
          "-d --restart=always " + run_options(options)
        end

        def run_options(options)
          [
            mapped_options("--link", options[:linked_containers]),
            ("--name #{options[:name]}" if options[:name]),
            mapped_options("-p", options[:ports]),
            listed_options("--volumes-from", options[:volume_containers]),
          ].flatten.compact.join(" ")
        end

        def listed_options(command, values)
          values ||= []
          values.map { |v| "#{command} #{v}" }
        end

        def mapped_options(command, values)
          values ||= {}<commit_msg>Remove ActiveSupport dependency<commit_after>module Conjure
  module Provision
    module Docker
      class Image
        attr_reader :image_name

        def initialize(docker_host, image_name)
          @docker_host = docker_host
          @name = image_name
        end

        def start_volume(options = {})
          @docker_host.started_container_id @name, "/bin/true", daemon_options(options)
        end

        def start_daemon(command, options = {})
          container_id = @docker_host.started_container_id @name, command, daemon_options(options)
          sleep 2
          ip_address = @docker_host.container_ip_address container_id
          raise "Container failed to start" if ip_address.to_s == ""
          ip_address
        end

        private

        def volume_options(options)
          "-d " + run_options(options)
        end

        def daemon_options(options)
          "-d --restart=always " + run_options(options)
        end

        def run_options(options)
          [
            mapped_options("--link", options[:linked_containers]),
            ("--name #{options[:name]}" if options[:name]),
            mapped_options("-p", options[:ports]),
            listed_options("--volumes-from", options[:volume_containers]),
          ].flatten.compact.join(" ")
        end

        def listed_options(command, values)
          values ||= []
          values.map { |v| "#{command} #{v}" }
        end

        def mapped_options(command, values)
          values ||= {}
{'fraction_non_alphanumeric': 0.10507004669779853, 'fraction_numerical': 0.00066711140760507, 'mean_word_length': 2.0949432404540764, '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': '5200618', 'n_tokens_mistral': 839, 'n_tokens_neox': 808, 'n_words': 174}