@@ -0,0 +1,1817 @@
+/*%0A * Copyright 2012 the hegemon authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.cueup.hegemon;%0A%0Aimport com.google.common.base.Charsets;%0Aimport com.google.common.io.Files;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0A%0A/**%0A * Simple script locator that just loads scripts under a sub-path.%0A * This is useful for development environments.  For production code,%0A * you almost certainly want ResourceScriptLocator.%0A */%0Apublic class PathScriptLocator extends ScriptLocator %7B%0A%0A  private final File root;%0A%0A  /**%0A   * Creates a path locator with the given root path.%0A   * @param root the root path%0A   */%0A  public PathScriptLocator(String root) %7B%0A    this(new File(root));%0A  %7D%0A%0A  /**%0A   * Creates a path locator with the given root path.%0A   * @param root the root path%0A   */%0A  public PathScriptLocator(File root) %7B%0A    this.root = root;%0A  %7D%0A%0A  @Override%0A  public String getFile(String name) throws LoadError %7B%0A    File script = new File(this.root, name);%0A    try %7B%0A      if (script.getCanonicalPath().startsWith(this.root.getCanonicalPath())%0A          && script.exists()) %7B%0A        return Files.toString(script, Charsets.UTF_8);%0A      %7D%0A    %7D catch (IOException e) %7B%0A      throw new LoadError(e);%0A    %7D%0A    throw new LoadError(%22Could not find %22 + name + %22 under %22 + this.root);%0A  %7D%0A%0A%7D%0A

Add simple script locator that reads files from a path