<commit_before># encoding: UTF-8
require 'rspec'
require 'fileutils'
require 'tempfile'
require 'pathname'
require 'base64'
require_relative '../lib/rivet'

Rivet::Log.level(Logger::FATAL)

module SpecHelpers
  AUTOSCALE_DIR      = File.join('.', 'autoscale')
  CONFIG_FILE        = File.join(AUTOSCALE_DIR, 'unit_test.rb')
  TEMPLATE_FILE      = File.join(AUTOSCALE_DIR, 'default.erb')
  BOOTSTRAP_TEMPLATE = '<%= "bar" %>'\

  DSL_VALUES = {
    :min_size                     => '1',
    :desired_capacity             => '1',
    :max_size                     => '3',
    :region                       => "'us-west-2'",
    :availability_zones           => '%w(b c a)',
    :key_name                     => "'UnitTests'",
    :instance_type                => "'m1.large'",
    :security_groups              => '%w(unit_test3 unit_tests1 unit_tests2)',
    :image_id                     => "'ami-12345678'",
    :iam_instance_profile         => "'unit_test_profile'",
    :default_cooldown             => '300',
    :placement_group              => "'unit test placement group'",
    :health_check_type            => ':ec2',
    :termination_policies         => '%w(policy2 policy1)',
    :load_balancers               => '%w(balancer2 balancer1)',
    :health_check_grace_period    => '100',
    :associate_public_ip_address  => 'true',
    :detailed_instance_monitoring => 'true',
    :block_device_mappings        => "[{:device_name => '/dev/sda1', :virtual_name => 'ephemeral0'}]",
    :kernel_id                    => "'aki-12345678'",
    :ramdisk_id                   => "'ari-12345678'",
    :spot_price                   => "'0.01'",
    :bootstrap                    => {
      :template => "'#{TEMPLATE_FILE}'",
      :foo => "'bar'"
    }
  }
  DSL_CONFIG_CONTENT = DSL_VALUES.inject(String.new) do |a, (k, v)|
    if k == :bootstrap
      v.each_pair do |bootstrap_attr, bootstrap_value|
        a << "bootstrap.#{bootstrap_attr} #{bootstrap_value}\n"
      end
    else
      a << "#{k} #{v}\n";
    end
    a
  end

  AUTOSCALE_IDENTITY_STRING = "bootstrap#{Base64.encode64('unit_test_user_data')}"\
                              "iam_instance_profile#{Base64.encode64(eval(DSL_VALUES[:iam_instance_profile]))}"\
                              "image_id#{Base64.encode64(eval(DSL_VALUES[:image_id]))}"\
                              "instance_type#{Base64.encode64(eval(DSL_VALUES[:instance_type]))}"\
                              "key_name#{Base64.encode64(eval(DSL_VALUES[:key_name]))}"\<commit_msg>Removes use of semicolon to terminate an expression when it wasn't needed<commit_after># encoding: UTF-8
require 'rspec'
require 'fileutils'
require 'tempfile'
require 'pathname'
require 'base64'
require_relative '../lib/rivet'

Rivet::Log.level(Logger::FATAL)

module SpecHelpers
  AUTOSCALE_DIR      = File.join('.', 'autoscale')
  CONFIG_FILE        = File.join(AUTOSCALE_DIR, 'unit_test.rb')
  TEMPLATE_FILE      = File.join(AUTOSCALE_DIR, 'default.erb')
  BOOTSTRAP_TEMPLATE = '<%= "bar" %>'\

  DSL_VALUES = {
    :min_size                     => '1',
    :desired_capacity             => '1',
    :max_size                     => '3',
    :region                       => "'us-west-2'",
    :availability_zones           => '%w(b c a)',
    :key_name                     => "'UnitTests'",
    :instance_type                => "'m1.large'",
    :security_groups              => '%w(unit_test3 unit_tests1 unit_tests2)',
    :image_id                     => "'ami-12345678'",
    :iam_instance_profile         => "'unit_test_profile'",
    :default_cooldown             => '300',
    :placement_group              => "'unit test placement group'",
    :health_check_type            => ':ec2',
    :termination_policies         => '%w(policy2 policy1)',
    :load_balancers               => '%w(balancer2 balancer1)',
    :health_check_grace_period    => '100',
    :associate_public_ip_address  => 'true',
    :detailed_instance_monitoring => 'true',
    :block_device_mappings        => "[{:device_name => '/dev/sda1', :virtual_name => 'ephemeral0'}]",
    :kernel_id                    => "'aki-12345678'",
    :ramdisk_id                   => "'ari-12345678'",
    :spot_price                   => "'0.01'",
    :bootstrap                    => {
      :template => "'#{TEMPLATE_FILE}'",
      :foo => "'bar'"
    }
  }
  DSL_CONFIG_CONTENT = DSL_VALUES.inject(String.new) do |a, (k, v)|
    if k == :bootstrap
      v.each_pair do |bootstrap_attr, bootstrap_value|
        a << "bootstrap.#{bootstrap_attr} #{bootstrap_value}\n"
      end
    else
      a << "#{k} #{v}\n"
    end
    a
  end

  AUTOSCALE_IDENTITY_STRING = "bootstrap#{Base64.encode64('unit_test_user_data')}"\
                              "iam_instance_profile#{Base64.encode64(eval(DSL_VALUES[:iam_instance_profile]))}"\
                              "image_id#{Base64.encode64(eval(DSL_VALUES[:image_id]))}"\
                              "instance_type#{Base64.encode64(eval(DSL_VALUES[:instance_type]))}"\
                              "key_name#{Base64.encode64(eval(DSL_VALUES[:key_name]))}"\
{'fraction_non_alphanumeric': 0.15275868839583742, 'fraction_numerical': 0.02788140585116827, 'mean_word_length': 2.10989010989011, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 59, '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': '2712908', 'n_tokens_mistral': 1732, 'n_tokens_neox': 1656, 'n_words': 252}