<commit_before>package org.jenkinsci.plugins.vagrant;

/**
 * Created by elad on 9/18/14.
 */

import hudson.FilePath;
import hudson.Launcher;
import java.io.File;
import hudson.Proc;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;

import java.io.IOException;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.TreeMap;

public class VagrantWrapper {

  private final String vagrantFile;
  protected final String vagrantVm;

  transient private String vagrantFileName;
  transient private FilePath containingFolder;

  transient private AbstractBuild build;
  transient private Launcher launcher;
  transient private BuildListener listener;

  private boolean validated;

  public VagrantWrapper(String vagrantFile, String vagrantVm) {
    this.vagrantFile = vagrantFile;
    this.vagrantVm = vagrantVm;
    this.validated = false;
  }

  /**
   *
   * @return
   */
  public String getVagrantFileName() {
    return this.vagrantFileName;
  }

  /**
   *
   * @param build
   */
  public void setBuild(AbstractBuild build) {
    this.build = build;
  }

  /**
   *
   * @param launcher
   */
  public void setLauncher(Launcher launcher) {
    this.launcher = launcher;
  }

  /**
   *
   * @param listener
   */
  public void setListener(BuildListener listener) {
    this.listener = listener;
  }

  /**
   *
   * @return
   */

  public FilePath getContainingFolder() {
    return this.containingFolder;
  }

  /**
   *
   * @return
   */
  public String getVagrantFile() {
    return this.vagrantFile;
  }

  /**
   *
   * @return
   */
  public String getVagrantVm() {
    return this.vagrantVm;
  }

  /**
   *
   */
  protected void parseVagrantEnvironment() {
    if (this.vagrantFile == null) {
      this.vagrantFileName = "Vagrantfile";
      this.containingFolder = build.getWorkspace();
    } else {
      File file = new File(vagrantFile);
      this.vagrantFileName = file.getName();
      this.containingFolder = new FilePath(launcher.getChannel(), file.getAbsoluteFile().getParent());
    }
  }

  /**
   *
   * @param data
   */
  public void log(String data) {
    listener.getLogger().print("[ vagrant ]: ");
    listener.getLogger().println(data);
  }

  public void log(Throwable exception) {
    listener.getLogger().print("[ vagrant ]: ");
    exception.printStackTrace(listener.getLogger());
  }

  /**
   *
   * @param command<commit_msg>[ JENKINS-26326 ] Allow relative paths in the vagrantfile path<commit_after>package org.jenkinsci.plugins.vagrant;

/**
 * Created by elad on 9/18/14.
 */

import hudson.FilePath;
import hudson.Launcher;
import java.io.File;
import hudson.Proc;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;

import java.io.IOException;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.TreeMap;

public class VagrantWrapper {

  private final String vagrantFile;
  protected final String vagrantVm;

  transient private String vagrantFileName;
  transient private FilePath containingFolder;

  transient private AbstractBuild build;
  transient private Launcher launcher;
  transient private BuildListener listener;

  private boolean validated;

  public VagrantWrapper(String vagrantFile, String vagrantVm) {
    this.vagrantFile = vagrantFile;
    this.vagrantVm = vagrantVm;
    this.validated = false;
  }

  /**
   *
   * @return
   */
  public String getVagrantFileName() {
    return this.vagrantFileName;
  }

  /**
   *
   * @param build
   */
  public void setBuild(AbstractBuild build) {
    this.build = build;
  }

  /**
   *
   * @param launcher
   */
  public void setLauncher(Launcher launcher) {
    this.launcher = launcher;
  }

  /**
   *
   * @param listener
   */
  public void setListener(BuildListener listener) {
    this.listener = listener;
  }

  /**
   *
   * @return
   */

  public FilePath getContainingFolder() {
    return this.containingFolder;
  }

  /**
   *
   * @return
   */
  public String getVagrantFile() {
    return this.vagrantFile;
  }

  /**
   *
   * @return
   */
  public String getVagrantVm() {
    return this.vagrantVm;
  }

  /**
   *
   */
  protected void parseVagrantEnvironment() {
    if (this.vagrantFile == null) {
      this.vagrantFileName = "Vagrantfile";
      this.containingFolder = build.getWorkspace();
    } else {
      File file = new File(vagrantFile);
      this.vagrantFileName = file.getName();
      this.containingFolder = new FilePath(launcher.getChannel(), file.isAbsolute() ? file.getAbsoluteFile().getParent() : new File(build.getWorkspace().getRemote() + "/" + vagrantFile).getParent());
    }
  }

  /**
   *
   * @param data
   */
  public void log(String data) {
    listener.getLogger().print("[ vagrant ]: ");
    listener.getLogger().println(data);
  }

  public void log(Throwable exception) {
    listener.getLogger().print("[ vagrant ]: ");
    exception.printStackTrace(listener.getLogger());
  }

  /**
   *
   * @param command
{'fraction_non_alphanumeric': 0.11875249900039984, 'fraction_numerical': 0.0029988004798080768, 'mean_word_length': 3.064175467099919, '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': '4554687', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1600, 'n_words': 333}