@Override public String apply(String input) { String variableNameKey = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, input) + "Variable"; if (ShellToken.tokenValueMap(family).containsKey(variableNameKey)) return ShellToken.tokenValueMap(family).get(variableNameKey); return input; } }
@Override public String apply(String input) { String variableNameKey = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, input) + "Variable"; if (ShellToken.tokenValueMap(family).containsKey(variableNameKey)) return ShellToken.tokenValueMap(family).get(variableNameKey); return input; } }
@Override public String apply(String input) { String variableNameKey = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, input) + "Variable"; if (ShellToken.tokenValueMap(family).containsKey(variableNameKey)) return ShellToken.tokenValueMap(family).get(variableNameKey); return input; } }
@Override public String apply(String input) { String variableNameKey = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, input) + "Variable"; if (ShellToken.tokenValueMap(family).containsKey(variableNameKey)) return ShellToken.tokenValueMap(family).get(variableNameKey); return input; } }
@Override public String apply(String input) { String variableNameKey = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, input) + "Variable"; if (ShellToken.tokenValueMap(family).containsKey(variableNameKey)) return ShellToken.tokenValueMap(family).get(variableNameKey); return input; } }
public String render(OsFamily family) { StringBuilder args = new StringBuilder(); for (String arg : this.args) { args.append(" ").append(Utils.replaceTokens(arg, ShellToken.tokenValueMap(family))); } StringBuilder call = new StringBuilder(); call.append(Utils.replaceTokens(OS_TO_CALL.get(family), ImmutableMap.of("function", function, "args", args.toString()))); return call.toString(); }
public String render(OsFamily family) { StringBuilder args = new StringBuilder(); for (String arg : this.args) { args.append(" ").append(Utils.replaceTokens(arg, ShellToken.tokenValueMap(family))); } StringBuilder call = new StringBuilder(); call.append(Utils.replaceTokens(OS_TO_CALL.get(family), ImmutableMap.of("function", function, "args", args.toString()))); return call.toString(); }
public String render(OsFamily family) { StringBuilder args = new StringBuilder(); for (String arg : this.args) { args.append(" ").append(Utils.replaceTokens(arg, ShellToken.tokenValueMap(family))); } StringBuilder call = new StringBuilder(); call.append(Utils.replaceTokens(OS_TO_CALL.get(family), ImmutableMap.of("function", function, "args", args.toString()))); return call.toString(); }
public String render(OsFamily family) { StringBuilder args = new StringBuilder(); for (String arg : this.args) { args.append(" ").append(Utils.replaceTokens(arg, ShellToken.tokenValueMap(family))); } StringBuilder call = new StringBuilder(); call.append(Utils.replaceTokens(OS_TO_CALL.get(family), ImmutableMap.of("function", function, "args", args.toString()))); return call.toString(); }
public String render(OsFamily family) { StringBuilder args = new StringBuilder(); for (String arg : this.args) { args.append(" ").append(Utils.replaceTokens(arg, ShellToken.tokenValueMap(family))); } StringBuilder call = new StringBuilder(); call.append(Utils.replaceTokens(OS_TO_CALL.get(family), ImmutableMap.of("function", function, "args", args.toString()))); return call.toString(); }
public String render(OsFamily family) { StringBuilder args = new StringBuilder(); for (String arg : this.args) { args.append(" ").append(Utils.replaceTokens(arg, ShellToken.tokenValueMap(family))); } StringBuilder call = new StringBuilder(); call.append(Utils.replaceTokens(OS_TO_CALL.get(family), ImmutableMap.of("function", function, "args", args.toString()))); return call.toString(); }
public static void writeFunctions(Map<String, String> functionsToWrite, OsFamily osFamily, StringBuilder builder) { if (functionsToWrite.size() > 0) { builder.append(ShellToken.BEGIN_FUNCTIONS.to(osFamily)); for (String function : functionsToWrite.values()) { builder.append(Utils.replaceTokens(function, ShellToken.tokenValueMap(osFamily))); } builder.append(ShellToken.END_FUNCTIONS.to(osFamily)); } }
public String render(OsFamily family) { return Utils .replaceTokens(Joiner.on(ShellToken.LF.to(family)).join(statements), ShellToken.tokenValueMap(family)); }
public static void writeFunctions(Map<String, String> functionsToWrite, OsFamily osFamily, StringBuilder builder) { if (functionsToWrite.size() > 0) { builder.append(ShellToken.BEGIN_FUNCTIONS.to(osFamily)); for (String function : functionsToWrite.values()) { builder.append(Utils.replaceTokens(function, ShellToken.tokenValueMap(osFamily))); } builder.append(ShellToken.END_FUNCTIONS.to(osFamily)); } }
public static void writeFunctions(Map<String, String> functionsToWrite, OsFamily osFamily, StringBuilder builder) { if (!functionsToWrite.isEmpty()) { builder.append(ShellToken.BEGIN_FUNCTIONS.to(osFamily)); for (String function : functionsToWrite.values()) { builder.append(Utils.replaceTokens(function, ShellToken.tokenValueMap(osFamily))); } builder.append(ShellToken.END_FUNCTIONS.to(osFamily)); } }
public static void writeFunctions(Map<String, String> functionsToWrite, OsFamily osFamily, StringBuilder builder) { if (!functionsToWrite.isEmpty()) { builder.append(ShellToken.BEGIN_FUNCTIONS.to(osFamily)); for (String function : functionsToWrite.values()) { builder.append(Utils.replaceTokens(function, ShellToken.tokenValueMap(osFamily))); } builder.append(ShellToken.END_FUNCTIONS.to(osFamily)); } }
public static void writeFunctions(Map<String, String> functionsToWrite, OsFamily osFamily, StringBuilder builder) { if (functionsToWrite.size() > 0) { builder.append(ShellToken.BEGIN_FUNCTIONS.to(osFamily)); for (String function : functionsToWrite.values()) { builder.append(Utils.replaceTokens(function, ShellToken.tokenValueMap(osFamily))); } builder.append(ShellToken.END_FUNCTIONS.to(osFamily)); } }
public static void writeFunctions(Map<String, String> functionsToWrite, OsFamily osFamily, StringBuilder builder) { if (!functionsToWrite.isEmpty()) { builder.append(ShellToken.BEGIN_FUNCTIONS.to(osFamily)); for (String function : functionsToWrite.values()) { builder.append(Utils.replaceTokens(function, ShellToken.tokenValueMap(osFamily))); } builder.append(ShellToken.END_FUNCTIONS.to(osFamily)); } }
public void testTokenValueMapUNIX() { Map<String, String> expected = new ImmutableMap.Builder<String, String>().put("fs", "/").put( "ps", ":").put("lf", "\n").put("sh", "sh").put("source", ".").put("rem", "#").put( "args", "$@").put("varl", "$").put("return", "return").put("exit", "exit").put( "varr", "").put("libraryPathVariable", "LD_LIBRARY_PATH").put("beginScript", "#!/bin/bash\nset +u\nshopt -s xpg_echo\nshopt -s expand_aliases\n").put( "endScript", "exit $?\n").put("vq", "\"").put("beginFunctions", "").put( "endFunctions", "").put("fncl", "function ").put("fncr", " {\n").put("fnce", " return $?\n}\n").put("export", "export").put("rm", "rm").put("cd", "cd").put( "tmp", "/tmp").put("uid", "$USER").put("root", "/").put("closeFd", ">&-").put("md", "mkdir -p").put("escvar", "\\").build(); assertEquals(ShellToken.tokenValueMap(OsFamily.UNIX), expected); }
public void testSingleCurlyBraceDoesntBreakLfTokenReplacement() { assertEquals(Utils.replaceTokens("{{lf}", ShellToken.tokenValueMap(OsFamily.UNIX)), "{\n"); }