vocabs.metadata.resources: new error resource-missing, if a resources.txt line doesnt match something
So then if files declared in resources.txt are missing, that will hopefully be caught by the deploy process.char-rename
parent
c23dbf0f8f
commit
b40e6cbd6d
|
@ -2,11 +2,15 @@
|
|||
USING: arrays globs sorting tools.test vocabs.metadata.resources ;
|
||||
IN: vocabs.metadata.resources.tests
|
||||
|
||||
! filter-resources
|
||||
! match-pattern
|
||||
{ { "hello.txt" } } [
|
||||
"*.txt" <glob> 1array { "hello.txt" } filter-resources
|
||||
"*.txt" { "hello.txt" } match-pattern
|
||||
] unit-test
|
||||
|
||||
[
|
||||
"*.txt" { "foo.bar" "foo.factor" } match-pattern
|
||||
] [ resource-missing? ] must-fail-with
|
||||
|
||||
! vocab-resource-files
|
||||
{ { "bar" "bas" "foo" } }
|
||||
[ "vocabs.metadata.resources.test.1" vocab-resource-files natural-sort ] unit-test
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
! (c)2010 Joe Groff bsd license
|
||||
USING: globs io.directories io.directories.hierarchy io.files.info
|
||||
io.pathnames kernel regexp sequences vocabs.loader vocabs.metadata ;
|
||||
USING: fry globs io.directories io.directories.hierarchy io.files.info
|
||||
io.pathnames kernel regexp sequences sets vocabs.loader
|
||||
vocabs.metadata ;
|
||||
IN: vocabs.metadata.resources
|
||||
|
||||
<PRIVATE
|
||||
|
@ -21,13 +22,19 @@ PRIVATE>
|
|||
dup directory-tree-files [ append-path ] with map
|
||||
] [ drop { } ] if swap prefix ;
|
||||
|
||||
: filter-resources ( resource-globs vocab-files -- vocab-files' )
|
||||
[ swap [ matches? ] with any? ] with filter ;
|
||||
ERROR: resource-missing pattern ;
|
||||
|
||||
: match-pattern ( pattern files -- files' )
|
||||
over <glob> '[ _ matches? ] filter
|
||||
[ resource-missing ] [ nip ] if-empty ;
|
||||
|
||||
: match-patterns ( patterns files -- files' )
|
||||
'[ _ match-pattern ] map concat members ;
|
||||
|
||||
: vocab-resource-files ( vocab -- filenames )
|
||||
[ vocab-resources [ <glob> ] map ] [ vocab-dir-in-root ] bi
|
||||
[ vocab-resources ] [ vocab-dir-in-root ] bi
|
||||
[
|
||||
filter-resources [ expand-resource ] map concat
|
||||
match-patterns [ expand-resource ] map concat
|
||||
] with-directory-files ;
|
||||
|
||||
: copy-vocab-resources ( dir vocab -- )
|
||||
|
|
Loading…
Reference in New Issue