Permalink
Browse files

Integrates sbt-org-policies plugin (#9)

  • Loading branch information...
juanpedromoreno committed Mar 28, 2017
1 parent 0b774fa commit 59fc5ca665c3cf07d4847b228a97d70d196a7f13
Showing with 3,978 additions and 3,757 deletions.
  1. +23 −0 .scalafmt.conf
  2. +3 −4 README.md
  3. +17 −44 build.sbt
  4. +47 −0 project/ProjectPlugin.scala
  5. +1 −1 project/build.properties
  6. +6 −3 project/plugins.sbt
  7. +11 −6 src/main/scala/scalatutorial/ScalaTutorial.scala
  8. +9 −5 src/main/scala/scalatutorial/aux/BankAccount.scala
  9. +8 −3 src/main/scala/scalatutorial/aux/IntSet.scala
  10. +5 −0 src/main/scala/scalatutorial/aux/Note.scala
  11. +6 −1 src/main/scala/scalatutorial/aux/Rational.scala
  12. +5 −0 src/main/scala/scalatutorial/aux/animals.scala
  13. +7 −2 src/main/scala/scalatutorial/aux/sorting.scala
  14. +154 −148 src/main/scala/scalatutorial/sections/ClassesVsCaseClasses.scala
  15. +196 −191 src/main/scala/scalatutorial/sections/DefinitionsAndEvaluation.scala
  16. +132 −127 src/main/scala/scalatutorial/sections/FunctionalLoops.scala
  17. +146 −141 src/main/scala/scalatutorial/sections/HigherOrderFunctions.scala
  18. +325 −320 src/main/scala/scalatutorial/sections/ImperativeProgramming.scala
  19. +210 −204 src/main/scala/scalatutorial/sections/LazyEvaluation.scala
  20. +270 −265 src/main/scala/scalatutorial/sections/LexicalScopes.scala
  21. +632 −627 src/main/scala/scalatutorial/sections/ObjectOrientedProgramming.scala
  22. +427 −422 src/main/scala/scalatutorial/sections/PolymorphicTypes.scala
  23. +5 −0 src/main/scala/scalatutorial/sections/ScalaTutorialSection.scala
  24. +245 −240 src/main/scala/scalatutorial/sections/StandardLibrary.scala
  25. +209 −204 src/main/scala/scalatutorial/sections/StructuringInformation.scala
  26. +292 −287 src/main/scala/scalatutorial/sections/SyntacticConveniences.scala
  27. +118 −113 src/main/scala/scalatutorial/sections/TailRecursion.scala
  28. +163 −159 src/main/scala/scalatutorial/sections/TermsAndTypes.scala
  29. +183 −177 src/main/scala/scalatutorial/sections/TypeClasses.scala
  30. +7 −4 src/test/scala/scalatutorial/sections/ClassesVsCaseClassesSpec.scala
  31. +8 −6 src/test/scala/scalatutorial/sections/DefinitionsAndEvaluationSpec.scala
  32. +5 −0 src/test/scala/scalatutorial/sections/FunctionalLoopsSpec.scala
  33. +5 −0 src/test/scala/scalatutorial/sections/HigherOrderFunctionsSpec.scala
  34. +6 −2 src/test/scala/scalatutorial/sections/ImperativeProgrammingSpec.scala
  35. +7 −4 src/test/scala/scalatutorial/sections/LazyEvaluationSpec.scala
  36. +7 −4 src/test/scala/scalatutorial/sections/LexicalScopesSpec.scala
  37. +7 −5 src/test/scala/scalatutorial/sections/ObjectOrientedProgrammingSpec.scala
  38. +6 −2 src/test/scala/scalatutorial/sections/PolymorphicTypesSpec.scala
  39. +17 −6 src/test/scala/scalatutorial/sections/StandardLibrarySpec.scala
  40. +8 −6 src/test/scala/scalatutorial/sections/StructuringInformationSpec.scala
  41. +21 −18 src/test/scala/scalatutorial/sections/SyntacticConveniencesSpec.scala
  42. +5 −0 src/test/scala/scalatutorial/sections/TailRecursionSpec.scala
  43. +8 −6 src/test/scala/scalatutorial/sections/TermsAndTypesSpec.scala
  44. +5 −0 src/test/scala/scalatutorial/sections/TypeClassesSpec.scala
  45. +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
}
@@ -1,5 +1,4 @@
#Scala Exercises - Functional Programming Principles library
# Scala Exercises - Functional Programming Principles library
------------------------
This repository hosts a library for the first course of the [Scala MOOC](https://www.coursera.org/specializations/scala) ("Functional Programming Principles in Scala").
@@ -43,7 +42,7 @@ evaluator.secretKey="secretKey"
sbt -mem 1500 run
~~~
## 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.
@@ -54,7 +53,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,49 +1,22 @@
val scalaExerciesV = "0.4.0-SNAPSHOT"
def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExerciesV
lazy val `scala-tutorial` = (project in file("."))
.enablePlugins(ExerciseCompilerPlugin)
.settings(publishSettings:_*)
.settings(
organization := "org.scala-exercises",
name := "exercises-scalatutorial",
scalaVersion := "2.11.8",
version := "0.3.0-SNAPSHOT",
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases")
),
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "2.2.4",
"org.scala-exercises" %% "exercise-compiler" % "0.3.0-SNAPSHOT",
"org.scala-exercises" %% "definitions" % "0.3.0-SNAPSHOT",
"org.scalacheck" %% "scalacheck" % "1.12.5",
"com.github.alexarchambault" %% "scalacheck-shapeless_1.12" % "0.3.1",
compilerPlugin("org.spire-math" %% "kind-projector" % "0.7.1")
)
.enablePlugins(ExerciseCompilerPlugin)
.settings(
name := "exercises-scalatutorial",
libraryDependencies ++= Seq(
dep("exercise-compiler"),
dep("definitions"),
%%("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-scalatutorial"), "https://github.com/scala-exercises/exercises-scalatutorial.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.8
sbt.version=0.13.13
@@ -1,3 +1,6 @@
resolvers += 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")
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots")
)
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.4.0-SNAPSHOT", "0.13", "2.10")
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.3.2")
@@ -1,18 +1,23 @@
/*
* scala-exercises - exercises-scalatutorial
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/
package scalatutorial
import org.scalaexercises.definitions.Library
import sections._
/** Quickly learn Scala through an interactive tutorial based on the first two courses of the Scala MOOCs.
*
* @param name scala_tutorial
*/
*
* @param name scala_tutorial
*/
object ScalaTutorial extends Library {
val owner = "scala-exercises"
val repository = "exercises-scalatutorial"
val owner = "scala-exercises"
val repository = "exercises-scalatutorial"
override val color = Some("#f26527")
val logoPath = "scala-tutorial"
val logoPath = "scala-tutorial"
val sections = List(
TermsAndTypes,
@@ -1,16 +1,20 @@
/*
* scala-exercises - exercises-scalatutorial
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/
package scalatutorial.aux
class BankAccount {
private var balance = 0
def deposit(amount: Int): Unit = {
def deposit(amount: Int): Unit =
if (amount > 0) balance = balance + amount
}
def withdraw(amount: Int): Int =
if (0 < amount && amount <= balance) {
balance = balance - amount
balance
balance = balance - amount
balance
} else throw new Error("insufficient funds")
}
}
@@ -1,3 +1,8 @@
/*
* scala-exercises - exercises-scalatutorial
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/
package scalatutorial.aux
abstract class IntSet {
@@ -7,17 +12,17 @@ abstract class IntSet {
object Empty extends IntSet {
def contains(x: Int): Boolean = false
def incl(x: Int): IntSet = new NonEmpty(x, Empty, Empty)
def incl(x: Int): IntSet = new NonEmpty(x, Empty, Empty)
}
class NonEmpty(elem: Int, left: IntSet, right: IntSet) extends IntSet {
def contains(x: Int): Boolean =
if (x < elem) left contains x
else if (x > elem) right contains x
else if (x > elem) right contains x
else true
def incl(x: Int): IntSet =
if (x < elem) new NonEmpty(elem, left incl x, right)
else if (x > elem) new NonEmpty(elem, left, right incl x)
else this
}
}
@@ -1,3 +1,8 @@
/*
* scala-exercises - exercises-scalatutorial
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/
package scalatutorial.aux
case class Note(name: String, duration: String, octave: Int)
@@ -1,9 +1,14 @@
/*
* scala-exercises - exercises-scalatutorial
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/
package scalatutorial.aux
class Rational(x: Int, y: Int) {
private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
private val g = gcd(x, y)
private val g = gcd(x, y)
lazy val numer: Int = x / g
lazy val denom: Int = y / g
@@ -1,3 +1,8 @@
/*
* scala-exercises - exercises-scalatutorial
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/
package scalatutorial.aux
trait Animal {
@@ -1,3 +1,8 @@
/*
* scala-exercises - exercises-scalatutorial
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/
package scalatutorial.aux
object Sorting {
@@ -12,9 +17,9 @@ object Sorting {
}
xs match {
case List() => List()
case List() => List()
case y :: ys => insert(y, insertionSort(ys))
}
}
}
}
Oops, something went wrong.

0 comments on commit 59fc5ca

Please sign in to comment.