Skip to content
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

migration to scala 2.11.2 (supports 2.10.4), dropped support for 2.9.x #7

Open
wants to merge 4 commits 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ target/
.project
.classpath
.idea*

src/main/.DS_Store
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ An ASCII-art diagram library for graphs. It supports both parsing existing diagr

You can use it via sbt:

libraryDependencies += "com.github.mdr" %% "ascii-graphs" % "0.0.3"
libraryDependencies += "com.github.mdr" %% "ascii-graphs" % "0.0.7"

# Graph layout

import com.github.mdr.ascii.layout._
import com.github.mdr.ascii.graph.Graph
import com.github.mdr.ascii.layout.GraphLayout

val graph = Graph(
vertices = List(
Expand All @@ -19,7 +20,7 @@ You can use it via sbt:
"V2" -> "V5",
"V2" -> "V6"))

val ascii = Layouter.renderGraph(graph)
val ascii = GraphLayout.renderGraph(graph)

println(ascii)

Expand Down
20 changes: 13 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import AssemblyKeys._

assemblySettings

name := "ascii-graphs"

organization := "com.github.mdr"

version := "0.0.6"
version := "0.0.7"

scalaVersion := "2.11.2"

scalaVersion := "2.10.1"
crossScalaVersions := Seq("2.10.4", "2.11.2")

crossScalaVersions := Seq("2.9.1", "2.9.2", "2.10.1")
scalacOptions ++= Seq("-optimize", "-Yinline-warnings", "-feature", "-deprecation")

scalacOptions ++= Seq("-deprecation")
javacOptions ++= Seq("-source", "1.7", "-target", "1.7")

javacOptions ++= Seq("-source", "1.6", "-target", "1.6")
libraryDependencies ++= Seq()

libraryDependencies += "org.scalatest" %% "scalatest" % "1.9.1" % "test"
libraryDependencies += ("org.scalatest" %% "scalatest" % "2.1.3" % "test")

libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.10.1" % "test"
libraryDependencies += ("org.scalacheck" %% "scalacheck" % "1.11.5" % "test")

// Screen-sized dependency graph:
// libraryDependencies += "org.vert-x" % "vertx-core" % "1.3.1.final"
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.12.3
sbt.version=0.13.0
21 changes: 15 additions & 6 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.2.0")
logLevel := Level.Warn

resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)

resolvers ++= Seq(
"Sonatype Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
"Sonatype Releases" at "http://oss.sonatype.org/content/repositories/releases"
)

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.3")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.2.0")

// addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4-SNAPSHOT")
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4")

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.4.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.2")

addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.0.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")
8 changes: 6 additions & 2 deletions src/main/scala/com/github/mdr/ascii/util/Utils.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.mdr.ascii.util

import java.net.URL

import scala.annotation.tailrec
import scala.io.Source

Expand All @@ -21,7 +23,9 @@ object Utils {
}

def adjacentPairs[T](xs: List[T]): List[(T, T)] = xs zip xs.drop(1)

def adjacentTriples[T](xs: List[T]): List[(T, T, T)] = xs zip xs.drop(1) zip xs.drop(2) map { case ((x, y), z) ⇒ (x, y, z) }

def adjacentPairsWithPreviousAndNext[T](xs: List[T]): List[(Option[T], T, T, Option[T])] =
(None :: xs.init.map(Some(_))) zip xs zip xs.drop(1) zip (xs.drop(2).map(Some(_)) :+ None) map {
case (((x, y), z), u) ⇒ (x, y, z, u)
Expand Down Expand Up @@ -53,8 +57,8 @@ object Utils {
}

def getResourceAsString(path: String): String = {
val inputStream = getClass.getResourceAsStream(path)
Source.fromInputStream(inputStream).getLines.mkString("\n")
val url: URL = getClass.getResource(path)
Source.fromURL(url, "utf-8").mkString
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.github.mdr.ascii.diagram.parser

import org.scalatest.matchers.ShouldMatchers
import org.scalatest.FlatSpec
import org.scalatest.{ Matchers, FlatSpec }
import com.github.mdr.ascii.diagram.Diagram
import com.github.mdr.ascii.diagram.Box
import com.github.mdr.ascii.util.Utils
import scala.io.Source

class GraphDiagramParserTest extends FlatSpec with ShouldMatchers {
class GraphDiagramParserTest extends FlatSpec with Matchers {

"Parser" should "parse labels" in {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.github.mdr.ascii.graph

import org.scalacheck._
import org.scalacheck.Gen.Params
import org.scalacheck.Gen.Parameters
import scala.util.Random
import com.github.mdr.ascii.layout.cycles.CycleRemover

object GraphGenerators {

implicit val graphGen: Gen[Graph[String]] = Gen { p: Params ⇒ Some(RandomGraph.randomGraph(new Random(p.rng))) }
implicit val graphGen: Gen[Graph[String]] = Gen.parameterized {
p: Parameters ⇒
RandomGraph.randomGraph(p.rng)
}

implicit val arbitraryGraph = Arbitrary(graphGen)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package com.github.mdr.ascii.graph

import org.scalacheck.Arbitrary
import org.scalacheck.Gen
import org.scalacheck.Gen.Params
import org.scalacheck.Prop.forAll
import org.scalacheck.Properties
import org.scalacheck.Shrink
import com.github.mdr.ascii.util.Utils
import com.github.mdr.ascii.graph.GraphGenerators._
import com.github.mdr.ascii.layout.cycles.CycleRemover

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.mdr.ascii.graph

import org.scalatest.FlatSpec
import org.scalatest.{ Matchers, FlatSpec }
import org.scalatest.matchers.ShouldMatchers
import org.scalatest.prop.Checkers

class TopologicalSortTest extends FlatSpec with ShouldMatchers with Checkers {
class TopologicalSortTest extends FlatSpec with Matchers with Checkers {

check("""
+-+ +-+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.github.mdr.ascii.layout

import org.scalatest.matchers.ShouldMatchers
import org.scalatest.FlatSpec
import org.scalatest.{ Matchers, FlatSpec }
import com.github.mdr.ascii.graph.Graph

// https://github.com/mdr/ascii-graphs/issues/3
class Issue3InfiniteLoopTest extends FlatSpec with ShouldMatchers {
class Issue3InfiniteLoopTest extends FlatSpec with Matchers {

"Layouter" should "not go into an infinite loop" in {
val v = Set("1", "2", "3", "7", "9")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.github.mdr.ascii.layout

import org.scalatest.FlatSpec
import org.scalatest.{ Matchers, FlatSpec }
import org.scalatest.matchers.ShouldMatchers
import com.github.mdr.ascii.graph.Graph
import com.github.mdr.ascii.layout.RoundTripSpecification._

class RoundTripTest extends FlatSpec with ShouldMatchers {
class RoundTripTest extends FlatSpec with Matchers {

"Round trip" should ("not overwrite an arrow") in {
checkRoundTrip(Graph.fromDiagram("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ package com.github.mdr.ascii.layout.cycles

import scala.util.Random._

import org.scalacheck.Arbitrary
import org.scalacheck.Gen
import org.scalacheck.Gen.Params
import org.scalacheck.Prop.forAll
import org.scalacheck.Properties
import org.scalacheck.Shrink

import com.github.mdr.ascii.graph.Graph
import com.github.mdr.ascii.graph.GraphUtils
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.github.mdr.ascii.layout.cycles

import org.scalatest.FlatSpec
import org.scalatest.{ Matchers, FlatSpec }
import org.scalatest.matchers.ShouldMatchers

import com.github.mdr.ascii.graph.Graph
import com.github.mdr.ascii.graph.GraphUtils
import com.github.mdr.ascii.util.Utils

class CycleRemoverTest extends FlatSpec with ShouldMatchers {
class CycleRemoverTest extends FlatSpec with Matchers {

check("""
+-+ +-+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.github.mdr.ascii.layout.cycles

import org.scalatest.FlatSpec
import org.scalatest.{ Matchers, FlatSpec }
import org.scalatest.matchers.ShouldMatchers

import com.github.mdr.ascii.graph.Graph
import com.github.mdr.ascii.util.Utils

class GraphReflowTest extends FlatSpec with ShouldMatchers {
class GraphReflowTest extends FlatSpec with Matchers {

reflowingGraph("""
+-+ +-+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package com.github.mdr.ascii.layout.layering

import org.scalacheck.Arbitrary
import org.scalacheck.Gen
import org.scalacheck.Gen.Params
import org.scalacheck.Prop.forAll
import org.scalacheck.Properties
import org.scalacheck.Shrink
import com.github.mdr.ascii.graph.Graph
import com.github.mdr.ascii.graph.GraphGenerators._
import com.github.mdr.ascii.layout.cycles.CycleRemover
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.github.mdr.ascii.layout.layering

import org.scalatest.FlatSpec
import org.scalatest.{ Matchers, FlatSpec }
import org.scalatest.matchers.ShouldMatchers

import com.github.mdr.ascii.graph.GraphUtils
import com.github.mdr.ascii.graph.Graph
import com.github.mdr.ascii.util.Utils
import com.github.mdr.ascii.layout.cycles.CycleRemover

class CrossingCalculatorTest extends FlatSpec with ShouldMatchers {
class CrossingCalculatorTest extends FlatSpec with Matchers {

// Note: layer ordering in test data is done alphabetically

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package com.github.mdr.ascii.layout.layering

import org.scalacheck.Arbitrary
import org.scalacheck.Gen
import org.scalacheck.Gen.Params
import org.scalacheck.Prop.forAll
import org.scalacheck.Properties
import org.scalacheck.Shrink

import com.github.mdr.ascii.graph.Graph
import com.github.mdr.ascii.graph.GraphGenerators._
import com.github.mdr.ascii.layout.cycles.CycleRemover

object LongestDistanceToSinkSpecification extends Properties("LongestDistanceToSink") {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.github.mdr.ascii.layout.layering

import org.scalatest.FlatSpec
import org.scalatest.{ Matchers, FlatSpec }
import org.scalatest.matchers.ShouldMatchers
import com.github.mdr.ascii.graph.Graph
import com.github.mdr.ascii.graph.GraphUtils
import com.github.mdr.ascii.util.Utils

class LongestDistanceToSinkTest extends FlatSpec with ShouldMatchers {
class LongestDistanceToSinkTest extends FlatSpec with Matchers {

distancesToSinks("""
+-+ +-+ +-+
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/com/github/mdr/ascii/util/QuadTreeTest.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.mdr.ascii.util

import org.scalatest.FlatSpec
import org.scalatest.{ Matchers, FlatSpec }
import org.scalatest.matchers.ShouldMatchers
import com.github.mdr.ascii.common._

class QuadTreeTest extends FlatSpec with ShouldMatchers {
class QuadTreeTest extends FlatSpec with Matchers {

"A QuadTree" should "work with one element" in {
val tree = new QuadTree[Region](Dimension(16, 16))
Expand Down