public ImmutableList<String> includes() { return Globs.glob(join(fileRoot, include)); }
public static ImmutableList<String> glob(final String glob) { Path path = getGlobPath(glob); int globIndex = getGlobIndex(path); if (globIndex < 0) { return of(glob); } return doGlob(path, searchPath(path, globIndex)); }
private static Path getGlobPath(final String glob) { Path path = Paths.get(glob); if (isCurrentPath(path)) { return Paths.get(".").resolve(path); } return path; }
private static int getGlobIndex(final Path path) { int nameCount = path.getNameCount(); for (int i = 0; i < nameCount; i++) { String current = path.getName(i).toString(); int length = current.length(); for (int j = 0; j < length; j++) { if (isGlobMeta(current.charAt(j))) { return i; } } } return -1; }
private Runner createDynamicConfigurationRunner(final StartArgs startArgs) { String pathname = startArgs.getConfigurationFile().get(); ImmutableList<String> glob = glob(pathname); Iterable<File> files = from(glob).transform(filenameToFile()); final FileRunner fileRunner = createConfigurationFileRunner(files, startArgs); Watcher watcher = factory.createConfigurationWatcher(files, fileRunner); return new WatcherRunner(fileRunner, watcher); } }
@Test(expected = MocoException.class) public void should_throw_exception_for_unknown_root() { Globs.glob("unknown/src/test/resources/details/*.json"); }
@Test public void should_glob_files() { ImmutableList<String> glob = Globs.glob("*.json"); assertThat(glob.isEmpty(), is(true)); } }
@Test public void should_glob_direct_files() { ImmutableList<String> files = Globs.glob("src/test/resources/details/foo.json"); assertThat(files.contains("src/test/resources/details/foo.json"), is(true)); }
@Test public void should_glob_absolute_files() throws IOException { File file = folder.newFile(); String path = file.getAbsolutePath(); ImmutableList<String> files = Globs.glob(path); assertThat(files.contains(path), is(true)); }
@Test public void should_glob_relative_files() { ImmutableList<String> files = Globs.glob("src/test/resources/details/*.json"); assertThat(files.contains("src/test/resources/details/foo.json"), is(true)); assertThat(files.contains("src/test/resources/details/bar.json"), is(true)); }
@Test public void should_glob_absolute_files_with_glob() throws IOException { File file = folder.newFile("glob.json"); String glob = Files.join(folder.getRoot().getAbsolutePath(), "*.json"); ImmutableList<String> files = Globs.glob(glob); assertThat(files.contains(file.getAbsolutePath()), is(true)); }
public ImmutableList<String> includes() { return Globs.glob(join(fileRoot, include)); }
private Runner createDynamicConfigurationRunner(final StartArgs startArgs) { String pathname = startArgs.getConfigurationFile().get(); ImmutableList<String> glob = glob(pathname); Iterable<File> files = from(glob).transform(filenameToFile()); final FileRunner fileRunner = createConfigurationFileRunner(files, startArgs); Watcher watcher = factory.createConfigurationWatcher(files, fileRunner); return new WatcherRunner(fileRunner, watcher); } }