Skip to content

Hide implicit CSVFormat in dedicated object #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ libraryDependencies += "com.github.tototoshi" %% "scala-csv" % "1.3.0-SNAPSHOT"

```scala
scala> import com.github.tototoshi.csv._
scala> import implicits._ // for a default CSVFormat instance
```

### Reading example
Expand Down
5 changes: 5 additions & 0 deletions src/main/scala/com/github/tototoshi/csv/CSVFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
*/
package com.github.tototoshi.csv

import scala.annotation.implicitNotFound

@implicitNotFound(
"Cannot find implicit instance of com.github.tototoshi.csv.CSVFormat. Create your own, or import com.github.tototoshi.csv.implicits._"
)
trait CSVFormat {

val delimiter: Char
Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/com/github/tototoshi/csv/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package com.github.tototoshi

package object csv {

implicit val defaultCSVFormat = new DefaultCSVFormat {}
object implicits {
implicit val defaultCSVFormat: CSVFormat = new DefaultCSVFormat {}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.github.tototoshi.csv
import java.io.{ UnsupportedEncodingException, FileReader, File, StringReader }

import org.scalatest._
import implicits._

class CSVReaderSpec extends FunSpec with ShouldMatchers with Using {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.github.tototoshi.csv
import java.io.{ FileOutputStream, UnsupportedEncodingException, FileWriter, File }

import org.scalatest._
import implicits._

class CSVWriterSpec extends FunSpec with ShouldMatchers with BeforeAndAfter with Using {

Expand Down