Permalink
Browse files

Integrates sbt-org-policies plugin (#52)

  • Loading branch information...
juanpedromoreno committed Mar 28, 2017
1 parent 8ce7664 commit 64bbcc661ae49eea99b0f86e0fd7d194f8f6069f
Showing with 1,704 additions and 1,491 deletions.
  1. +23 −0 .scalafmt.conf
  2. +0 −3 .travis.yml
  3. +4 −5 README.md
  4. +20 −46 build.sbt
  5. +46 −0 project/ProjectPlugin.scala
  6. +1 −1 project/build.properties
  7. +2 −2 project/plugins.sbt
  8. +37 −30 src/main/scala/catslib/Applicative.scala
  9. +86 −75 src/main/scala/catslib/Apply.scala
  10. +9 −4 src/main/scala/catslib/ApplyHelpers.scala
  11. +9 −4 src/main/scala/catslib/CatsLibrary.scala
  12. +95 −88 src/main/scala/catslib/Foldable.scala
  13. +110 −104 src/main/scala/catslib/FunctorSection.scala
  14. +66 −62 src/main/scala/catslib/IdentitySection.scala
  15. +92 −86 src/main/scala/catslib/Monad.scala
  16. +5 −0 src/main/scala/catslib/MonadHelpers.scala
  17. +57 −51 src/main/scala/catslib/Monoid.scala
  18. +87 −63 src/main/scala/catslib/Semigroup.scala
  19. +225 −219 src/main/scala/catslib/Traverse.scala
  20. +6 −1 src/main/scala/catslib/TraverseHelpers.scala
  21. +305 −296 src/main/scala/catslib/Validated.scala
  22. +12 −6 src/main/scala/catslib/ValidatedHelpers.scala
  23. +347 −342 src/main/scala/catslib/XorSection.scala
  24. +5 −0 src/test/scala/catslib/ApplicativeSpec.scala
  25. +6 −1 src/test/scala/catslib/ApplySpec.scala
  26. +5 −0 src/test/scala/catslib/FoldableSpec.scala
  27. +5 −0 src/test/scala/catslib/FunctorSpec.scala
  28. +5 −0 src/test/scala/catslib/IdentitySpec.scala
  29. +5 −0 src/test/scala/catslib/MonadSpec.scala
  30. +6 −1 src/test/scala/catslib/MonoidSpec.scala
  31. +5 −0 src/test/scala/catslib/SemigroupSpec.scala
  32. +5 −0 src/test/scala/catslib/TraverseSpec.scala
  33. +5 −0 src/test/scala/catslib/ValidatedSpec.scala
  34. +7 −1 src/test/scala/catslib/XorSpec.scala
  35. +1 −0 version.sbt
View
@@ -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
}
View
@@ -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
View
@@ -1,21 +1,20 @@
#Scala Exercises - Cats library
# Scala Exercises - Cats library
------------------------
This repository hosts a content library for the [Scala Exercises](https://www.scala-exercises.org/) platform, that includes interactive exercises related to the [Cats library](https://github.com/typelevel/cats) by Typelevel.
##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 its most important libraries.
Scala Exercises is available at [scala-exercises.org](https://scala-exercises.org).
##Contributing
## Contributing
Contributions are 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.
View
@@ -1,51 +1,25 @@
val scalaExerciesV = "0.4.0-SNAPSHOT"
def dep(artifactId: String) =
"org.scala-exercises" %% artifactId % scalaExerciesV excludeAll ExclusionRule("org.typelevel")
lazy val cats = (project in file("."))
.settings(publishSettings:_*)
.enablePlugins(ExerciseCompilerPlugin)
.settings(
organization := "org.scala-exercises",
name := "exercises-cats",
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-cats",
libraryDependencies ++= Seq(
dep("exercise-compiler"),
dep("definitions"),
%%("cats-core", "0.7.2"),
%%("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-cats"), "https://github.com/scala-exercises/exercises-cats.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,46 @@
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")
),
headers := Map(
"scala" -> (HeaderPattern.cStyleBlockComment,
s"""|/*
| * scala-exercises - ${name.value}
| * Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
| */
|
|""".stripMargin)
)
)
}
View
@@ -1 +1 @@
sbt.version=0.13.12
sbt.version=0.13.13
View
@@ -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-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/
package catslib
import org.scalatest._
@@ -6,23 +11,26 @@ import cats._
import cats.implicits._
/** `Applicative` extends `Apply` by adding a single method, `pure`:
*
* {{{
* def pure[A](x: A): F[A]
* }}}
*
*
* @param name applicative
*/
object ApplicativeSection extends FlatSpec with Matchers with org.scalaexercises.definitions.Section {
*
* {{{
* def pure[A](x: A): F[A]
* }}}
*
*
* @param name applicative
*/
object ApplicativeSection
extends FlatSpec
with Matchers
with org.scalaexercises.definitions.Section {
/** This method takes any value and returns the value in the context of
* the functor. For many familiar functors, how to do this is
* obvious. For `Option`, the `pure` operation wraps the value in
* `Some`. For `List`, the `pure` operation returns a single element
* `List`:
*
*/
* the functor. For many familiar functors, how to do this is
* obvious. For `Option`, the `pure` operation wraps the value in
* `Some`. For `List`, the `pure` operation returns a single element
* `List`:
*
*/
def pureMethod(res0: Option[Int], res1: List[Int]) = {
import cats._
import cats.implicits._
@@ -32,24 +40,23 @@ object ApplicativeSection extends FlatSpec with Matchers with org.scalaexercises
}
/** Like `Functor` and `Apply`, `Applicative`
* functors also compose naturally with each other. When
* you compose one `Applicative` with another, the resulting `pure`
* operation will lift the passed value into one context, and the result
* into the other context:
*/
def applicativeComposition(res0: List[Option[Int]]) = {
* functors also compose naturally with each other. When
* you compose one `Applicative` with another, the resulting `pure`
* operation will lift the passed value into one context, and the result
* into the other context:
*/
def applicativeComposition(res0: List[Option[Int]]) =
(Applicative[List] compose Applicative[Option]).pure(1) should be(res0)
}
/** = Applicative Functors & Monads =
*
* `Applicative` is a generalization of `Monad`, allowing expression
* of effectful computations in a pure functional way.
*
* `Applicative` is generally preferred to `Monad` when the structure of a
* computation is fixed a priori. That makes it possible to perform certain
* kinds of static analysis on applicative values.
*/
*
* `Applicative` is a generalization of `Monad`, allowing expression
* of effectful computations in a pure functional way.
*
* `Applicative` is generally preferred to `Monad` when the structure of a
* computation is fixed a priori. That makes it possible to perform certain
* kinds of static analysis on applicative values.
*/
def applicativesAndMonads(res0: Option[Int], res1: Option[Int]) = {
Monad[Option].pure(1) should be(res0)
Applicative[Option].pure(1) should be(res1)
Oops, something went wrong.

0 comments on commit 64bbcc6

Please sign in to comment.