Releases: dylemma/xml-spac
0.12.1
Maintenance release; no functional changes. Full Changelog: 0.12.0...0.12.1
Library Updates
cats-core2.8.0 -> 2.10.0cats-effect3.3.13 -> 3.5.2fs2-core3.2.7 -> 3.9.2fs2-io3.2.7 -> 3.9.2fs2-data-json1.4.1 -> 1.9.0fs2-data-xml1.4.1 -> 1.9.0jackson-core2.12.3 -> 2.15.3typename1.0.0 -> 1.1.0
Build Updates
- SBT 1.5.2 -> 1.9.6
- Scala 2.12.16 -> 2.12.18
- Scala 2.13.8 -> 2.13.12
- Scala 3.1.3 -> 3.3.1
sbt-pgp2.1.2 -> 2.2.1sbt-sonatype3.9.7 -> 3.9.21
0.12.0
0.11.0
Changes
JavaxSource.fromInputStreamhas been split intofromInputStreamandfromInputStreamWithCharsetJavaxSource.fromFilehas been split intofromFileandfromFileWithCharset
Bugfix
JacksonSource.fromStringis now reusable as intended
Additions
- Added
Source.deferto help construct reusable Sources
0.10.0
This is another refactor release, with two focus areas:
- reduce usage of typeclasses involved with the
.parsemethod - decouple the library from cats-effect and fs2
The bottom line is that the interfaces for Parser construction remain the same, but the way you run a Parser to consume data is different.
Major Changes
- Removed
JavaxSupportandIntoXmlEventReader- useJavaxSourcemethods instead - Removed
JacksonSupportandIntoJacksonJsonParser- useJacksonSourceinstead - Removed
Fs2DataSupport(for both XML and JSON) - useFs2DataSourceinstead - Removed
ChunkSize - Removed
Parsable- methods formerly using this now accept Source / Iterator / fs2.Stream explicitly - Refactored
Parser#parse- no longer usesParsabletypeclass; two overloads takeIterator[In]andSource[In]respectively. - Refactored
JavaxSource- provides explicitfromXmethods returningSource[XmlEvent], no longer providesfs2.Streamconstructors - Refactored
JacksonSource- provides explicitfromXmethods returningSource[JsonEvent], no longer providesfs2.Streamconstructors - Refactored
Fs2DataSource(for both XML and JSON) - provides explicitfromXmethods returningStream[F, XmlEvent]andStream[F, JsonEvent]respectively - Refactored XML
Fs2DataSource.Middleware; rename toCleanup,Middleware.defaultbecameCleanup(object), andMiddleware.nonebecameNoCleanup - Moved
Parser#parseFtoio.dylemma.spac.interop.fs2 - Moved
Parser#toPipetoio.dylemma.spac.interop.fs2 - Moved
Transformer#toPipetoio.dylemma.spac.interop.fs2 - Added overload for
Transformer#transformthat takes aSource - Added
Source[A]trait (like an upgradedIterableadds resource management around itsiterator) - Added
Source#toResourceandSource#toStreamtoio.dylemma.spac.interop.fs2 - Added
Parser#startfor situations where you don't want to consume the entire input all at once - Added
Parser#flatten - Added
JsonSplitter#asNullable
Dependency Updates
- Scala
2.12.10->2.12.16 - Scala
2.13.5->2.13.8 - Scala
3.0.0->3.1.3 - Cats Core
2.6.1->2.8.0 - Cats Effect
3.1.1->3.3.13 - FS2
3.0.3->3.2.7 - FS2-Data
1.0.0-RC3->1.4.1
0.9.2
0.9.1
0.9
This is a big one! See here for a full list of issues and PRs related to this release, but I'll point out the highlights:
Better Error Handling (#14)
In previous versions of SPaC, it was pretty difficult to tell exactly what was going wrong if a complicated parser crashed. Most of the time it was due to some optional attribute/element being treated as mandatory, but the exceptions thrown when that happened didn't do a good job of informing you about what was missing, from where, and which part of your parser wanted it.
This release introduces SpacException, which comes with a special "Spac Trace" (I couldn't resist the pun on "Stack Trace"), where the normal StackTraceElements are replaced with SpacTraceElements which will provide useful debug information, like:
io.dylemma.spac.SpacException$MissingFirstException: Parser context ended before the first String could be found.
at Input(</data>) - {line: 11, col: 14, offset: 230}
at Splitter(elem(data) \ elem(bar)) - ErrorHandlingTest.scala:32
at Compound Parser member 3 of 3
at InputContext(<data id="123">) - {line: 8, col: 22, offset: 151}
at InputContext(<thing>) - {line: 2, col: 11, offset: 18}
at InputContext(<root>) - {line: 1, col: 7, offset: 6}
at Splitter(elem(root) \ elem(thing) \ elem(data)) - ErrorHandlingTest.scala:44
at parse - ErrorHandlingTest.scala:60
(see the linked issue for the raw XML and associated Parser that caused this exception)
Integration with Cats and Fs2 (#27)
SPaC now comes with a built-in integration with Cats and Fs2. Some cool things come from that:
- There's an
Applicative[Parser[In, *]], which means you can use Cats'mapNmethod to combine multiple parsers - Parser and Transformer can both be converted to an fs2
Pipe - Parser gains a
parseFmethod that suspends the parser handler logic in anF[_]effect likecats.effect.IO
Support for Multiple Parser Backends (#27)
In previous versions of SPaC, XMLParser was implemented in terms of javax.xml.stream.event.XMLEvent, meaning that all of the underlying XML parsing logic was done by classes provided by the Java standard library. Similarly. JsonParser was implemented in a way that only allowed for the Jackson JSON library to be used as the underlying parser.
This release introduces the concept of a "parser backend", allowing you to choose how you want to obtain your XML/JSON data.
You use a specific import to select your backend, and SPaC will use that backend to create the underlying event stream, and convert that stream to one of the event models defined in xml-spac or json-spac as appropriate.
The Javax and Jackson logic is still available via their own respective imports, but this release also introduces support for fs2-data to be used as the parser backend.
Migration Guide
There were a handful of source-breaking changes made in this release. See the wiki for a hopefully-complete migration guide.
0.8
This release addresses concerns raised by #21
- Make
XMLResourceandJsonResourcecontravariant - Ensure
InputStreams andReaders not created by*Resourcewill not be closed by that resource. Responsibility for closing streams should lie with whoever constructed the stream. - Introduce
*Resourcefor() => Ttypes to allow for easier support for specialized types. Due to the constructor style, Resources created in this way will close the constructed stream.
0.7
This release closes #18 and #22.
- Add support for scala 2.13
- Use SBT version 1.3.3
- Add
firstNotNullconvenience to JsonSplitter - Add
JsonParser.objectOf[T]to parse a JSON object intoMap[String, T] - Add
flattenmethod to Transformers - Cleaned up the XMLSplitter.firstOption API (no longer uses the
Trytype) - Removed the
HandlerFactoryabstraction as it was no longer necessary
0.6
Major Changes
- Parser and Consumer have been merged.
- Parser no longer wraps its results with
Try; exceptions will be thrown. Useparser.wrapSafeto emulate old behavior.
- Parser no longer wraps its results with
xml-spachas been split into separate modules:spac-core,xml-spac, andjson-spac- All XML-specific features of Parser and Splitter now exist in XMLParser and XMLSplitter
- If you were using
Parser, you should now useXMLParser.- except for
Parser.constant
- except for
- If you were using
Splitter, you should now useXMLSplitter.
- If you were using
- New JSON-specific features exist on JsonParser and JsonSplitter
- The
Splittertrait and companion still exist, but only with general-purpose methods - The
Parsercompanion now only contains generic parser constructors. For XML or JSON-specific parsers, use the XMLParser or JsonParser objects.
- All XML-specific features of Parser and Splitter now exist in XMLParser and XMLSplitter
- Removed the homemade
Functorimplementation, and theFunctorSyntaxconvenience methods. Possible integration with Cats at a later date.
Minor Changes
- Most of the
Consumer/ParserandTransformerconvenience constructors have been lower-cased - ContextMatcher now takes an
Elemtype parameter (to support matching against JSON and XML contexts) - The internals of
Splitterhave some new abstractions that make it easier to create custom splitters - The new
FromHandlerFactortypeclass makes it easier to convert between Parser and Consumer - Deprecated
Splitter#through, renamed it tomap - Changed some of the internal event management classes to better support JSON events/contexts
New Features
- JSON support via
json-spac - Add
Transformer#transformfor #16 - Splitter now supports
flatMap-ing withTransformer(see Example6 for why this is helpful) - ConsumableLike now exposes an Iterator for pull-style parsing
- Add
Parser#orElseto handle varying input formats - Add
Parser#interruptedByto help with certainfollowedByscenarios (see Example7) - Add
Parser#beforeContextas a convenience forParser#interruptedBy