<commit_before># pinocchio/api/vagrant
module Pinocchio
  def self.assign_test_manifest test_manifest
    source_dir = test_manifest
    dest_dir   = File.join(Pinocchio.manifests_path, Pinocchio.manifest_file)
    FileUtils.copy_file(source_dir, dest_dir)
  end

  def self.vagrant_init
    @vagrant = Vagrant::Prison.new

    @vagrant.configure do |config|
      config.vm.host_name = 'puppet.pinocchio.test'
      ## XXX: parameterize this (in cucumber given?)
      Pinocchio.exposed_ports.each do |port|
        guest_port = port.to_i
        host_port  = guest_port + 1000
        config.vm.forward_port guest_port, host_port
      end
      Pinocchio.boxes.each do |box_name, box_url|
        config.vm.define box_name.to_sym do |c|
          c.vm.box     = box_name
          c.vm.box_url = box_url
          c.vm.provision :puppet do |puppet|
            puppet.module_path    = 'modules'
            puppet.manifests_path = Pinocchio.manifests_path
            puppet.manifest_file  = Pinocchio.manifest_file
          end
        end
      end
    end
    return @vagrant
  end

  def self.vagrant_provision box_name
    Vagrant::Command::Provision.new([box_name], @vagrant.construct(:ui_class => Vagrant::UI::Basic)).execute
  end

  def self.vagrant_up box_name
    # even though we dont care yet, vagrant still needs puppet.manifest_file to exist on vagrant up
    FileUtils.touch File.join(Pinocchio.manifests_path, Pinocchio.manifest_file)
    FileUtils.mkdir_p Pinocchio.vagrant_prison_module_dir
    Vagrant::Command::Up.new([box_name, '--no-provision'], @vagrant.construct(:ui_class => Vagrant::UI::Basic)).execute
    Pinocchio.sync_module_fixtures
  end

  def self.vagrant_prison_module_dir
    vagrant_prison_basedir = @vagrant.construct.cwd.to_s
    return File.join(vagrant_prison_basedir, 'modules')
  end

  def self.sync_module_fixtures
    ## since spec/fixtures/modules is full of symlinks, we can't just use
    ## it as vagrant's modulepath for puppet because they'd all be broken.
    ## instead, we copy what we need into the vagrant prison's dir.
    source_files = Dir.glob(File.join(Pinocchio.module_path, '*'))
    ## XXX: assumes constant of relative path 'modules' in vagrant config; support others

    # module_path = @vagrant.construct.config.global.vm.provisioners.first.config.module_path.to_s
    FileUtils.cp_r(source_files, dest_dir)
  end
end<commit_msg>not sure how i missed that<commit_after># pinocchio/api/vagrant
module Pinocchio
  def self.assign_test_manifest test_manifest
    source_dir = test_manifest
    dest_dir   = File.join(Pinocchio.manifests_path, Pinocchio.manifest_file)
    FileUtils.copy_file(source_dir, dest_dir)
  end

  def self.vagrant_init
    @vagrant = Vagrant::Prison.new

    @vagrant.configure do |config|
      config.vm.host_name = 'puppet.pinocchio.test'
      ## XXX: parameterize this (in cucumber given?)
      Pinocchio.exposed_ports.each do |port|
        guest_port = port.to_i
        host_port  = guest_port + 1000
        config.vm.forward_port guest_port, host_port
      end
      Pinocchio.boxes.each do |box_name, box_url|
        config.vm.define box_name.to_sym do |c|
          c.vm.box     = box_name
          c.vm.box_url = box_url
          c.vm.provision :puppet do |puppet|
            puppet.module_path    = 'modules'
            puppet.manifests_path = Pinocchio.manifests_path
            puppet.manifest_file  = Pinocchio.manifest_file
          end
        end
      end
    end
    return @vagrant
  end

  def self.vagrant_provision box_name
    Vagrant::Command::Provision.new([box_name], @vagrant.construct(:ui_class => Vagrant::UI::Basic)).execute
  end

  def self.vagrant_up box_name
    # even though we dont care yet, vagrant still needs puppet.manifest_file to exist on vagrant up
    FileUtils.touch File.join(Pinocchio.manifests_path, Pinocchio.manifest_file)
    FileUtils.mkdir_p Pinocchio.vagrant_prison_module_dir
    Vagrant::Command::Up.new([box_name, '--no-provision'], @vagrant.construct(:ui_class => Vagrant::UI::Basic)).execute
    Pinocchio.sync_module_fixtures
  end

  def self.vagrant_prison_module_dir
    vagrant_prison_basedir = @vagrant.construct.cwd.to_s
    return File.join(vagrant_prison_basedir, 'modules')
  end

  def self.sync_module_fixtures
    ## since spec/fixtures/modules is full of symlinks, we can't just use
    ## it as vagrant's modulepath for puppet because they'd all be broken.
    ## instead, we copy what we need into the vagrant prison's dir.
    source_files = Dir.glob(File.join(Pinocchio.module_path, '*'))
    ## XXX: assumes constant of relative path 'modules' in vagrant config; support others
    dest_dir = Pinocchio.vagrant_prison_module_dir
    FileUtils.cp_r(source_files, dest_dir)
  end
end
{'fraction_non_alphanumeric': 0.08721174004192872, 'fraction_numerical': 0.0016771488469601676, 'mean_word_length': 3.3372727272727274, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2334031', 'n_tokens_mistral': 1653, 'n_tokens_neox': 1599, 'n_words': 342}