Permalink
Browse files

Integrates sbt-org-policies plugin (#41)

  • Loading branch information...
juanpedromoreno committed Mar 28, 2017
1 parent f8179e8 commit a60700b178b250d20be3837d3279e67adb7d7006
Showing with 836 additions and 629 deletions.
  1. +23 −0 .scalafmt.conf
  2. +0 −3 .travis.yml
  3. +3 −4 README.md
  4. +18 −46 build.sbt
  5. +47 −0 project/ProjectPlugin.scala
  6. +1 −1 project/build.properties
  7. +2 −2 project/plugins.sbt
  8. +23 −17 src/main/scala/shapeless/ArityExercises.scala
  9. +103 −94 src/main/scala/shapeless/AutoTypeClassExercises.scala
  10. +33 −25 src/main/scala/shapeless/CoproductExercises.scala
  11. +34 −27 src/main/scala/shapeless/ExtensibleRecordsExercises.scala
  12. +59 −53 src/main/scala/shapeless/GenericExercises.scala
  13. +57 −51 src/main/scala/shapeless/HListExercises.scala
  14. +22 −17 src/main/scala/shapeless/HMapExercises.scala
  15. +72 −65 src/main/scala/shapeless/LazyExercises.scala
  16. +39 −36 src/main/scala/shapeless/LensesExercises.scala
  17. +29 −25 src/main/scala/shapeless/PolyExercises.scala
  18. +9 −4 src/main/scala/shapeless/ShapelessLib.scala
  19. +31 −25 src/main/scala/shapeless/SingletonExercises.scala
  20. +30 −26 src/main/scala/shapeless/SizedExercises.scala
  21. +63 −61 src/main/scala/shapeless/TuplesHListExercises.scala
  22. +29 −21 src/main/scala/shapeless/TypeCheckingExercises.scala
  23. +34 −23 src/main/scala/shapeless/TypeSafeCastExercises.scala
  24. +5 −0 src/test/scala/shapeless/AritySpec.scala
  25. +5 −0 src/test/scala/shapeless/AutoTypeClassSpec.scala
  26. +5 −0 src/test/scala/shapeless/CoproductSpec.scala
  27. +8 −1 src/test/scala/shapeless/ExtensibleRecordsSpec.scala
  28. +5 −0 src/test/scala/shapeless/GenericExercisesSpec.scala
  29. +5 −0 src/test/scala/shapeless/HListSpec.scala
  30. +5 −0 src/test/scala/shapeless/HMapExercisesSpec.scala
  31. +5 −0 src/test/scala/shapeless/LazyExercisesSpec.scala
  32. +5 −0 src/test/scala/shapeless/LensesExercisesSpec.scala
  33. +5 −0 src/test/scala/shapeless/PolySpec.scala
  34. +6 −1 src/test/scala/shapeless/SingletonExercisesSpec.scala
  35. +5 −0 src/test/scala/shapeless/SizedExercisesSpec.scala
  36. +5 −1 src/test/scala/shapeless/TuplesHListExercisesSpec.scala
  37. +5 −0 src/test/scala/shapeless/TypeCheckingExercisesSpec.scala
  38. +1 −0 version.sbt
@@ -0,0 +1,23 @@
style = defaultWithAlign
maxColumn = 100
continuationIndent.callSite = 2
newlines {
sometimesBeforeColonInMethodReturnType = false
}
align {
arrowEnumeratorGenerator = false
ifWhileOpenParen = false
openParenCallSite = false
openParenDefnSite = false
}
docstrings = JavaDoc
rewrite {
rules = [SortImports, RedundantBraces]
redundantBraces.maxLines = 1
}
@@ -15,6 +15,3 @@ after_success:
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
sbt compile publishSigned;
fi
- if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then
echo "Not in master branch, skipping deploy and release";
fi
@@ -1,10 +1,9 @@
#Scala Exercises - Shapeless
# Scala Exercises - Shapeless
------------------------
This repository hosts a content library for the [Scala Exercises](https://www.scala-exercises.org/) platform, including interactive exercises related to the [Shapeless](https://github.com/milessabin/shapeless) generic programming library.
## About Scala exercises
## About Scala exercises
"Scala Exercises" brings exercises for the Stdlib, Cats, Shapeless and many other great libraries for Scala to your browser. Offering hundreds of solvable exercises organized into several categories covering the basics of the Scala language and it's most important libraries.
@@ -15,7 +14,7 @@ Scala Exercises is available at [scala-exercises.org](https://scala-exercises.or
Contributions welcome! Please join our [Gitter channel](https://gitter.im/scala-exercises/scala-exercises)
to get involved, or visit our [GitHub site](https://github.com/scala-exercises).
##License
## License
Copyright (C) 2015-2016 47 Degrees, LLC.
Reactive, scalable software solutions.
@@ -1,51 +1,23 @@
val scalaExerciesV = "0.4.0-SNAPSHOT"
def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExerciesV
lazy val shapeless = (project in file("."))
.settings(publishSettings:_*)
.enablePlugins(ExerciseCompilerPlugin)
.settings(
organization := "org.scala-exercises",
name := "exercises-shapeless",
scalaVersion := "2.11.8",
version := "0.3.0-SNAPSHOT",
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases")
),
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % "0.7.2",
"com.chuusai" %% "shapeless" % "2.2.5",
"org.scalatest" %% "scalatest" % "2.2.4",
"org.scala-exercises" %% "exercise-compiler" % version.value,
"org.scala-exercises" %% "definitions" % version.value,
"org.scalacheck" %% "scalacheck" % "1.12.5",
"com.github.alexarchambault" %% "scalacheck-shapeless_1.12" % "0.3.1",
compilerPlugin("org.spire-math" %% "kind-projector" % "0.9.0")
.enablePlugins(ExerciseCompilerPlugin)
.settings(
name := "exercises-shapeless",
libraryDependencies ++= Seq(
dep("exercise-compiler"),
dep("definitions"),
%%("shapeless"),
%%("scalatest"),
%%("scalacheck"),
%%("scheckShapeless")
)
)
)
// Distribution
lazy val gpgFolder = sys.env.getOrElse("PGP_FOLDER", ".")
lazy val publishSettings = Seq(
organizationName := "Scala Exercises",
organizationHomepage := Some(new URL("http://scala-exercises.org")),
startYear := Some(2016),
description := "Scala Exercises: The path to enlightenment",
homepage := Some(url("http://scala-exercises.org")),
pgpPassphrase := Some(sys.env.getOrElse("PGP_PASSPHRASE", "").toCharArray),
pgpPublicRing := file(s"$gpgFolder/pubring.gpg"),
pgpSecretRing := file(s"$gpgFolder/secring.gpg"),
credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", sys.env.getOrElse("PUBLISH_USERNAME", ""), sys.env.getOrElse("PUBLISH_PASSWORD", "")),
scmInfo := Some(ScmInfo(url("https://github.com/scala-exercises/exercises-shapeless"), "https://github.com/scala-exercises/exercises-shapeless.git")),
licenses := Seq("Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := Function.const(false),
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("Snapshots" at nexus + "content/repositories/snapshots")
else
Some("Releases" at nexus + "service/local/staging/deploy/maven2")
}
)
pgpPassphrase := Some(getEnvVar("PGP_PASSPHRASE").getOrElse("").toCharArray)
pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
pgpSecretRing := file(s"$gpgFolder/secring.gpg")
@@ -0,0 +1,47 @@
import de.heikoseeberger.sbtheader.HeaderPattern
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._
import sbt.Keys._
import sbt._
import sbtorgpolicies._
import sbtorgpolicies.model._
import sbtorgpolicies.OrgPoliciesPlugin.autoImport._
object ProjectPlugin extends AutoPlugin {
override def trigger: PluginTrigger = allRequirements
override def requires: Plugins = plugins.JvmPlugin && OrgPoliciesPlugin
override def projectSettings: Seq[Def.Setting[_]] =
Seq(
description := "Scala Exercises: The path to enlightenment",
startYear := Option(2016),
orgGithubSetting := GitHubSettings(
organization = "scala-exercises",
project = name.value,
organizationName = "Scala Exercises",
groupId = "org.scala-exercises",
organizationHomePage = url("https://www.scala-exercises.org"),
organizationEmail = "hello@47deg.com"
),
orgLicenseSetting := ApacheLicense,
scalaVersion := "2.11.8",
scalaOrganization := "org.scala-lang",
crossScalaVersions := Seq("2.11.8"),
resolvers ++= Seq(
Resolver.mavenLocal,
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases")
),
scalacOptions := sbtorgpolicies.model.scalacCommonOptions,
headers := Map(
"scala" -> (HeaderPattern.cStyleBlockComment,
s"""|/*
| * scala-exercises - ${name.value}
| * Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
| */
|
|""".stripMargin)
)
)
}
@@ -1 +1 @@
sbt.version=0.13.12
sbt.version=0.13.13
@@ -2,5 +2,5 @@ resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots")
)
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.3.0-SNAPSHOT", "0.13", "2.10")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.4.0-SNAPSHOT", "0.13", "2.10")
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.3.2")
@@ -1,3 +1,8 @@
/*
* scala-exercises - exercises-shapeless
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/
package shapelessex
import org.scalatest._
@@ -7,31 +12,32 @@ import ops.function._
import syntax.std.function._
object Helper {
def applyProduct[P <: Product, F, L <: HList, R](p: P)(f: F)(implicit gen: Generic.Aux[P, L], fp: FnToProduct.Aux[F, L R]) =
def applyProduct[P <: Product, F, L <: HList, R](p: P)(
f: F)(implicit gen: Generic.Aux[P, L], fp: FnToProduct.Aux[F, L R]) =
f.toProduct(gen.to(p))
}
/** == Facilities for abstracting over arity ==
*
* Conversions between tuples and `HList`'s, and between ordinary Scala functions of arbitrary arity and functions which
* take a single corresponding `HList` argument allow higher order functions to abstract over the arity of the functions
* and values they are passed
* {{{
* import syntax.std.function._
* import ops.function._
*
* def applyProduct[P <: Product, F, L <: HList, R](p: P)(f: F)
* (implicit gen: Generic.Aux[P, L], fp: FnToProduct.Aux[F, L => R]) =
* f.toProduct(gen.to(p))
* }}}
*
* @param name arity
*/
*
* Conversions between tuples and `HList`'s, and between ordinary Scala functions of arbitrary arity and functions which
* take a single corresponding `HList` argument allow higher order functions to abstract over the arity of the functions
* and values they are passed
* {{{
* import syntax.std.function._
* import ops.function._
*
* def applyProduct[P <: Product, F, L <: HList, R](p: P)(f: F)
* (implicit gen: Generic.Aux[P, L], fp: FnToProduct.Aux[F, L => R]) =
* f.toProduct(gen.to(p))
* }}}
*
* @param name arity
*/
object ArityExercises extends FlatSpec with Matchers with org.scalaexercises.definitions.Section {
import Helper._
/** Abstracting over arity
*/
*/
def arityTest(res0: Int, res1: Int) = {
applyProduct(1, 2)((_: Int) + (_: Int)) should be(res0)
applyProduct(1, 2, 3)((_: Int) * (_: Int) * (_: Int)) should be(res1)
Oops, something went wrong.

0 comments on commit a60700b

Please sign in to comment.