Merge branch 'master' of git://github.com/seckar/factor

db4
Slava Pestov 2009-05-04 05:19:55 -05:00
commit 985a0759a4
3 changed files with 29 additions and 4 deletions

View File

@ -73,3 +73,11 @@ HELP: set-vocab-tags
HELP: all-vocabs
{ $values { "assoc" "an association list mapping vocabulary roots to sequences of vocabulary specifiers" } }
{ $description "Outputs an association list of all vocabularies which have been loaded or are available for loading." } ;
HELP: load-all-under
{ $values { "prefix" string } }
{ $description "Load all vocabularies that match the provided prefix." } ;
HELP: all-vocabs-under
{ $values { "prefix" string } }
{ $description "Return a sequence of vocab or vocab-links for each vocab matching the provided prefix. Unlike " { $link all-child-vocabs } " this word will return both loaded and unloaded vocabularies." } ;

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