vocabs.metadata: cleanup paths to be fully specified.

flac
John Benediktsson 2020-03-05 08:59:36 -08:00 committed by Steve Ayerhart
parent 761cf1a5dd
commit 685c3eae2c
No known key found for this signature in database
GPG Key ID: 5BFD39C5359E967D
6 changed files with 59 additions and 70 deletions

View File

@ -5,17 +5,17 @@ prettyprint.config sequences splitting tools.deploy.config
vocabs.loader vocabs.metadata ; vocabs.loader vocabs.metadata ;
IN: tools.deploy.config.editor IN: tools.deploy.config.editor
: deploy-config-path ( vocab -- string ) : deploy-config-path ( vocab -- path/f )
vocab-dir "deploy.factor" append-path ; "deploy.factor" vocab-file-path ;
: deploy-config ( vocab -- assoc ) : deploy-config ( vocab -- assoc )
dup default-config swap [ default-config ] keep
dup deploy-config-path vocab-file-lines "deploy.factor" vocab-file-lines
parse-fresh [ first assoc-union ] unless-empty ; parse-fresh [ first assoc-union ] unless-empty ;
: set-deploy-config ( assoc vocab -- ) : set-deploy-config ( assoc vocab -- )
[ [ unparse-use ] without-limits string-lines ] dip [ [ unparse-use ] without-limits string-lines ] dip
dup deploy-config-path set-vocab-file-lines ; "deploy.factor" set-vocab-file-lines ;
: set-deploy-flag ( value key vocab -- ) : set-deploy-flag ( value key vocab -- )
[ deploy-config [ set-at ] keep ] keep set-deploy-config ; [ deploy-config [ set-at ] keep ] keep set-deploy-config ;

View File

@ -6,9 +6,14 @@ IN: tools.deploy.libraries.unix
! stupid hack. better ways to find the library name would be open the library, ! stupid hack. better ways to find the library name would be open the library,
! note a symbol address found in the library, then call dladdr (or use ! note a symbol address found in the library, then call dladdr (or use
<PRIVATE
: ?exists ( path -- path/f ) : ?exists ( path -- path/f )
dup exists? [ drop f ] unless ; inline dup exists? [ drop f ] unless ; inline
PRIVATE>
M: unix find-library-file M: unix find-library-file
dup absolute-path? [ ?exists ] [ dup absolute-path? [ ?exists ] [
{ "/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" "resource:" } { "/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" "resource:" }

View File

@ -2,19 +2,15 @@ USING: help.markup help.syntax literals sequences strings ;
IN: vocabs.files IN: vocabs.files
HELP: vocab-tests-path HELP: vocab-tests-path
{ $values { "vocab" "a vocabulary specifier" } { "path" "pathname string to test file" } } { $values { "vocab" "a vocabulary specifier" } { "path/f" { $maybe "pathname string to test file" } } }
{ $description "Outputs a pathname where the unit test file for " { $snippet "vocab" } " is located. Outputs " { $link f } " if the vocabulary does not have a directory on disk." } ; { $description "Outputs a pathname where the unit test file for " { $snippet "vocab" } " is located. Outputs " { $link f } " if the vocabulary does not have a directory on disk." } ;
HELP: vocab-tests-file
{ $values { "vocab" "a vocabulary specifier" } { "path/f" "pathname string to test file" } }
{ $description "Outputs a pathname where the unit test file is located, or " { $link f } " if the file does not exist." } ;
HELP: vocab-tests-dir HELP: vocab-tests-dir
{ $values { "vocab" "a vocabulary specifier" } { "paths" "a sequence of pathname strings" } } { $values { "vocab" "a vocabulary specifier" } { "paths" "a sequence of pathname strings" } }
{ $description "Outputs a sequence of pathnames for the tests in the test directory." } ; { $description "Outputs a sequence of pathnames for the tests in the test directory." } ;
HELP: vocab-files HELP: vocab-files
{ $values { "vocab" "a vocabulary specifier" } { "seq" "a sequence of pathname strings" } } { $values { "vocab" "a vocabulary specifier" } { "paths" "a sequence of pathname strings" } }
{ $description "Outputs a sequence of files comprising this vocabulary, or " { $link f } " if the vocabulary does not have a directory on disk." } { $description "Outputs a sequence of files comprising this vocabulary, or " { $link f } " if the vocabulary does not have a directory on disk." }
{ $examples { $examples
{ $example { $example
@ -33,7 +29,7 @@ HELP: vocab-files
} ; } ;
HELP: vocab-tests HELP: vocab-tests
{ $values { "vocab" "a vocabulary specifier" } { "tests" "a sequence of pathname strings" } } { $values { "vocab" "a vocabulary specifier" } { "paths" "a sequence of pathname strings" } }
{ $description "Outputs a sequence of pathnames where the unit tests for " { $snippet "vocab" } " are located." } { $description "Outputs a sequence of pathnames where the unit tests for " { $snippet "vocab" } " are located." }
{ $examples { $examples
{ $example { $example

View File

@ -1,33 +1,31 @@
! Copyright (C) 2009 Slava Pestov. ! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: io.directories io.files io.pathnames kernel make USING: combinators io.directories io.files io.pathnames kernel
sequences vocabs vocabs.loader ; make sequences vocabs.loader ;
IN: vocabs.files IN: vocabs.files
: vocab-tests-path ( vocab -- path ) : vocab-tests-path ( vocab -- path/f )
dup "-tests.factor" append-vocab-dir vocab-append-path ; dup "-tests.factor" append-vocab-dir vocab-append-path ;
: vocab-tests-file ( vocab -- path/f )
vocab-tests-path dup
[ dup exists? [ drop f ] unless ] [ drop f ] if ;
: vocab-tests-dir ( vocab -- paths ) : vocab-tests-dir ( vocab -- paths )
dup vocab-dir "tests" append-path vocab-append-path dup [ dup vocab-dir "tests" append-path vocab-append-path [
dup exists? [ dup exists? [
dup directory-files [ ".factor" tail? ] filter dup directory-files [ ".factor" tail? ] filter
[ append-path ] with map [ append-path ] with map
] [ drop f ] if ] [ drop f ] if
] [ drop f ] if ; ] [ f ] if* ;
: vocab-tests ( vocab -- tests ) : vocab-tests ( vocab -- paths )
[ [
[ vocab-tests-file [ , ] when* ] [ vocab-tests-path [ dup exists? [ , ] [ drop ] if ] when* ]
[ vocab-tests-dir [ % ] when* ] bi [ vocab-tests-dir % ] bi
] { } make ; ] { } make ;
: vocab-files ( vocab -- seq ) : vocab-files ( vocab -- paths )
[ [
[ vocab-source-path [ , ] when* ] {
[ vocab-docs-path [ , ] when* ] [ vocab-source-path [ , ] when* ]
[ vocab-tests % ] tri [ vocab-docs-path [ , ] when* ]
[ vocab-tests % ]
} cleave
] { } make ; ] { } make ;

View File

@ -3,32 +3,20 @@ IN: vocabs.metadata
ARTICLE: "vocabs.metadata" "Vocabulary metadata" ARTICLE: "vocabs.metadata" "Vocabulary metadata"
"Vocabulary directories can contain text files with metadata:" "Vocabulary directories can contain text files with metadata:"
{ $list { $table
{ { $snippet "authors.txt" } " - a series of lines, with one author name per line. These are listed under " { $link "vocab-authors" } "." } { { $snippet "authors.txt" } { "a series of lines, with one author name per line. These are listed under " { $link "vocab-authors" } "." } }
{ { $snippet "platforms.txt" } " - a series of lines, with one operating system name per line." } { { $snippet "platforms.txt" } { "a series of lines, with one operating system name per line." } }
{ { $snippet "resources.txt" } " - a series of lines, with one file glob pattern per line. Files inside the vocabulary directory whose names match any of these glob patterns will be included with the compiled application as " { $link "deploy-resources" } "." } { { $snippet "resources.txt" } { "a series of lines, with one file glob pattern per line. Files inside the vocabulary directory whose names match any of these glob patterns will be included with the compiled application as " { $link "deploy-resources" } "." } }
{ { $snippet "summary.txt" } " - a one-line description." } { { $snippet "summary.txt" } { "a one-line description." } }
{ { $snippet "tags.txt" } " - a series of lines, with one tag per line. Tags help classify the vocabulary. Consult " { $link "vocab-tags" } " for a list of existing tags you can reuse." } { { $snippet "tags.txt" } { "a series of lines, with one tag per line. Tags help classify the vocabulary. Consult " { $link "vocab-tags" } " for a list of existing tags you can reuse." } }
} }
"Words for reading " { $snippet "summary.txt" } ":" "These metadata files can be accessed with the following words:"
{ $subsections
vocab-summary
}
"Words for reading " { $snippet "authors.txt" } ":"
{ $subsections { $subsections
vocab-authors vocab-authors
}
"Words for reading " { $snippet "tags.txt" } ":"
{ $subsections
vocab-tags
}
"Words for reading " { $snippet "platforms.txt" } ":"
{ $subsections
vocab-platforms vocab-platforms
}
"Words for reading " { $snippet "resources.txt" } ":"
{ $subsections
vocab-resources vocab-resources
vocab-summary
vocab-tags
} }
"Getting and setting arbitrary vocabulary metadata:" "Getting and setting arbitrary vocabulary metadata:"
{ $subsections { $subsections

View File

@ -1,17 +1,20 @@
! Copyright (C) 2009, 2010 Slava Pestov, Joe Groff. ! Copyright (C) 2009, 2010 Slava Pestov, Joe Groff.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes.algebra USING: accessors assocs classes.algebra
combinators.short-circuit continuations io.directories combinators.short-circuit continuations io.directories
io.encodings.utf8 io.files io.pathnames kernel make math.parser io.encodings.utf8 io.files io.pathnames kernel make math.parser
memoize namespaces sequences sets summary system vocabs memoize namespaces sequences summary system vocabs vocabs.loader
vocabs.loader words ; words ;
IN: vocabs.metadata IN: vocabs.metadata
: check-vocab ( vocab -- vocab ) : check-vocab ( vocab -- vocab )
dup find-vocab-root [ no-vocab ] unless ; dup find-vocab-root [ no-vocab ] unless ;
: vocab-file-path ( vocab name -- path/f )
[ dup vocab-dir ] [ append-path ] bi* vocab-append-path ;
MEMO: vocab-file-lines ( vocab name -- lines/f ) MEMO: vocab-file-lines ( vocab name -- lines/f )
vocab-append-path dup [ vocab-file-path dup [
dup exists? [ dup exists? [
utf8 file-lines harvest utf8 file-lines harvest
] [ ] [
@ -20,23 +23,22 @@ MEMO: vocab-file-lines ( vocab name -- lines/f )
] when ; ] when ;
: set-vocab-file-lines ( lines vocab name -- ) : set-vocab-file-lines ( lines vocab name -- )
dupd vocab-append-path [ dupd vocab-file-path [
swap [ ?delete-file ] [ swap utf8 set-file-lines ] if-empty swap [ ?delete-file ] [ swap utf8 set-file-lines ] if-empty
\ vocab-file-lines reset-memoized \ vocab-file-lines reset-memoized
] [ vocab-name no-vocab ] ?if ; ] [ vocab-name no-vocab ] ?if ;
: vocab-resources-path ( vocab -- string ) : vocab-resources-path ( vocab -- path/f )
vocab-dir "resources.txt" append-path ; "resources.txt" vocab-file-path ;
: vocab-resources ( vocab -- patterns ) : vocab-resources ( vocab -- patterns )
dup vocab-resources-path vocab-file-lines ; "resources.txt" vocab-file-lines ;
: vocab-summary-path ( vocab -- string ) : vocab-summary-path ( vocab -- path/f )
vocab-dir "summary.txt" append-path ; "summary.txt" vocab-file-path ;
: vocab-summary ( vocab -- summary ) : vocab-summary ( vocab -- summary )
dup dup vocab-summary-path vocab-file-lines dup "summary.txt" vocab-file-lines [
[
vocab-name " vocabulary" append vocab-name " vocabulary" append
] [ ] [
nip first nip first
@ -52,25 +54,25 @@ M: vocab summary
M: vocab-link summary vocab-summary ; M: vocab-link summary vocab-summary ;
: vocab-tags-path ( vocab -- string ) : vocab-tags-path ( vocab -- path/f )
vocab-dir "tags.txt" append-path ; "tags.txt" vocab-file-path ;
: vocab-tags ( vocab -- tags ) : vocab-tags ( vocab -- tags )
dup vocab-tags-path vocab-file-lines ; "tags.txt" vocab-file-lines ;
: vocab-authors-path ( vocab -- string ) : vocab-authors-path ( vocab -- path/f )
vocab-dir "authors.txt" append-path ; "authors.txt" vocab-file-path ;
: vocab-authors ( vocab -- authors ) : vocab-authors ( vocab -- authors )
dup vocab-authors-path vocab-file-lines ; "authors.txt" vocab-file-lines ;
: vocab-platforms-path ( vocab -- string ) : vocab-platforms-path ( vocab -- path/f )
vocab-dir "platforms.txt" append-path ; "platforms.txt" vocab-file-path ;
ERROR: bad-platform name ; ERROR: bad-platform name ;
: vocab-platforms ( vocab -- platforms ) : vocab-platforms ( vocab -- platforms )
dup vocab-platforms-path vocab-file-lines "platforms.txt" vocab-file-lines
[ dup "system" lookup-word [ ] [ bad-platform ] ?if ] map ; [ dup "system" lookup-word [ ] [ bad-platform ] ?if ] map ;
: supported-platform? ( platforms -- ? ) : supported-platform? ( platforms -- ? )