Skip to content

Commit 83f733c

Browse files
Initial Commit
0 parents  commit 83f733c

File tree

9 files changed

+160
-0
lines changed

9 files changed

+160
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
target/
2+
.idea/
3+
# vim
4+
*.sw?
5+
6+
# Ignore [ce]tags files
7+
tags

.scalafmt.conf

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# tune this file as appropriate to your style! see: https://olafurpg.github.io/scalafmt/#Configuration
2+
3+
maxColumn = 80
4+
5+
continuationIndent.callSite = 2
6+
7+
newlines {
8+
sometimesBeforeColonInMethodReturnType = false
9+
}
10+
11+
align {
12+
arrowEnumeratorGenerator = false
13+
ifWhileOpenParen = false
14+
openParenCallSite = false
15+
openParenDefnSite = false
16+
17+
tokens = ["%", "%%"]
18+
}
19+
20+
docstrings = JavaDoc
21+
22+
rewrite {
23+
rules = [SortImports, RedundantBraces]
24+
redundantBraces.maxLines = 1
25+
}

.travis.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
sudo: false
2+
language: scala
3+
4+
scala:
5+
- 2.12.4
6+
7+
before_cache:
8+
- find $HOME/.sbt -name "*.lock" -type f -delete
9+
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -type f -delete
10+
11+
cache:
12+
directories:
13+
- $HOME/.ivy2/cache
14+
- $HOME/.coursier/cache
15+
- $HOME/.sbt
16+
17+
jdk:
18+
- oraclejdk8

bar.txt

+1
Large diffs are not rendered by default.

build.sbt

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
lazy val readFileLines = project.in(file("."))
2+
.settings(commonSettings)
3+
.settings(
4+
name := "readFileLines"
5+
)
6+
7+
/***********************************************************************\
8+
Boilerplate below these lines
9+
\***********************************************************************/
10+
11+
12+
13+
14+
lazy val commonSettings = Seq(
15+
organization := "tech.christopherdavenport",
16+
licenses += ("MIT", url("https://opensource.org/licenses/MIT")),
17+
18+
scalaVersion := "2.12.4",
19+
20+
addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.4" cross CrossVersion.binary),
21+
22+
libraryDependencies ++= Seq(
23+
// "org.typelevel" %% "cats-core" % "1.0.0-RC1",
24+
//
25+
// "org.typelevel" %% "kittens" % "1.0.0-RC1",
26+
// "org.typelevel" %% "alleycats-core" % "1.0.0-RC1",
27+
// "org.typelevel" %% "mouse" % "0.12",
28+
//
29+
// "org.typelevel" %% "cats-effect" % "0.5",
30+
//
31+
// "com.chuusai" %% "shapeless" % "2.3.2",
32+
//
33+
// "co.fs2" %% "fs2-core" % "0.10.0-M8",
34+
"co.fs2" %% "fs2-io" % "0.10.0-RC1",
35+
//
36+
// "org.http4s" %% "http4s-dsl" % "0.18.0-M5",
37+
// "org.http4s" %% "http4s-blaze-server" % "0.18.0-M5",
38+
// "org.http4s" %% "http4s-blaze-client" % "0.18.0-M5",
39+
// "org.http4s" %% "http4s-circe" % "0.18.0-M5",
40+
//
41+
// "io.circe" %% "circe-core" % "0.9.0-M2",
42+
// "io.circe" %% "circe-generic" % "0.9.0-M2",
43+
// "io.circe" %% "circe-parser" % "0.9.0-M2",
44+
//
45+
// "io.circe" %% "circe-fs2" % "0.9.0-M3",
46+
//
47+
// "org.tpolecat" %% "doobie-core" % "0.5.0-M9",
48+
// "org.tpolecat" %% "doobie-h2" % "0.5.0-M9",
49+
// "org.tpolecat" %% "doobie-hikari" % "0.5.0-M9",
50+
// "org.tpolecat" %% "doobie-postgres" % "0.5.0-M9",
51+
// "org.tpolecat" %% "doobie-specs2" % "0.5.0-M9",
52+
//
53+
// "com.github.pureconfig" %% "pureconfig" % "0.8.0",
54+
//
55+
// "eu.timepit" %% "refined" % "0.8.4",
56+
// "eu.timepit" %% "refined-scalacheck" % "0.8.4" % Test,
57+
58+
"org.specs2" %% "specs2-core" % "4.0.1" % Test,
59+
"org.specs2" %% "specs2-scalacheck" % "4.0.1" % Test,
60+
"org.typelevel" %% "discipline" % "0.8" % Test,
61+
"com.github.alexarchambault" %% "scalacheck-shapeless_1.13" % "1.1.6" % Test
62+
)
63+
)

project/build.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.1.0

project/plugins.sbt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
addSbtPlugin("com.dwijnand" % "sbt-travisci" % "1.1.1")
2+
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3")
3+
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")
4+
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.3")
5+
addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.1.0")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package tech.christopherdavenport.readfilelines
2+
3+
import cats.effect.IO
4+
import fs2._
5+
import java.nio.file.Paths
6+
7+
object Main extends StreamApp[IO] {
8+
9+
val absoluteFilePath = "/home/davenpcm/Documents/ScalaProjects/Examples/readfilelines/bar.txt"
10+
11+
override def stream(args: List[String], requestShutdown: IO[Unit]): Stream[IO, StreamApp.ExitCode] =
12+
for {
13+
_ <- Stream.eval(getFileContent.compile.drain)
14+
} yield StreamApp.ExitCode(0)
15+
16+
17+
val getFileContent = io.file.readAll[IO](Paths.get(absoluteFilePath), 512)
18+
.through(fs2.text.utf8Decode)
19+
.through(fs2.text.lines)
20+
.evalMap(withEachLine)
21+
22+
23+
def withEachLine(line: String): IO[Unit] = {
24+
if (line.contains("Sarasota Jazz Project")) IO(println(line)) else IO.unit
25+
}
26+
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package tech.christopherdavenport.readfilelines
2+
3+
import org.specs2._
4+
5+
object MainSpec extends mutable.Specification {
6+
7+
"Main" should {
8+
"run a println" in {
9+
Main.main(Array.empty[String]).should_===(())
10+
}
11+
}
12+
13+
}

0 commit comments

Comments
 (0)