Skip to content

Commit

Permalink
Integrates sbt-org-policies plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpedromoreno committed Mar 28, 2017
1 parent a70967a commit d555692
Show file tree
Hide file tree
Showing 85 changed files with 1,753 additions and 1,150 deletions.
23 changes: 23 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -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
}

3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#Scala Exercises - Stdlib library

# Scala Exercises - Stdlib library
------------------------

This repository hosts a content library for the [Scala Exercises](https://www.scala-exercises.org/) platform, including interactive exercises related to the Scala standard 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.

Expand All @@ -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.
Expand Down
56 changes: 14 additions & 42 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,51 +1,23 @@
val scalaExerciesV = "0.4.0-SNAPSHOT"

def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExerciesV

lazy val stdlib = (project in file("."))
.settings(publishSettings:_*)
.enablePlugins(ExerciseCompilerPlugin)
.settings(
organization := "org.scala-exercises",
name := "exercises-stdlib",
scalaVersion := "2.11.8",
version := "0.3.0-SNAPSHOT",
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases")
),
libraryDependencies ++= Seq(
"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"
),
licenses := Seq("Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
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-stdlib"), "https://github.com/scala-exercises/exercises-stdlib.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")
47 changes: 47 additions & 0 deletions project/ProjectPlugin.scala
Original file line number Diff line number Diff line change
@@ -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)
)
)
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.12
sbt.version=0.13.13
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
73 changes: 39 additions & 34 deletions src/main/scala/stdlib/Asserts.scala
Original file line number Diff line number Diff line change
@@ -1,49 +1,54 @@
/*
* scala-exercises - exercises-stdlib
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/

package stdlib

import org.scalatest._

/** @param name asserts
*/
*/
object Asserts extends FlatSpec with Matchers with org.scalaexercises.definitions.Section {

/** ScalaTest makes three assertions available by default in any style trait. You can use:
*
* - `assert` for general assertions;
* - `assertResult` to differentiate expected from actual values;
* - `intercept` to ensure a bit of code throws an expected exception.
*
* In any Scala program, you can write assertions by invoking `assert` and passing in a `Boolean` expression:
*
* {{{
* val left = 2
* val right = 1
* assert(left == right)
* }}}
*
* If the passed expression is `true`, `assert` will return normally. If `false`,
* Scala's `assert` will complete abruptly with an `AssertionError`. This behavior is provided by
* the `assert` method defined in object `Predef`, whose members are implicitly imported into every Scala source file.
*
*
* ScalaTest provides a domain specific language (DSL) for expressing assertions in tests
* using the word `should`. ScalaTest matchers provides five different ways to check equality, each designed to address a different need. They are:
*
* {{{
* result should equal (3) // can customize equality
* result should === (3) // can customize equality and enforce type constraints
* result should be (3) // cannot customize equality, so fastest to compile
* result shouldEqual 3 // can customize equality, no parentheses required
* result shouldBe 3 // cannot customize equality, so fastest to compile, no parentheses required
* }}}
*
* Come on, your turn: true and false values can be compared with should matchers:
*/
*
* - `assert` for general assertions;
* - `assertResult` to differentiate expected from actual values;
* - `intercept` to ensure a bit of code throws an expected exception.
*
* In any Scala program, you can write assertions by invoking `assert` and passing in a `Boolean` expression:
*
* {{{
* val left = 2
* val right = 1
* assert(left == right)
* }}}
*
* If the passed expression is `true`, `assert` will return normally. If `false`,
* Scala's `assert` will complete abruptly with an `AssertionError`. This behavior is provided by
* the `assert` method defined in object `Predef`, whose members are implicitly imported into every Scala source file.
*
*
* ScalaTest provides a domain specific language (DSL) for expressing assertions in tests
* using the word `should`. ScalaTest matchers provides five different ways to check equality, each designed to address a different need. They are:
*
* {{{
* result should equal (3) // can customize equality
* result should === (3) // can customize equality and enforce type constraints
* result should be (3) // cannot customize equality, so fastest to compile
* result shouldEqual 3 // can customize equality, no parentheses required
* result shouldBe 3 // cannot customize equality, so fastest to compile, no parentheses required
* }}}
*
* Come on, your turn: true and false values can be compared with should matchers:
*/
def scalaTestAsserts(res0: Boolean) {
true should be(res0)
}

/** Booleans in asserts can test equality:
*/
*/
def booleanAsserts(res0: Int) {
val v1 = 4
v1 shouldEqual res0
Expand All @@ -52,7 +57,7 @@ object Asserts extends FlatSpec with Matchers with org.scalaexercises.definition
}

/** Sometimes we expect you to fill in the values:
*/
*/
def valuesAsserts(res0: Int) {
assert(res0 == 1 + 1)
}
Expand Down
13 changes: 9 additions & 4 deletions src/main/scala/stdlib/ByNameParameter.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
/*
* scala-exercises - exercises-stdlib
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/

package stdlib

import org.scalatest._

/** @param name byname_parameter
*/
*/
object ByNameParameter extends FlatSpec with Matchers with org.scalaexercises.definitions.Section {

/** `() => Int` is a Function type that takes a `Unit` type. `Unit` is known as `void` to a Java programmer. The function returns an `Int`. You can place this as a method parameter so that you can you use it as a block, but still it doesn't look quite right:
*/
*/
def takesUnitByNameParameter(res0: Either[Throwable, Int]) {
def calc(x: () Int): Either[Throwable, Int] = {
try {
Expand All @@ -25,7 +30,7 @@ object ByNameParameter extends FlatSpec with Matchers with org.scalaexercises.de
}

/** A by-name parameter does the same thing as the previous koan but there is no need to explicitly handle `Unit` or `()`. This is used extensively in Scala to create blocks:
*/
*/
def byNameParameter(res0: Either[Throwable, Int]) {
def calc(x: Int): Either[Throwable, Int] = {
//x is a call by name parameter
Expand All @@ -47,7 +52,7 @@ object ByNameParameter extends FlatSpec with Matchers with org.scalaexercises.de
}

/** By name parameters can also be used with `object` and `apply` to make interesting block-like calls:
*/
*/
def withApplyByNameParameter(res0: String) {
object PigLatinizer {
def apply(x: String) = x.tail + x.head + "ay"
Expand Down
Loading

0 comments on commit d555692

Please sign in to comment.