<commit_before>require 'serverspec'
require 'pathname'
require 'net/ssh'

include Serverspec::Helper::Ssh
include Serverspec::Helper::DetectOS

RSpec.configure do |c|
  if ENV['ASK_SUDO_PASSWORD']
    require 'highline/import'
    c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false }
  else
    c.sudo_password = ENV['<PASSWORD>']
  end
  c.before :all do
    block = self.class.metadata[:example_group_block]
    if RUBY_VERSION.start_with?('1.8')
      file = block.to_s.match(/.*@(.*):[0-9]+>/)[1]
    else
      file = block.source_location.first
    end
    pwd = Pathname.new(file).dirname
    c.add_setting :pwd
    if c.pwd != pwd
      c.ssh.close if c.ssh
      c.pwd = <PASSWORD>

      vagrant_up = `vagrant up`

      user = Etc.getlogin
      options = {}
      config = `vagrant ssh-config`
      config.each_line do |line|
        if match = /HostName (.*)/.match(line)
          c.host = match[1]
          options = Net::SSH::Config.for(c.host)
        elsif  match = /User (.*)/.match(line)
          user = match[1]
        elsif match = /IdentityFile (.*)/.match(line)
          options[:keys] = [match[1].gsub(/"/, '')]
        elsif match = /Port (.*)/.match(line)
          options[:port] = match[1]
        end
      end
      c.ssh = Net::SSH.start(c.host, user, options)


      manifest = File.join(Pathname.new(file).dirname, 'manifest.pp')
      manifest = manifest.sub(Dir.getwd, '/vagrant')
      provisioner = "sudo puppet apply --detailed-exitcodes --verbose --modulepath '/vagrant/modules' #{manifest.shellescape} || [ $? -eq 2 ]"
      c.ssh.exec!(provisioner)
    end
  end
end
<commit_msg>Added basic snapshots<commit_after>require 'serverspec'
require 'pathname'
require 'net/ssh'

include Serverspec::Helper::Ssh
include Serverspec::Helper::DetectOS

RSpec.configure do |c|
  if ENV['ASK_SUDO_PASSWORD']
    require 'highline/import'
    c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false }
  else
    c.sudo_password = ENV['<PASSWORD>']
  end
  c.before :all do
    block = self.class.metadata[:example_group_block]
    if RUBY_VERSION.start_with?('1.8')
      file = block.to_s.match(/.*@(.*):[0-9]+>/)[1]
    else
      file = block.source_location.first
    end
    pwd = Pathname.new(file).dirname
    c.add_setting :pwd
    if c.pwd != pwd
      c.pwd = <PASSWORD>

      if c.ssh
        c.ssh.close
        vagrant_snapshot_go = `vagrant snapshot go default default-test-snapshot`
      else
        vagrant_up = `vagrant up`
        vagrant_snapshot_take = `vagrant snapshot take default default-test-snapshot`
      end

      user = Etc.getlogin
      options = {}
      config = `vagrant ssh-config`
      config.each_line do |line|
        if match = /HostName (.*)/.match(line)
          c.host = match[1]
          options = Net::SSH::Config.for(c.host)
        elsif  match = /User (.*)/.match(line)
          user = match[1]
        elsif match = /IdentityFile (.*)/.match(line)
          options[:keys] = [match[1].gsub(/"/, '')]
        elsif match = /Port (.*)/.match(line)
          options[:port] = match[1]
        end
      end
      c.ssh = Net::SSH.start(c.host, user, options)

      manifest = File.join(Pathname.new(file).dirname, 'manifest.pp')
      manifest = manifest.sub(Dir.getwd, '/vagrant')
      provisioner = "sudo puppet apply --detailed-exitcodes --verbose --modulepath '/vagrant/modules' #{manifest.shellescape} || [ $? -eq 2 ]"
      c.ssh.exec!(provisioner)
    end
  end
end

{'fraction_non_alphanumeric': 0.1522610188895249, 'fraction_numerical': 0.005724098454493417, 'mean_word_length': 2.495, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3906100', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1219, 'n_words': 252}