Don't treat . directories as vocab dirs.

Rename subdirs to (less general) vocab-subdirs.
Add all-vocabs-under and load-all-under.
db4
Nicholas Seckar 2009-05-03 21:00:29 -07:00
parent 70c8a1bef0
commit 8beea2ab0c
2 changed files with 21 additions and 4 deletions

View File

@ -1,5 +1,5 @@
IN: tools.vocabs.tests
USING: tools.test tools.vocabs namespaces continuations ;
USING: continuations namespaces tools.test tools.vocabs tools.vocabs.private ;
[ ] [
changed-vocabs get-global
@ -7,3 +7,6 @@ USING: tools.test tools.vocabs namespaces continuations ;
[ t ] [ "kernel" changed-vocab? ] unit-test
[ "kernel" changed-vocab ] [ changed-vocabs set-global ] [ ] cleanup
] unit-test
[ t ] [ "some-vocab" valid-vocab-dirname ] unit-test
[ f ] [ ".git" valid-vocab-dirname ] unit-test

View File

@ -205,15 +205,21 @@ M: vocab-link summary vocab-summary ;
: set-vocab-authors ( authors vocab -- )
dup vocab-authors-path set-vocab-file-contents ;
: subdirs ( dir -- dirs )
<PRIVATE
: valid-vocab-dirname ( dirname -- ? )
dup empty? [ drop f ] [ first CHAR: . = not ] if ;
PRIVATE>
: vocab-subdirs ( dir -- dirs )
[
[ link-info directory? ] filter
[ [ link-info directory? ] [ valid-vocab-dirname ] bi and ] filter
] with-directory-files natural-sort ;
: (all-child-vocabs) ( root name -- vocabs )
[
vocab-dir append-path dup exists?
[ subdirs ] [ drop { } ] if
[ vocab-subdirs ] [ drop { } ] if
] keep [
swap [ "." glue ] with map
] unless-empty ;
@ -235,6 +241,11 @@ M: vocab-link summary vocab-summary ;
dup [ "" vocabs-in-dir ] { } make
] { } map>assoc ;
: all-vocabs-under ( prefix -- vocabs )
[
vocab-roots get [ over vocabs-in-dir ] each drop
] { } make ;
MEMO: all-vocabs-seq ( -- seq )
all-vocabs values concat ;
@ -252,6 +263,9 @@ MEMO: all-vocabs-seq ( -- seq )
: load-everything ( -- )
try-everything load-failures. ;
: load-all-under ( prefix -- )
all-vocabs-under filter-unportable require-all load-failures. ;
: unrooted-child-vocabs ( prefix -- seq )
dup empty? [ CHAR: . suffix ] unless
vocabs