Skip to content

Commit

Permalink
Merge pull request #362 from NetLogo/redo-cross-referencing
Browse files Browse the repository at this point in the history
Redo cross-referencing
  • Loading branch information
mrerrormessage authored Jul 21, 2017
2 parents 10f1032 + 6787bea commit 5b1e02b
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ target/
/test/applet/NetLogo.jar
/test/applet/NetLogoLite.jar
/test/benchmarks/firebig*.csv
/index.txt
/index.conf
/Alternative Visualizations/Ethnocentrism - Alternative Visualization.png
/Alternative Visualizations/Flocking - Alternative Visualizations.png
/Alternative Visualizations/Heat Diffusion - Alternative Visualization.png
Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ libraryDependencies ++= Seq(
"com.github.wookietreiber" %% "scala-chart" % "0.5.1",
"com.googlecode.java-diff-utils" % "diffutils" % "1.2" % "test",
"org.jfree" % "jfreesvg" % "3.0",
"com.typesafe" % "config" % "1.3.1" % "test",
"com.vladsch.flexmark" % "flexmark" % "0.20.0" % "test",
"com.vladsch.flexmark" % "flexmark-ext-autolink" % "0.20.0" % "test",
"com.vladsch.flexmark" % "flexmark-util" % "0.20.0" % "test"
Expand Down
55 changes: 55 additions & 0 deletions crossReference.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
org.nlogo.models.crossReference.singleModels: [
{ source: "Sample Models/Biology/AIDS.nlogo", referenceIn: "Sample Models/Social Science" }
{ source: "Sample Models/Biology/Simple Birth Rates.nlogo", referenceIn: "Sample Models/Social Science" }

{ source: "Sample Models/Biology/Evolution/Altruism.nlogo", referenceIn: "Sample Models/Social Science" }
{ source: "Sample Models/Biology/Evolution/Cooperation.nlogo", referenceIn: "Sample Models/Social Science" }

{ source: "Sample Models/Biology/Evolution/Unverified/Divide The Cake.nlogo",
referenceIn: "Sample Models/Social Science/Unverified" }

{ source: "Sample Models/Biology/Evolution/Altruism.nlogo", referenceIn: "Curricular Models/EACH" }
{ source: "Sample Models/Biology/Evolution/Cooperation.nlogo", referenceIn: "Curricular Models/EACH" }

{ source: "Sample Models/Biology/Evolution/Unverified/Divide The Cake.nlogo",
referenceIn: "Curricular Models/EACH/Unverified" }

{ source: "Sample Models/Networks/Team Assembly.nlogo", referenceIn: "Sample Models/Social Science" }

{ source: "Code Examples/Extensions Examples/vid/Video Camera Example.nlogo", referenceIn: "Code Examples/Extension Examples/bitmap" }

// BEAGLE curricular models
{ source: "Sample Models/Biology/Wolf Sheep Predation.nlogo", referenceIn: "Curricular Models/BEAGLE Evolution" }
{ source: "Sample Models/Biology/Evolution/Genetic Drift/GenDrift T interact.nlogo", referenceIn: "Curricular Models/BEAGLE Evolution" }
{ source: "Sample Models/Biology/Evolution/Bug Hunt Speeds.nlogo", referenceIn: "Curricular Models/BEAGLE Evolution" }
{ source: "Sample Models/Biology/Evolution/Bug Hunt Camouflage.nlogo", referenceIn: "Curricular Models/BEAGLE Evolution" }
{ source: "HubNet Activities/Unverified/Guppy Spots HubNet.nlogo", referenceIn: "Curricular Models/BEAGLE Evolution" }
{ source: "Sample Models/Biology/Daisyworld.nlogo", referenceIn: "Curricular Models/BEAGLE Evolution" }
{ source: "Sample Models/Biology/Evolution/Mimicry.nlogo", referenceIn: "Curricular Models/BEAGLE Evolution" }
{ source: "Sample Models/Biology/Evolution/Altruism.nlogo", referenceIn: "Curricular Models/BEAGLE Evolution" }
{ source: "Sample Models/Biology/Evolution/Cooperation.nlogo", referenceIn: "Curricular Models/BEAGLE Evolution" }
{ source: "HubNet Activities/Bug Hunters Camouflage HubNet.nlogo", referenceIn: "Curricular Models/BEAGLE Evolution/HubNet Activities" }

// copy BEAGLE HubNet models to hubnet activities
{ source: "Curricular Models/BEAGLE Evolution/HubNet Activities/Bird Breeders HubNet.nlogo", referenceIn: "HubNet Activities" }
{ source: "Curricular Models/BEAGLE Evolution/HubNet Activities/Bug Hunters Competition HubNet.nlogo", referenceIn: "HubNet Activities" }
{ source: "Curricular Models/BEAGLE Evolution/HubNet Activities/Critter Designers HubNet.nlogo", referenceIn: "HubNet Activities" }
{ source: "Curricular Models/BEAGLE Evolution/HubNet Activities/Fish Spotters HubNet.nlogo", referenceIn: "HubNet Activities" }

// Oil Cartel HubNet to HubNet Activities
{ source: "Sample Models/Social Science/Oil Cartel HubNet.nlogo", referenceIn: "HubNet Activities" }

// IABM Textbook models duplicated in Sample Models and Code Examples
{ source: "IABM Textbook/chapter 3/El Farol Extensions/El Farol.nlogo", referenceIn: "Sample Models/Social Science" }
{ source: "IABM Textbook/chapter 3/DLA Extensions/DLA Simple.nlogo", referenceIn: "Sample Models/Chemistry & Physics/Diffusion Limited Aggregation" }
{ source: "IABM Textbook/chapter 8/Arduino Example.nlogo", referenceIn: "Code Examples/Extensions Examples/arduino" }
]

org.nlogo.models.crossReference.directories: [
{ sourceDir: "Sample Models/Mathematics/Probability/ProbLab", referenceIn: "Curricular Models/ProbLab", recursive: false }
{ sourceDir: "Sample Models/Mathematics/Probability/ProbLab/Unverified",
referenceIn: "Curricular Models/ProbLab", recursive: false }

{ sourceDir: "Sample Models/Chemistry & Physics/GasLab", referenceIn: "Curricular Models/GasLab", recursive: true }
{ sourceDir: "Sample Models/Chemistry & Physics/MaterialSim", referenceIn: "Curricular Models/MaterialSim", recursive: true }
]
45 changes: 45 additions & 0 deletions src/test/scala/org/nlogo/models/CrossReferenceTests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.nlogo.models

import java.io.File
import java.nio.file.{ Files, Paths }

import com.typesafe.config.{ Config, ConfigFactory }

import org.scalatest.FunSuite

import scala.collection.JavaConverters._

class CrossReferenceTests extends FunSuite {

val crossReference = ConfigFactory.parseFile(new File("crossReference.conf"))

test("all cross-referenced single models exist") {
val modelRefs = crossReference.getConfigList("org.nlogo.models.crossReference.singleModels").asScala
modelRefs.foreach { ref =>
val source = ref.getString("source")
val path = Paths.get(source)
val realPath = path.toRealPath()
val realSubpath =
realPath.subpath(realPath.getNameCount - path.getNameCount, realPath.getNameCount)
assert(
Files.exists(path) && Files.isRegularFile(path) &&
realSubpath.toString == path.toString,
s"expected to find a nlogo file at $source, but couldn't find it!")
}
}

test("all cross-referenced directories exist and are directories") {
val directoryRefs = crossReference.getConfigList("org.nlogo.models.crossReference.directories").asScala
directoryRefs.foreach { ref =>
val source = ref.getString("sourceDir")
val path = Paths.get(source)
val realPath = path.toRealPath()
val realSubpath =
realPath.subpath(realPath.getNameCount - path.getNameCount, realPath.getNameCount)
assert(
Files.exists(path) && Files.isDirectory(path) &&
realSubpath.toString == path.toString,
s"expected find a directory at $source, but couldn't find it!")
}
}
}

0 comments on commit 5b1e02b

Please sign in to comment.