Package

grizzled

file

Permalink

package file

File-related classes and utilities. This package is distinguished from the grizzled.io package in that this package operates on files and paths, not on open streams or sources.

See also

grizzled.io

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. file
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. class FileDoesNotExistException extends Exception

    Permalink
  2. class Includer extends Iterator[String]

    Permalink

    Process "include" directives in files, returning an iterator over lines from the flattened files.

    Process "include" directives in files, returning an iterator over lines from the flattened files.

    The grizzled.file.Includer class can be used to process "include" directives within a text file, returning a file-like object. It also contains some utility functions that permit using include-enabled files in other contexts.

    Syntax

    The include syntax is defined by a regular expression; any line that matches the regular expression is treated as an include directive. The default regular expression, %include\s"(["]+)"$ matches include directives like this:

    %include "/absolute/path/to/file"
    %include "../relative/path/to/file"
    %include "local_reference"
    %include "http://localhost/path/to/my.config"

    Relative and local file references are relative to the including file or URL. That is, if an Includer is processing file "/home/bmc/foo.txt" and encounters an attempt to include file "bar.txt", it will assume "bar.txt" is to be found in "/home/bmc".

    Similarly, if an Includer is processing URL "http://localhost/bmc/foo.txt" and encounters an attempt to include file "bar.txt", it will assume "bar.txt" is to be found at "http://localhost/bmc/bar.txt".

    Nested includes are permitted; that is, an included file may, itself, include other files. The maximum recursion level is configurable and defaults to 100.

    The include syntax can be changed by passing a different regular expression to the Includer constructor.

    Usage

    This package provides an Includer class, which processes include directives in a file and behaves somewhat like a Scala Source. See the class documentation for more details.

    The package also provides a preprocess() convenience function, via a companion object, that can be used to preprocess a file; it returns the path to the resulting preprocessed file.

    Examples

    Preprocess a file containing include directives, then read the result:

    import grizzled.file.Includer
    
    Includer(path).foreach(println(_))

    Use an include-enabled file with a Scala scala.io.Source object:

    import grizzled.file.includer.Includer
    import scala.io.Source
    
    val source = Source.fromFile(Includer.preprocess("/path/to/file"))

Value Members

  1. object Implicits

    Permalink

    Enrichment classes for File objects and the like.

  2. object Includer

    Permalink

    Companion object for the Includer class.

    Companion object for the Includer class. Also contains some utility methods, such as the preprocess() method.

  3. package filter

    Permalink

    Contains various file- and I/O-related filter classes.

  4. object util

    Permalink

    Useful file-related utility functions.

Inherited from AnyRef

Inherited from Any

Ungrouped