<commit_before>require 'thor'
require 'aws-sdk'

module Gantree

  class Init
    def initialize image,options
      @image = image
      @options = merge_defaults(options)
      AWS.config(
        :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
        :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'])
      @s3 = AWS::S3.new
    end

    def run
      puts "initialize image #{@image}"
      puts "with user #{@options.user}" if @options.user
      FileUtils.rm("Dockerrun.aws.json") if File.exist?("Dockerrun.aws.json")
      create_docker_config_folder
      create_dockerrun
      upload_docker_config if @options.user
    end

    def create_docker_config_folder
      bucket = @s3.buckets.create("docker-cfgs")
    end

    def dockerrun_object
      docker = {
        AWSEBDockerrunVersion: "1",
        Image: {
          Name: @image,
          Update: true
        },
        Logging: "/var/log/nginx",
        Ports: [
          {
            ContainerPort: @options.port
          }
        ]
      }
      if @options.user
        docker["Authentication"] = {
          Bucket: "docker-cfgs",
          Key: "#{@options.user}.dockercfg"
        }
      end
      docker
    end

    def create_dockerrun
      IO.write("Dockerrun.aws.json",JSON.pretty_generate(dockerrun_object))
    end

    def upload_docker_config
      raise "You need to run 'docker login' to generate a .dockercfg file" if File.exist?("#{ENV['HOME']}/.dockercfg") != true
      filename = "#{ENV['HOME']}/#{@options.user}.dockercfg"
      FileUtils.cp("#{ENV['HOME']}/.dockercfg", "#{ENV['HOME']}/#{@options.user}.dockercfg")
      key = File.basename(filename)
      @s3.buckets["docker-cfgs"].objects[key].write(:file => filename)
    end

    def merge_defaults(options)
      if File.exist?(".gantree.cfg")
        defaults = JSON.parse(File.open(".gantree.cfg").read)
        defaults.merge(options)
      else
        options
      end
    end
  end
end
<commit_msg>remove '.' from file name<commit_after>require 'thor'
require 'aws-sdk'

module Gantree

  class Init
    def initialize image,options
      @image = image
      @options = merge_defaults(options)
      AWS.config(
        :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
        :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'])
      @s3 = AWS::S3.new
    end

    def run
      puts "initialize image #{@image}"
      puts "with user #{@options.user}" if @options.user
      FileUtils.rm("Dockerrun.aws.json") if File.exist?("Dockerrun.aws.json")
      create_docker_config_folder
      create_dockerrun
      upload_docker_config if @options.user
    end

    def create_docker_config_folder
      bucket = @s3.buckets.create("docker-cfgs")
    end

    def dockerrun_object
      docker = {
        AWSEBDockerrunVersion: "1",
        Image: {
          Name: @image,
          Update: true
        },
        Logging: "/var/log/nginx",
        Ports: [
          {
            ContainerPort: @options.port
          }
        ]
      }
      if @options.user
        docker["Authentication"] = {
          Bucket: "docker-cfgs",
          Key: "#{@options.user}.dockercfg"
        }
      end
      docker
    end

    def create_dockerrun
      IO.write("Dockerrun.aws.json",JSON.pretty_generate(dockerrun_object))
    end

    def upload_docker_config
      raise "You need to run 'docker login' to generate a .dockercfg file" if File.exist?("#{ENV['HOME']}/.dockercfg") != true
      filename = "#{ENV['HOME']}/#{@options.user}.dockercfg"
      FileUtils.cp("#{ENV['HOME']}/.dockercfg", "#{ENV['HOME']}/#{@options.user}.dockercfg")
      key = File.basename(filename)
      @s3.buckets["docker-cfgs"].objects[key].write(:file => filename)
    end

    def merge_defaults(options)
      if File.exist?(".gantreecfg")
        defaults = JSON.parse(File.open(".gantreecfg").read)
        defaults.merge(options)
      else
        options
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.13155216284987278, 'fraction_numerical': 0.002544529262086514, 'mean_word_length': 2.33135593220339, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3666696', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1271, 'n_words': 237}