Skip to content

Commit

Permalink
Release 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Sep 23, 2024
1 parent 959f23f commit 67fa01d
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 218 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ the project!
To test Ox, use the following dependency, using either [sbt](https://www.scala-sbt.org):

```scala
"com.softwaremill.ox" %% "core" % "0.3.9"
"com.softwaremill.ox" %% "core" % "0.4.0"
```

Or [scala-cli](https://scala-cli.virtuslab.org):

```scala
//> using dep "com.softwaremill.ox::core:0.3.9"
//> using dep "com.softwaremill.ox::core:0.4.0"
```

Documentation is available at [https://ox.softwaremill.com](https://ox.softwaremill.com), ScalaDocs can be browsed at [https://javadoc.io](https://www.javadoc.io/doc/com.softwaremill.ox).
Expand Down
4 changes: 2 additions & 2 deletions generated-doc/out/basics/start-here.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

```scala
// sbt dependency
"com.softwaremill.ox" %% "core" % "0.3.9"
"com.softwaremill.ox" %% "core" % "0.4.0"

// scala-cli dependency
//> using dep com.softwaremill.ox::core:0.3.9
//> using dep com.softwaremill.ox::core:0.4.0
```

## Scope of the Ox project
Expand Down
59 changes: 26 additions & 33 deletions generated-doc/out/channels/io.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

Ox allows creating a `Source` which reads from a file or `InpuStream`, as well as directing an existing source into a file or an `OutputStream`. These methods work only with a `Source[Chunk[Byte]]`. Ox takes care of closing files/streams after processing and on errors.

All I/O operations require the [IO capability](../io.md).

## InputStream and OutputStream

### Source.fromInputStream
Expand All @@ -12,18 +10,17 @@ An `InputStream` can be converted to a `Source[Chunk[Byte]]`:

```scala
import ox.channels.Source
import ox.{IO, supervised}
import ox.supervised
import java.io.ByteArrayInputStream
import java.io.InputStream

val inputStream: InputStream = new ByteArrayInputStream("some input".getBytes)
supervised {
IO.unsafe:
Source
.fromInputStream(inputStream) // Source[Chunk[Byte]]
.decodeStringUtf8
.map(_.toUpperCase)
.foreach(println) // "SOME INPUT"
Source
.fromInputStream(inputStream) // Source[Chunk[Byte]]
.decodeStringUtf8
.map(_.toUpperCase)
.foreach(println) // "SOME INPUT"
}
```

Expand All @@ -32,18 +29,17 @@ You can define a custom chunk size instead of using the default:

```scala
import ox.channels.Source
import ox.{IO, supervised}
import ox.supervised
import java.io.ByteArrayInputStream
import java.io.InputStream

val inputStream: InputStream = new ByteArrayInputStream("some input".getBytes)
supervised {
IO.unsafe:
Source
.fromInputStream(inputStream, chunkSize = 4) // Source[Chunk[Byte]]
.decodeStringUtf8
.map(_.toUpperCase)
.foreach(println) // "SOME", " INPUT"
Source
.fromInputStream(inputStream, chunkSize = 4) // Source[Chunk[Byte]]
.decodeStringUtf8
.map(_.toUpperCase)
.foreach(println) // "SOME", " INPUT"
}
```

Expand All @@ -53,16 +49,15 @@ A `Source[Chunk[Byte]]` can be directed to write to an `OutputStream`:

```scala
import ox.channels.Source
import ox.{IO, supervised}
import ox.supervised
import java.io.ByteArrayOutputStream

val outputStream = new ByteArrayOutputStream()
supervised {
val source = Source.fromIterable(List("text1,", "text2"))
IO.unsafe:
source
.encodeUtf8
.toOutputStream(outputStream)
source
.encodeUtf8
.toOutputStream(outputStream)
}
outputStream.toString // "TEXT1,TEXT2"
```
Expand All @@ -75,16 +70,15 @@ You can obtain a `Source` of byte chunks read from a file for a given path:

```scala
import ox.channels.Source
import ox.{IO, supervised}
import ox.supervised
import java.nio.file.Paths

supervised {
IO.unsafe:
Source
.fromFile(Paths.get("/path/to/my/file.txt"))
.linesUtf8
.map(_.toUpperCase)
.toList // List("FILE_LINE1", "FILE_LINE2")
Source
.fromFile(Paths.get("/path/to/my/file.txt"))
.linesUtf8
.map(_.toUpperCase)
.toList // List("FILE_LINE1", "FILE_LINE2")
}
```

Expand All @@ -96,14 +90,13 @@ A `Source[Chunk[Byte]]` can be written to a file under a given path:

```scala
import ox.channels.Source
import ox.{IO, supervised}
import ox.supervised
import java.nio.file.Paths

supervised {
val source = Source.fromIterable(List("text1,", "text2"))
IO.unsafe:
source
.encodeUtf8
.toFile(Paths.get("/path/to/my/target/file.txt"))
source
.encodeUtf8
.toFile(Paths.get("/path/to/my/target/file.txt"))
}
```
3 changes: 1 addition & 2 deletions generated-doc/out/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ In addition to this documentation, ScalaDocs can be browsed at [https://javadoc.
.. toctree::
:maxdepth: 2
:caption: Resiliency, I/O & utilities
:caption: Resiliency & utilities
oxapp
io
retries
repeat
scheduled
Expand Down
140 changes: 0 additions & 140 deletions generated-doc/out/io.md

This file was deleted.

Loading

0 comments on commit 67fa01d

Please sign in to comment.