Created
November 10, 2021 02:08
-
-
Save rzhade3/9987db176dbff7cee4c0fcc9e9ec0718 to your computer and use it in GitHub Desktop.
Script to generate a Ruby glob that'll accept all files except those in a certain directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Please input a folder name: " | |
folder = gets.chomp | |
glob = "{" | |
prefix = "" | |
folder.each_char do |character| | |
# We don't accept any strings that start with the prefix | |
glob << "#{prefix}[^#{character}]*," | |
# Except the prefix itself | |
glob << "#{prefix}," | |
prefix << character | |
end | |
glob << "#{folder}?*" | |
glob << "}/**/*" | |
puts glob |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment