class Includer extends Iterator[String]
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.
WARNING: This class is not thread-safe.
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"))
- Alphabetic
- By Inheritance
- Includer
- Iterator
- IterableOnceOps
- IterableOnce
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- class GroupedIterator[B >: A] extends AbstractIterator[Seq[B]]
- Definition Classes
- Iterator
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ++[B >: String](xs: => IterableOnce[B]): Iterator[B]
- Definition Classes
- Iterator
- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def addString(b: StringBuilder): StringBuilder
- Definition Classes
- IterableOnceOps
- Annotations
- @inline()
- final def addString(b: StringBuilder, sep: String): StringBuilder
- Definition Classes
- IterableOnceOps
- Annotations
- @inline()
- def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder
- Definition Classes
- IterableOnceOps
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def buffered: BufferedIterator[String]
- Definition Classes
- Iterator
- def clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def collect[B](pf: PartialFunction[String, B]): Iterator[B]
- Definition Classes
- Iterator → IterableOnceOps
- def collectFirst[B](pf: PartialFunction[String, B]): Option[B]
- Definition Classes
- IterableOnceOps
- def concat[B >: String](xs: => IterableOnce[B]): Iterator[B]
- Definition Classes
- Iterator
- def contains(elem: Any): Boolean
- Definition Classes
- Iterator
- def copyToArray[B >: String](xs: Array[B], start: Int, len: Int): Int
- Definition Classes
- IterableOnceOps
- def copyToArray[B >: String](xs: Array[B], start: Int): Int
- Definition Classes
- IterableOnceOps
- def copyToArray[B >: String](xs: Array[B]): Int
- Definition Classes
- IterableOnceOps
- def corresponds[B](that: IterableOnce[B])(p: (String, B) => Boolean): Boolean
- Definition Classes
- IterableOnceOps
- def count(p: (String) => Boolean): Int
- Definition Classes
- IterableOnceOps
- def distinct: Iterator[String]
- Definition Classes
- Iterator
- def distinctBy[B](f: (String) => B): Iterator[String]
- Definition Classes
- Iterator
- def drop(n: Int): Iterator[String]
- Definition Classes
- Iterator → IterableOnceOps
- def dropWhile(p: (String) => Boolean): Iterator[String]
- Definition Classes
- Iterator → IterableOnceOps
- def duplicate: (Iterator[String], Iterator[String])
- Definition Classes
- Iterator
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def exists(p: (String) => Boolean): Boolean
- Definition Classes
- IterableOnceOps
- def filter(p: (String) => Boolean): Iterator[String]
- Definition Classes
- Iterator → IterableOnceOps
- def filterNot(p: (String) => Boolean): Iterator[String]
- Definition Classes
- Iterator → IterableOnceOps
- def finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def find(p: (String) => Boolean): Option[String]
- Definition Classes
- IterableOnceOps
- def flatMap[B](f: (String) => IterableOnce[B]): Iterator[B]
- Definition Classes
- Iterator → IterableOnceOps
- def flatten[B](implicit ev: (String) => IterableOnce[B]): Iterator[B]
- Definition Classes
- Iterator → IterableOnceOps
- def fold[A1 >: String](z: A1)(op: (A1, A1) => A1): A1
- Definition Classes
- IterableOnceOps
- def foldLeft[B](z: B)(op: (B, String) => B): B
- Definition Classes
- IterableOnceOps
- def foldRight[B](z: B)(op: (String, B) => B): B
- Definition Classes
- IterableOnceOps
- def forall(p: (String) => Boolean): Boolean
- Definition Classes
- IterableOnceOps
- def foreach[U](f: (String) => U): Unit
- Definition Classes
- IterableOnceOps
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def grouped[B >: String](size: Int): GroupedIterator[B]
- Definition Classes
- Iterator
- def hasNext: Boolean
Determine whether there are any more input lines to be read from the includer.
Determine whether there are any more input lines to be read from the includer.
- returns
trueif at least one more line is available,falseotherwise
- Definition Classes
- Includer → Iterator
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- val includeRegex: Regex
- def indexOf[B >: String](elem: B, from: Int): Int
- Definition Classes
- Iterator
- def indexOf[B >: String](elem: B): Int
- Definition Classes
- Iterator
- def indexWhere(p: (String) => Boolean, from: Int): Int
- Definition Classes
- Iterator
- def isEmpty: Boolean
- Definition Classes
- Iterator → IterableOnceOps
- Annotations
- @deprecatedOverriding("isEmpty is defined as !hasNext; override hasNext instead", "2.13.0")
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isTraversableAgain: Boolean
- Definition Classes
- IterableOnceOps
- final def iterator: Iterator[String]
- Definition Classes
- Iterator → IterableOnce
- Annotations
- @inline()
- def knownSize: Int
- Definition Classes
- IterableOnce
- final def length: Int
- Definition Classes
- Iterator
- Annotations
- @inline()
- def map[B](f: (String) => B): Iterator[B]
- Definition Classes
- Iterator → IterableOnceOps
- def max[B >: String](implicit ord: Ordering[B]): String
- Definition Classes
- IterableOnceOps
- def maxBy[B](f: (String) => B)(implicit cmp: Ordering[B]): String
- Definition Classes
- IterableOnceOps
- def maxByOption[B](f: (String) => B)(implicit cmp: Ordering[B]): Option[String]
- Definition Classes
- IterableOnceOps
- val maxNesting: Int
- def maxOption[B >: String](implicit ord: Ordering[B]): Option[String]
- Definition Classes
- IterableOnceOps
- def min[B >: String](implicit ord: Ordering[B]): String
- Definition Classes
- IterableOnceOps
- def minBy[B](f: (String) => B)(implicit cmp: Ordering[B]): String
- Definition Classes
- IterableOnceOps
- def minByOption[B](f: (String) => B)(implicit cmp: Ordering[B]): Option[String]
- Definition Classes
- IterableOnceOps
- def minOption[B >: String](implicit ord: Ordering[B]): Option[String]
- Definition Classes
- IterableOnceOps
- final def mkString: String
- Definition Classes
- IterableOnceOps
- Annotations
- @inline()
- final def mkString(sep: String): String
- Definition Classes
- IterableOnceOps
- Annotations
- @inline()
- final def mkString(start: String, sep: String, end: String): String
- Definition Classes
- IterableOnceOps
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def next(): String
Get the next input line.
Get the next input line. You should call
hasNextbefore calling this method, to ensure that there are input lines remaining. Callingnexton an emptyIncluderwill result in a runtime exception- returns
the next input line
- Definition Classes
- Includer → Iterator
- Annotations
- @SuppressWarnings() @throws(scala.this.throws.<init>$default$1[NoSuchElementException])
- Exceptions thrown
NoSuchElementExceptionif there isn't a next element.
- def nextOption(): Option[String]
- Definition Classes
- Iterator
- def nonEmpty: Boolean
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecatedOverriding("nonEmpty is defined as !isEmpty; override isEmpty instead", "2.13.0")
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def padTo[B >: String](len: Int, elem: B): Iterator[B]
- Definition Classes
- Iterator
- def partition(p: (String) => Boolean): (Iterator[String], Iterator[String])
- Definition Classes
- Iterator
- def patch[B >: String](from: Int, patchElems: Iterator[B], replaced: Int): Iterator[B]
- Definition Classes
- Iterator
- def product[B >: String](implicit num: Numeric[B]): B
- Definition Classes
- IterableOnceOps
- def reduce[B >: String](op: (B, B) => B): B
- Definition Classes
- IterableOnceOps
- def reduceLeft[B >: String](op: (B, String) => B): B
- Definition Classes
- IterableOnceOps
- def reduceLeftOption[B >: String](op: (B, String) => B): Option[B]
- Definition Classes
- IterableOnceOps
- def reduceOption[B >: String](op: (B, B) => B): Option[B]
- Definition Classes
- IterableOnceOps
- def reduceRight[B >: String](op: (String, B) => B): B
- Definition Classes
- IterableOnceOps
- def reduceRightOption[B >: String](op: (String, B) => B): Option[B]
- Definition Classes
- IterableOnceOps
- def reversed: Iterable[String]
- Attributes
- protected
- Definition Classes
- IterableOnceOps
- def sameElements[B >: String](that: IterableOnce[B]): Boolean
- Definition Classes
- Iterator
- def scanLeft[B](z: B)(op: (B, String) => B): Iterator[B]
- Definition Classes
- Iterator → IterableOnceOps
- def size: Int
- Definition Classes
- IterableOnceOps
- def slice(from: Int, until: Int): Iterator[String]
- Definition Classes
- Iterator → IterableOnceOps
- def sliceIterator(from: Int, until: Int): Iterator[String]
- Attributes
- protected
- Definition Classes
- Iterator
- def sliding[B >: String](size: Int, step: Int): GroupedIterator[B]
- Definition Classes
- Iterator
- val source: IncludeSource
- def span(p: (String) => Boolean): (Iterator[String], Iterator[String])
- Definition Classes
- Iterator → IterableOnceOps
- def splitAt(n: Int): (Iterator[String], Iterator[String])
- Definition Classes
- IterableOnceOps
- def stepper[S <: Stepper[_]](implicit shape: StepperShape[String, S]): S
- Definition Classes
- IterableOnce
- def sum[B >: String](implicit num: Numeric[B]): B
- Definition Classes
- IterableOnceOps
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def take(n: Int): Iterator[String]
- Definition Classes
- Iterator → IterableOnceOps
- def takeWhile(p: (String) => Boolean): Iterator[String]
- Definition Classes
- Iterator → IterableOnceOps
- def tapEach[U](f: (String) => U): Iterator[String]
- Definition Classes
- Iterator → IterableOnceOps
- def to[C1](factory: Factory[String, C1]): C1
- Definition Classes
- IterableOnceOps
- def toArray[B >: String](implicit arg0: ClassTag[B]): Array[B]
- Definition Classes
- IterableOnceOps
- final def toBuffer[B >: String]: Buffer[B]
- Definition Classes
- IterableOnceOps
- Annotations
- @inline()
- def toIndexedSeq: IndexedSeq[String]
- Definition Classes
- IterableOnceOps
- def toList: List[String]
- Definition Classes
- IterableOnceOps
- def toMap[K, V](implicit ev: <:<[String, (K, V)]): Map[K, V]
- Definition Classes
- IterableOnceOps
- def toSeq: Seq[String]
- Definition Classes
- IterableOnceOps
- def toSet[B >: String]: Set[B]
- Definition Classes
- IterableOnceOps
- def toString(): String
- Definition Classes
- Iterator → AnyRef → Any
- def toVector: Vector[String]
- Definition Classes
- IterableOnceOps
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def withFilter(p: (String) => Boolean): Iterator[String]
- Definition Classes
- Iterator
- def zip[B](that: IterableOnce[B]): Iterator[(String, B)]
- Definition Classes
- Iterator
- def zipAll[A1 >: String, B](that: IterableOnce[B], thisElem: A1, thatElem: B): Iterator[(A1, B)]
- Definition Classes
- Iterator
- def zipWithIndex: Iterator[(String, Int)]
- Definition Classes
- Iterator → IterableOnceOps
Deprecated Value Members
- final def /:[B](z: B)(op: (B, String) => B): B
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.13.0) Use foldLeft instead of /:
- final def :\[B](z: B)(op: (String, B) => B): B
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.13.0) Use foldRight instead of :\
- def aggregate[B](z: => B)(seqop: (B, String) => B, combop: (B, B) => B): B
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0)
aggregateis not relevant for sequential collections. UsefoldLeft(z)(seqop)instead.
- final def copyToBuffer[B >: String](dest: Buffer[B]): Unit
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.13.0) Use
dest ++= collinstead
- final def hasDefiniteSize: Boolean
- Definition Classes
- Iterator → IterableOnceOps
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.13.0) hasDefiniteSize on Iterator is the same as isEmpty
- def scanRight[B](z: B)(op: (String, B) => B): Iterator[B]
- Definition Classes
- Iterator
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Call scanRight on an Iterable instead.
- def seq: Includer.this.type
- Definition Classes
- Iterator
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Iterator.seq always returns the iterator itself
- final def toIterator: Iterator[String]
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.13.0) Use .iterator instead of .toIterator
- final def toStream: Stream[String]
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.13.0) Use .to(LazyList) instead of .toStream