This repository has been archived by the owner on Apr 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Removes SBT dependency from core module #633
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,16 +16,16 @@ | |
|
||
package sbtorgpolicies | ||
|
||
import java.io.File | ||
import java.io._ | ||
import java.net.URL | ||
import java.nio.charset.Charset | ||
import java.nio.file.Path | ||
import java.nio.file.Paths.get | ||
|
||
import cats.syntax.either._ | ||
// import sbt.io._ | ||
// import sbt.io.syntax._ | ||
import sbt.{file, File} | ||
import sbtorgpolicies.exceptions.IOException | ||
|
||
import scala.io.Source | ||
import scala.language.implicitConversions | ||
|
||
package object io { | ||
|
@@ -53,7 +53,7 @@ package object io { | |
|
||
def toPath: Path = get(filename) | ||
|
||
def toFile: File = file(filename.fixPath) | ||
def toFile: File = new File(filename.fixPath) | ||
|
||
def fixPath: String = filename.replaceAll("/", File.separator) | ||
|
||
|
@@ -63,4 +63,47 @@ package object io { | |
else File.separator) | ||
} | ||
} | ||
|
||
object IO { | ||
|
||
def file(path: String): File = new File(path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IO.file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inception? |
||
|
||
def url(address: String): URL = new URL(address) | ||
|
||
def readLines(file: File): Iterator[String] = | ||
Source.fromFile(file).getLines() | ||
|
||
def readBytes(file: File): Array[Byte] = { | ||
val is: InputStream = new FileInputStream(file) | ||
val array: Array[Byte] = Stream.continually(is.read).takeWhile(_ != -1).map(_.toByte).toArray | ||
is.close() | ||
array | ||
} | ||
|
||
def write(file: File, content: String, charset: Charset = Charset.forName("UTF-8")): Unit = { | ||
val writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, false), charset)) | ||
writer.write(content) | ||
writer.close() | ||
} | ||
|
||
def relativize(base: File, file: File): Option[String] = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
def ensureEndingSlash: Option[String] = { | ||
val path = base.getAbsolutePath | ||
path.lastOption.map { | ||
case c if c == File.separatorChar => path | ||
case _ => path + File.separatorChar | ||
} | ||
} | ||
|
||
val baseFileString = if (base.isDirectory) ensureEndingSlash else None | ||
val pathString = file.getAbsolutePath | ||
baseFileString flatMap { | ||
case baseString if pathString.startsWith(baseString) => | ||
Some(pathString.substring(baseString.length)) | ||
case _ => None | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IO.file
to be consistent?