<commit_before>require 'ostruct'

class AutomationParserFactory

  # the currency of this parser factory is the "short" single-letter argument switch
  def initialize()
    @options = nil
    @switches = {}

    # build the list of how each parameter will be saved in the output
    @letterMap = {
      "x" => "defaultXcode",
      "p" => "testPath",
      "a" => "appName",
      "t" => "tagsAny",
      "o" => "tagsAll",
      "n" => "tagsNone",
      "s" => "scheme",
      "j" => "plistSettingsPath",
      "d" => "hardwareID",
      "i" => "implementation",
      "b" => "simDevice",
      "z" => "simVersion",
      "l" => "simLanguage",
      "f" => "skipBuild",
      "e" => "skipSetSim",
      "k" => "skipKillAfter",
      "c" => "coverage",
      "r" => "report",
      "v" => "verbose",
      "m" => "timeout",
      "w" => "randomSeed",
      "y" => "skipClean",
    }

    @letterProcessing = {
      "j" => lambda {|p| (Pathname.new p).realpath().to_s },     # get real path to pList
    }

    @defaultValues = {'x'=>'/Applications/Xcode.app',
                      'i'=>"iPhone",
                      "b" => "iPhone Retina (4-inch)",
                      "z" => "iOS 7.1",
                      'l' => 'en',
                      'm' => 30 }
  end

  # you must custom prepare before you can add custom switches... otherwise things get all stupid
  def prepare(defaultValues = nil, letterMapUpdates = nil, letterProcessingUpdates = nil)
    @letterMap = @letterMap.merge(letterMapUpdates) unless letterMapUpdates.nil?
    @letterProcessing = @letterProcessing.merge(letterProcessingUpdates) unless letterProcessingUpdates.nil?
    @defaultValues = @defaultValues.merge defaultValues unless defaultValues.nil?

    self.addSwitch("x", ["-x", "--xcode PATH", "Sets path to default Xcode installation "])
    self.addSwitch("p", ["-p", "--testPath PATH", "Path to js file with all tests imported"])
    self.addSwitch("a", ["-a", "--appName APPNAME", "App name to run"])
    self.addSwitch("t", ["-t", "--tags-any TAGSANY", "Run tests with any of the given tags"])
    self.addSwitch("o", ["-o", "--tags-all TAGSALL", "Run tests with all of the given tags"])
    self.addSwitch("n", ["-n", "--tags-none TAGSNONE", "Run tests with none of the given tags"])
    self.addSwitch("s", ["-s", "--scheme SCHEME", "Build and run specific tests on given workspace scheme"])
    self.addSwitch("j", ["-j", "--plistSettingsPath PATH", "path to settings plist"])
    self.addSwitch("d", ["-d", "--hardwareID ID", "hardware id of device you run on"])
    self.addSwitch("i", ["-i", "--implementation IMPL", "Device tests implementation (iPhone|iPad)"])
    self.addSwitch("b", ["-b", "--simDevice DEVICE", "Run on given simulated device"])
    self.addSwitch("z", ["-z", "--simVersion VERSION", "Run on given simulated iOS version"])
    self.addSwitch("l", ["-l", "--simLanguage LANGUAGE", "Run on given simulated iOS language"])
    self.addSwitch("f", ["-f", "--skip-build", "Just automate; assume already built"])
    self.addSwitch("e", ["-e", "--skip-set-sim", "Assume that simulator has already been chosen and properly reset"])
    self.addSwitch("k", ["-k", "--skip-kill-after", "Do not kill the simulator after the run"])
    self.addSwitch("c", ["-c", "--coverage", "Generate coverage files"])
    self.addSwitch("r", ["-r", "--report", "Generate Xunit reports in buildArtifacts/UIAutomationReport folder"])
    self.addSwitch("v", ["-v", "--verbose", "Show verbose output"])
    self.addSwitch("m", ["-m", "--timeout TIMEOUT", "startup timeout"])
    self.addSwitch("w", ["-w", "--random-seed SEED", "Randomize test order based on given integer seed"])
    self.addSwitch("y", ["-y", "--skipClean", "Skip clean when building"])
  end
<commit_msg>fix consistency of arguments<commit_after>require 'ostruct'

class AutomationParserFactory

  # the currency of this parser factory is the "short" single-letter argument switch
  def initialize()
    @options = nil
    @switches = {}

    # build the list of how each parameter will be saved in the output
    @letterMap = {
      "x" => "defaultXcode",
      "p" => "testPath",
      "a" => "appName",
      "t" => "tagsAny",
      "o" => "tagsAll",
      "n" => "tagsNone",
      "s" => "scheme",
      "j" => "plistSettingsPath",
      "d" => "hardwareID",
      "i" => "implementation",
      "b" => "simDevice",
      "z" => "simVersion",
      "l" => "simLanguage",
      "f" => "skipBuild",
      "e" => "skipSetSim",
      "k" => "skipKillAfter",
      "c" => "coverage",
      "r" => "report",
      "v" => "verbose",
      "m" => "timeout",
      "w" => "randomSeed",
      "y" => "skipClean",
    }

    @letterProcessing = {
      "j" => lambda {|p| (Pathname.new p).realpath().to_s },     # get real path to pList
    }

    @defaultValues = {'x'=>'/Applications/Xcode.app',
                      'i'=>"iPhone",
                      "b" => "iPhone Retina (4-inch)",
                      "z" => "iOS 7.1",
                      'l' => 'en',
                      'm' => 30 }
  end

  # you must custom prepare before you can add custom switches... otherwise things get all stupid
  def prepare(defaultValues = nil, letterMapUpdates = nil, letterProcessingUpdates = nil)
    @letterMap = @letterMap.merge(letterMapUpdates) unless letterMapUpdates.nil?
    @letterProcessing = @letterProcessing.merge(letterProcessingUpdates) unless letterProcessingUpdates.nil?
    @defaultValues = @defaultValues.merge defaultValues unless defaultValues.nil?

    self.addSwitch("x", ["-x", "--xcode PATH", "Sets path to default Xcode installation "])
    self.addSwitch("p", ["-p", "--testPath PATH", "Path to js file with all tests imported"])
    self.addSwitch("a", ["-a", "--appName APPNAME", "App name to run"])
    self.addSwitch("t", ["-t", "--tags-any TAGSANY", "Run tests with any of the given tags"])
    self.addSwitch("o", ["-o", "--tags-all TAGSALL", "Run tests with all of the given tags"])
    self.addSwitch("n", ["-n", "--tags-none TAGSNONE", "Run tests with none of the given tags"])
    self.addSwitch("s", ["-s", "--scheme SCHEME", "Build and run specific tests on given workspace scheme"])
    self.addSwitch("j", ["-j", "--plistSettingsPath PATH", "path to settings plist"])
    self.addSwitch("d", ["-d", "--hardwareID ID", "hardware id of device you run on"])
    self.addSwitch("i", ["-i", "--implementation IMPL", "Device tests implementation (iPhone|iPad)"])
    self.addSwitch("b", ["-b", "--simDevice DEVICE", "Run on given simulated device"])
    self.addSwitch("z", ["-z", "--simVersion VERSION", "Run on given simulated iOS version"])
    self.addSwitch("l", ["-l", "--simLanguage LANGUAGE", "Run on given simulated iOS language"])
    self.addSwitch("f", ["-f", "--skip-build", "Just automate; assume already built"])
    self.addSwitch("e", ["-e", "--skip-set-sim", "Assume that simulator has already been chosen and properly reset"])
    self.addSwitch("k", ["-k", "--skip-kill-after", "Do not kill the simulator after the run"])
    self.addSwitch("y", ["-y", "--skip-clean", "Skip clean when building"])
    self.addSwitch("c", ["-c", "--coverage", "Generate coverage files"])
    self.addSwitch("r", ["-r", "--report", "Generate Xunit reports in buildArtifacts/UIAutomationReport folder"])
    self.addSwitch("v", ["-v", "--verbose", "Show verbose output"])
    self.addSwitch("m", ["-m", "--timeout TIMEOUT", "startup timeout"])
    self.addSwitch("w", ["-w", "--random-seed SEED", "Randomize test order based on given integer seed"])
  end

{'fraction_non_alphanumeric': 0.1889920424403183, 'fraction_numerical': 0.001326259946949602, 'mean_word_length': 3.074014046461372, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 61, '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': '7385533', 'n_tokens_mistral': 2375, 'n_tokens_neox': 2300, 'n_words': 711}