Skip to content

Commit

Permalink
impl. ordered listFolder
Browse files Browse the repository at this point in the history
  • Loading branch information
clagomess committed Mar 7, 2024
1 parent 2d6d11d commit 1f63708
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -23,16 +26,15 @@ public String getFeatureExtension(File f){
return matcher.find() ? matcher.group(0) : null;
}

protected List<File> listFolder(File curDir) throws Exception {
// @TODO: maibe ordered?
List<File> buffer = new LinkedList<>();
protected Set<File> listFolder(File curDir) throws Exception {
Set<File> buffer = new TreeSet<>();

listFolder(buffer, curDir);

return buffer;
}

private void listFolder(List<File> buffer, File curDir) throws Exception {
private void listFolder(Set<File> buffer, File curDir) throws Exception {
File[] filesList = curDir.listFiles();
if(filesList == null) throw new Exception("*.features not found");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.clagomess.pirilampo.core.compilers;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.clagomess.pirilampo.core.dto.FeatureIndexDto;
import com.github.clagomess.pirilampo.core.dto.FeatureMasterDto;
import com.github.clagomess.pirilampo.core.dto.FeatureMetadataDto;
Expand All @@ -8,18 +10,13 @@
import com.github.clagomess.pirilampo.core.parsers.GherkinDocumentParser;
import com.github.clagomess.pirilampo.core.parsers.ImageParser;
import com.github.clagomess.pirilampo.core.parsers.MenuParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;

@Slf4j
Expand Down Expand Up @@ -123,7 +120,7 @@ protected void buildIndex(PrintWriter out) throws JsonProcessingException {
public void build() throws Exception {
MenuParser menuParser = new MenuParser(parameters);

final List<File> arquivos = listFolder(parameters.getProjectSource());
Set<File> arquivos = listFolder(parameters.getProjectSource());
if(arquivos.isEmpty()) return;

try (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import java.util.Objects;
import java.util.Set;

@Slf4j
@RequiredArgsConstructor
public class FolderToPDFCompiler extends Compiler {
private final ParametersDto parameters;

public void build() throws Exception {
List<File> arquivos = listFolder(parameters.getProjectSource());
Set<File> arquivos = listFolder(parameters.getProjectSource());
if(arquivos.isEmpty()) return;

File outArtifact = getOutArtifact(parameters);
Expand Down

0 comments on commit 1f63708

Please sign in to comment.