Try a different strategy
parent
8d8c39ecca
commit
6b16f70822
|
@ -0,0 +1,6 @@
|
||||||
|
USING: tools.test tools.vocabs.monitor io.files ;
|
||||||
|
IN: tools.vocabs.monitor.tests
|
||||||
|
|
||||||
|
[ "kernel" ] [ "core/kernel/kernel.factor" path>vocab ] unit-test
|
||||||
|
[ "kernel" ] [ "core/kernel/" path>vocab ] unit-test
|
||||||
|
[ "kernel" ] [ "core/kernel/" resource-path path>vocab ] unit-test
|
|
@ -11,27 +11,37 @@ IN: tools.vocabs.monitor
|
||||||
|
|
||||||
: path>vocab-name ( path -- vocab )
|
: path>vocab-name ( path -- vocab )
|
||||||
dup ".factor" tail? [ parent-directory ] when
|
dup ".factor" tail? [ parent-directory ] when
|
||||||
dup [ vocab-dir>vocab-name ] when ;
|
;
|
||||||
|
|
||||||
|
: chop-vocab-root ( path -- path' )
|
||||||
|
"resource:" prepend-path (normalize-path)
|
||||||
|
dup vocab-roots get
|
||||||
|
[ (normalize-path) ] map
|
||||||
|
[ head? ] with find nip
|
||||||
|
?head drop ;
|
||||||
|
|
||||||
|
: path>vocab ( path -- vocab )
|
||||||
|
chop-vocab-root path>vocab-name vocab-dir>vocab-name ;
|
||||||
|
|
||||||
: changed-vocab ( vocab -- )
|
: changed-vocab ( vocab -- )
|
||||||
dup vocab
|
dup vocab
|
||||||
[ dup changed-vocabs get-global set-at ] [ drop ] if ;
|
[ dup changed-vocabs get-global set-at ] [ drop ] if ;
|
||||||
|
|
||||||
: monitor-thread ( path monitor -- )
|
: monitor-thread ( monitor -- )
|
||||||
#! On OS X, monitors give us the full path, so we chop it
|
#! On OS X, monitors give us the full path, so we chop it
|
||||||
#! off if its there.
|
#! off if its there.
|
||||||
next-change drop swap ?head drop
|
next-change drop path>vocab changed-vocab reset-cache ;
|
||||||
path>vocab-name changed-vocab reset-cache ;
|
|
||||||
|
|
||||||
: start-monitor-thread ( root -- )
|
: start-monitor-thread ( monitor -- )
|
||||||
#! Silently ignore errors during monitor creation since
|
#! Silently ignore errors during monitor creation since
|
||||||
#! monitors are not supported on all platforms.
|
#! monitors are not supported on all platforms.
|
||||||
(normalize-path) dup t <monitor> [ monitor-thread t ] 2curry
|
[ monitor-thread t ] curry
|
||||||
"Vocabulary monitor" spawn-server drop ;
|
"Vocabulary monitor" spawn-server
|
||||||
|
drop ;
|
||||||
|
|
||||||
: start-monitor-threads ( -- )
|
: start-monitor-threads ( -- )
|
||||||
[
|
[
|
||||||
vocab-roots get [ start-monitor-thread ] each
|
"" resource-path t <monitor> start-monitor-thread
|
||||||
H{ } clone changed-vocabs set-global
|
H{ } clone changed-vocabs set-global
|
||||||
vocabs [ changed-vocab ] each
|
vocabs [ changed-vocab ] each
|
||||||
] ignore-errors ;
|
] ignore-errors ;
|
||||||
|
|
Loading…
Reference in New Issue