]> gitweb.factorcode.org Git - factor.git/commitdiff
furnace.utilities: use a method based on where instead of vocab-path to find dir...
authorBjörn Lindqvist <bjourne@gmail.com>
Mon, 3 Nov 2014 17:47:22 +0000 (18:47 +0100)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 4 Nov 2014 04:49:18 +0000 (20:49 -0800)
basis/furnace/utilities/utilities-tests.factor [new file with mode: 0644]
basis/furnace/utilities/utilities.factor

diff --git a/basis/furnace/utilities/utilities-tests.factor b/basis/furnace/utilities/utilities-tests.factor
new file mode 100644 (file)
index 0000000..426288a
--- /dev/null
@@ -0,0 +1,22 @@
+USING: furnace.utilities io.encodings.utf8 io.files io.files.temp kernel
+multiline parser tools.test webapps.counter ;
+IN: furnace.utilities.tests
+
+<<
+STRING: dummy-vocab
+IN: dummy-vocab
+
+: dummy-word ( -- ) ;
+;
+
+dummy-vocab "dummy.factor" temp-file [ utf8 set-file-contents ] keep run-file
+>>
+
+{ t } [
+    USE: dummy-vocab
+    { dummy-word "index" } resolve-template-path "index" temp-file =
+] unit-test
+
+{ "resource:extra/webapps/counter/counter" } [
+    { counter-app "counter" } resolve-template-path
+] unit-test
index 61547131fc550238f026c5338e7230b7140a038f..e42213b31e043a1b6e1da37d353d61cba11443f9 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces make assocs sequences kernel classes splitting
+USING: definitions namespaces make assocs sequences kernel classes splitting
 words vocabs.loader accessors strings combinators arrays
 continuations present fry urls http http.server xml.syntax xml.writer
-http.server.redirection http.server.remapping ;
+http.server.redirection http.server.remapping io.pathnames ;
 IN: furnace.utilities
 
 : word>string ( word -- string )
@@ -41,13 +41,11 @@ ERROR: no-such-responder responder ;
         ] "" make
     ] when ;
 
-: vocab-path ( vocab -- path )
-    dup vocab-dir vocab-append-path ;
+: resolve-word-path ( word -- path/f )
+    where [ first parent-directory but-last ] [ f ] if* ;
 
 : resolve-template-path ( pair -- path )
-    [
-        first2 [ vocabulary>> vocab-path % ] [ "/" % % ] bi*
-    ] "" make ;
+    [ first2 [ resolve-word-path % ] dip "/" % % ] "" make ;
 
 GENERIC: modify-query ( query responder -- query' )