Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of internal Asciidoctorj DirectoryWalker #532

Closed
1 of 4 tasks
abelsromero opened this issue May 10, 2021 · 3 comments · Fixed by #535
Closed
1 of 4 tasks

Remove usage of internal Asciidoctorj DirectoryWalker #532

abelsromero opened this issue May 10, 2021 · 3 comments · Fixed by #535

Comments

@abelsromero
Copy link
Member

What is this issue about?

  • Bug report
  • Feature request
  • Question
  • Refactor/Improvement

Description
Currently, we use org.asciidoctor.jruby.AsciiDocDirectoryWalker and org.asciidoctor.jruby.DirectoryWalker to obtain AsciiDoc sources from the paths. But his classes are not part of the asciidoctorj-api but the jruby implementation, this breaks encapsulation and prevents the plugin from working with other AsciidoctorJ implementations using the service loader.
We should replace this by some agnostic piece with same functionality, for example FileUtils.listFiles.

Reference:

protected List<File> calculateSourceFiles(File sourceDirectory) {
if (sourceDocumentName != null)
return Arrays.asList(new File(sourceDirectory, sourceDocumentName));
// Both DirectoryWalkers filter out internal sources and path (_ prefix)
final String sourceDirectoryAbsolutePath = sourceDirectory.getAbsolutePath();
final DirectoryWalker directoryWalker = sourceDocumentExtensions.isEmpty()
? new AsciiDocDirectoryWalker(sourceDirectoryAbsolutePath)
: new CustomExtensionDirectoryWalker(sourceDirectoryAbsolutePath, sourceDocumentExtensions);
return directoryWalker.scan();
}

PD: there are other jruby specifics being used, but we can treat them in another issue.

@abelsromero
Copy link
Member Author

Since this is internal change, there should be no need for new tests.

@stdll
Copy link
Contributor

stdll commented Jul 7, 2021

Hi! Sorry for spamming this issue. I've looked into the issue and came up with a PR. If you have feedback, please let me know.

@abelsromero
Copy link
Member Author

Hi! Sorry for spamming this issue.

No problem 👍 My only suggestion is if you have a long running PR, just mark as "Draft" so people is aware is not finished. But even that's opinionated and some ppl prefer not getting the PR untill is finished 🤷

I can't promise I can look into the issue today, but I'll try.

@abelsromero abelsromero changed the title Remove usage of jruby DirectoryWalker Remove usage of internal Asciidoctorj DirectoryWalker Jul 7, 2021
abelsromero pushed a commit that referenced this issue Jul 8, 2021
* Replace usage of internal Asciidoctorj DirectoryWalker with Java NIO API (#532)
* Add tests (#532)

Co-authored-by: Stefan Dellmuth <stefan.dellmuth@msg.group>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants