Пример #1
0
  public void setRoot(String path) {
    if (path != null) {
      String sanitizedPath = null;

      if (path.indexOf("\\\\") >= 0) {
        sanitizedPath = path.replaceAll("\\\\\\\\", "/");
        sanitizedPath = sanitizedPath.replaceAll("\\\\", "");
      } else {
        sanitizedPath = path.replaceAll("\\\\", "/");
      }
      VirtualFile root = VFS.getChild(sanitizedPath);
      setRoot(root);
    }
  }
  @SuppressWarnings("unchecked")
  public void parse(VFSDeploymentUnit unit, Object dataObj) throws Exception {
    log.debug("Deploying ruby application: " + unit);
    log.info("UNIT.root: " + unit.getRoot());
    log.info("UNIT.root.uri: " + unit.getRoot().toURI());
    log.info("UNIT.root.uri.url: " + unit.getRoot().toURI().toURL());
    log.info("UNIT.root.uri.url.ext: " + unit.getRoot().toURI().toURL().toExternalForm());

    RubyApplicationMetaData appMetaData = unit.getAttachment(RubyApplicationMetaData.class);

    if (appMetaData == null) {
      log.debug("Configuring ruby application: " + unit);
      appMetaData = new RubyApplicationMetaData();
      appMetaData.setApplicationName(unit.getSimpleName());
      unit.addAttachment(RubyApplicationMetaData.class, appMetaData);
    } else {
      log.debug("Configuring pre-existing ruby application: " + unit + "\n  " + appMetaData);
    }

    Map<String, String> app = (Map<String, String>) dataObj;

    if (appMetaData.getRoot() == null) {
      String root = getOneOf(app, "root", "RAILS_ROOT", "RACK_ROOT");

      if (root != null && !root.trim().equals("")) {
        appMetaData.setRoot(root.trim());
      }
    }

    if (appMetaData.getEnvironmentName() == null) {
      String env = getOneOf(app, "env", "RAILS_ENV", "RACK_ENV");

      if (env != null && !env.trim().equals("")) {
        appMetaData.setEnvironmentName(env.trim());
      }
    }
    log.debug("Configured ruby application: " + unit + "\n  " + appMetaData);
  }