Releases: dylemma/xml-spac
0.12.1
Maintenance release; no functional changes. Full Changelog: 0.12.0...0.12.1
Library Updates
cats-core
2.8.0 -> 2.10.0cats-effect
3.3.13 -> 3.5.2fs2-core
3.2.7 -> 3.9.2fs2-io
3.2.7 -> 3.9.2fs2-data-json
1.4.1 -> 1.9.0fs2-data-xml
1.4.1 -> 1.9.0jackson-core
2.12.3 -> 2.15.3typename
1.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-pgp
2.1.2 -> 2.2.1sbt-sonatype
3.9.7 -> 3.9.21
0.12.0
0.11.0
Changes
JavaxSource.fromInputStream
has been split intofromInputStream
andfromInputStreamWithCharset
JavaxSource.fromFile
has been split intofromFile
andfromFileWithCharset
Bugfix
JacksonSource.fromString
is now reusable as intended
Additions
- Added
Source.defer
to help construct reusable Sources
0.10.0
This is another refactor release, with two focus areas:
- reduce usage of typeclasses involved with the
.parse
method - 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
JavaxSupport
andIntoXmlEventReader
- useJavaxSource
methods instead - Removed
JacksonSupport
andIntoJacksonJsonParser
- useJacksonSource
instead - Removed
Fs2DataSupport
(for both XML and JSON) - useFs2DataSource
instead - Removed
ChunkSize
- Removed
Parsable
- methods formerly using this now accept Source / Iterator / fs2.Stream explicitly - Refactored
Parser#parse
- no longer usesParsable
typeclass; two overloads takeIterator[In]
andSource[In]
respectively. - Refactored
JavaxSource
- provides explicitfromX
methods returningSource[XmlEvent]
, no longer providesfs2.Stream
constructors - Refactored
JacksonSource
- provides explicitfromX
methods returningSource[JsonEvent]
, no longer providesfs2.Stream
constructors - Refactored
Fs2DataSource
(for both XML and JSON) - provides explicitfromX
methods returningStream[F, XmlEvent]
andStream[F, JsonEvent]
respectively - Refactored XML
Fs2DataSource.Middleware
; rename toCleanup
,Middleware.default
becameCleanup
(object), andMiddleware.none
becameNoCleanup
- Moved
Parser#parseF
toio.dylemma.spac.interop.fs2
- Moved
Parser#toPipe
toio.dylemma.spac.interop.fs2
- Moved
Transformer#toPipe
toio.dylemma.spac.interop.fs2
- Added overload for
Transformer#transform
that takes aSource
- Added
Source[A]
trait (like an upgradedIterable
adds resource management around itsiterator
) - Added
Source#toResource
andSource#toStream
toio.dylemma.spac.interop.fs2
- Added
Parser#start
for 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'mapN
method to combine multiple parsers - Parser and Transformer can both be converted to an fs2
Pipe
- Parser gains a
parseF
method 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
XMLResource
andJsonResource
contravariant - Ensure
InputStream
s andReader
s not created by*Resource
will not be closed by that resource. Responsibility for closing streams should lie with whoever constructed the stream. - Introduce
*Resource
for() => T
types 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
firstNotNull
convenience to JsonSplitter - Add
JsonParser.objectOf[T]
to parse a JSON object intoMap[String, T]
- Add
flatten
method to Transformers - Cleaned up the XMLSplitter.firstOption API (no longer uses the
Try
type) - Removed the
HandlerFactory
abstraction 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.wrapSafe
to emulate old behavior.
- Parser no longer wraps its results with
xml-spac
has 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
Splitter
trait and companion still exist, but only with general-purpose methods - The
Parser
companion 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
Functor
implementation, and theFunctorSyntax
convenience methods. Possible integration with Cats at a later date.
Minor Changes
- Most of the
Consumer/Parser
andTransformer
convenience constructors have been lower-cased - ContextMatcher now takes an
Elem
type parameter (to support matching against JSON and XML contexts) - The internals of
Splitter
have some new abstractions that make it easier to create custom splitters - The new
FromHandlerFactor
typeclass 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#transform
for #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#orElse
to handle varying input formats - Add
Parser#interruptedBy
to help with certainfollowedBy
scenarios (see Example7) - Add
Parser#beforeContext
as a convenience forParser#interruptedBy