switched to ruby-based ignore find

This commit is contained in:
Atlas Cove 2023-02-11 14:08:06 +00:00
parent 3a9c5df1c4
commit 7c464c26d1
2 changed files with 72 additions and 18 deletions

69
pfiles.rb Normal file → Executable file
View File

@ -1,5 +1,70 @@
#!/usr/bin/ruby #!/usr/bin/ruby
require 'find'
ignore=!File.file?('ignore.txt') ? [] : File.readlines('ignore.txt') ignore=!File.file?('ignore.txt') ? [] : File.readlines('ignore.txt')
switch $ARGV[1] if ignore != []
ignore.map! do |i|
"in/#{i}"
end
end
class Enumerator
def collect
out=Array.new
for i in self
out.push(i)
end
return out
end
end
list=Find.find('in')
l=list.collect
case ARGV.first
when "doc"
for i in l do
next if ignore.include?(i)
if /\.(txti|org|md|html)$/.match?(i)
print i
print ' ' unless i==l.last
end
end
when "scass"
for i in l do
next if ignore.include?(i)
if /\.s[ac]ss$/.match?(i)
print i
print ' ' unless i==l.last
end
end
when "sass"
for i in l do
next if ignore.include?(i)
if /\.sass$/.match?(i)
print i
print ' ' unless i==l.last
end
end
when "scss"
for i in l do
next if ignore.include?(i)
if /\.scss$/.match?(i)
print i
print ' ' unless i==l.last
end
end
when "dir"
for i in l do
next if ignore.include?(i)
if File.directory?(i)
print i
print ' ' unless i==l.last
end
end
when "rest"
for i in l do
next if ignore.include?(i)
unless /\.(s[ac]ss|txti|org|md)$/.match?(i) or File.directory(i)
print i
print ' ' unless i==l.last
end
end
else
end end

View File

@ -26,6 +26,7 @@ function tape {
*.org) org-ruby --translate html "$1" ;; *.org) org-ruby --translate html "$1" ;;
*.md) comrak --gfm "$1" ;; *.md) comrak --gfm "$1" ;;
*.html) cat $1 ;; *.html) cat $1 ;;
*.s[ac]ss) err "Told to render $1, shouldn't happen"; return 1 ;;
*) pandoc --columns 168 -t html "$1" || echo "Skipping $i, unknown format" ;; *) pandoc --columns 168 -t html "$1" || echo "Skipping $i, unknown format" ;;
esac esac
} }
@ -35,7 +36,7 @@ function dirs {
return 0 return 0
fi fi
local i o dir local i o dir
dir=(`find in -type d`) dir=(`./pfiles.rb dir`)
inf "Creating directory structure..." inf "Creating directory structure..."
echo ${dir[@]} echo ${dir[@]}
for i in ${dir[@]}; do for i in ${dir[@]}; do
@ -49,13 +50,9 @@ function docs {
return 1 return 1
fi fi
local i o doc local i o doc
doc=(`find in -type f -name '*.txti' -o -name '*.org' -o -name '*.md'`) doc=(`./pfiles.rb doc`)
inf "Rendering document files..." inf "Rendering document files..."
for i in ${doc[@]}; do for i in ${doc[@]}; do
if in_arr $i ${ignore[@]}; then
inf "Skipping $i"
continue
fi
o="${i/in/out}" o="${i/in/out}"
echo "$i => $o" echo "$i => $o"
if test -z "${title[$i]}"; then if test -z "${title[$i]}"; then
@ -71,18 +68,14 @@ function sass {
return 1 return 1
fi fi
local i o sass scss local i o sass scss
sass=(`find in -type f -name '*.sass'`) sass=(`./pfiles.rb sass`)
scss=(`find in -type f -name '*.scss'`) scss=(`./pfiles.rb scss`)
inf "Rendering sass files..." inf "Rendering sass files..."
if [ ${#sass[@]} -eq 0 ]; then if [ ${#sass[@]} -eq 0 ]; then
inf "No .sass files detected, skipping" inf "No .sass files detected, skipping"
unset sass unset sass
else else
for i in ${sass[@]}; do for i in ${sass[@]}; do
if in_arr $i ${ignore[@]}; then
inf "Skipping $i"
continue
fi
o="${i/in/out}" o="${i/in/out}"
o="${o/.sa/.c}" o="${o/.sa/.c}"
echo "$i => $o" echo "$i => $o"
@ -94,10 +87,6 @@ function sass {
unset scss unset scss
else else
for i in ${scss[@]}; do for i in ${scss[@]}; do
if in_arr $i ${ignore[@]}; then
inf "Skipping $i"
continue
fi
o="${i/in/out}" o="${i/in/out}"
o="${o/\.s/.}" o="${o/\.s/.}"
echo "$i => $o" echo "$i => $o"