Package ro.isdc.wro.extensions.script

Examples of ro.isdc.wro.extensions.script.RhinoScriptBuilder.evaluate()


    // TODO handle reservedNames
    final String optionsAsJson = createOptionsAsJson();
    Validate.notNull(optionsAsJson);
    final String scriptAsString = String.format(getInvokeScript(), originalCode, optionsAsJson);
    watch.start(uglify ? "uglify" : "beautify");
    final Object result = builder.evaluate(scriptAsString, "uglifyIt");
   
    watch.stop();
    LOG.debug(watch.prettyPrint());
    return String.valueOf(result);
  }
View Full Code Here


      data = "[" + data + "]";
    }

    try {
      final String execute = "JSON.stringify(JSON.hunpack(eval(" + WroUtil.toJSMultiLineString(data) + ")));";
      final Object result = builder.evaluate(execute, "unpack");

      String resultAsString = String.valueOf(result);
      if (!isEnclosedInDoubleArray) {
        //remove [] characters in which the json is enclosed
        resultAsString = removeEnclosedArray(resultAsString);
View Full Code Here

      data = "[" + data + "]";
    }

    try {
      final String execute = "JSON.stringify(JSON.hpack(eval(" + WroUtil.toJSMultiLineString(data) + "), 4));";
      final Object result = builder.evaluate(execute, "pack");
      String resultAsString = String.valueOf(result);
      if (!isEnclosedInArray) {
        //remove [] characters in which the json is enclosed
        resultAsString = removeEnclosedArray(resultAsString);
      }
View Full Code Here

    final RhinoScriptBuilder builder = initScriptBuilder();
    watch.stop();
    watch.start("pack");
   
    final String packIt = buildPackScript(WroUtil.toJSMultiLineString(data));
    final Object result = builder.evaluate(packIt, "packerIt");
    watch.stop();
    LOG.debug(watch.prettyPrint());
    return String.valueOf(result);
  }
 
View Full Code Here

  public String compile(final String content, final String optionalArgument) {
    final RhinoScriptBuilder builder = initScriptBuilder();
    final String argStr = createArgStr(optionalArgument) + createArgStr(getArguments());
    final String compileScript =
      String.format("%s(%s%s);", getCompileCommand(), WroUtil.toJSMultiLineString(content), argStr);
    return (String) builder.evaluate(compileScript, getCompileCommand());
  }

  /**
   * @return the js statement used to execute the compilation of the template.
   */
 
View Full Code Here

   */
  public String compile(final String data) {
    final RhinoScriptBuilder builder = initScriptBuilder();
    final String compileScript = String.format("CoffeeScript.compile(%s, %s);", WroUtil.toJSMultiLineString(data),
        buildOptions());
    return (String) builder.evaluate(compileScript, "CoffeeScript.compile");
  }

  /**
   * @return A javascript representation of the options. The result is a json object.
   */
 
View Full Code Here

    stopWatch.stop();

    stopWatch.start("compile");
    try {
      final String execute = getCompilationCommand(typeScript);
      final NativeObject compilationResult = (NativeObject) builder.evaluate(execute, "compile");
      final NativeArray errors = (NativeArray) compilationResult.get(PARAM_ERRORS);
      if (errors.size() > 0) {
        throwCompilationError(errors);
      }
      return compilationResult.get(PARAM_SOURCE).toString();
View Full Code Here

    stopWatch.stop();

    stopWatch.start("cjson.pack");
    try {
      final String execute = "CJSON.stringify(JSON.parse(" + WroUtil.toJSMultiLineString(data) + "));";
      final Object result = builder.evaluate(execute, "pack");
      return String.valueOf(result);
    } finally {
      stopWatch.stop();
      LOG.debug(stopWatch.prettyPrint());
    }
View Full Code Here

    stopWatch.stop();

    stopWatch.start("json.unpack");
    try {
      final String execute = "JSON.stringify(CJSON.parse(" + WroUtil.toJSMultiLineString(data) + "));";
      final Object result = builder.evaluate(execute, "unpack");
      return String.valueOf(result);
    } finally {
      stopWatch.stop();
      LOG.debug(stopWatch.prettyPrint());
    }
View Full Code Here

    watch.stop();
    watch.start("cssLint");
    LOG.debug("options: {}", this.options);
    final String script = buildCssLintScript(WroUtil.toJSMultiLineString(data));
    LOG.debug("script: {}", script);
    builder.evaluate(script, "CSSLint.verify").toString();
    final boolean valid = Boolean.parseBoolean(builder.evaluate("result.length == 0", "checkNoErrors").toString());
    if (!valid) {
      final String json = builder.addJSON().evaluate("JSON.stringify(result)", "CssLint messages").toString();
      LOG.debug("json {}", json);
      final Type type = new TypeToken<List<CssLintError>>() {}.getType();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.