Skip to content

Commit d555692

Browse files
Integrates sbt-org-policies plugin
1 parent a70967a commit d555692

File tree

85 files changed

+1753
-1150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1753
-1150
lines changed

.scalafmt.conf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
style = defaultWithAlign
2+
maxColumn = 100
3+
4+
continuationIndent.callSite = 2
5+
6+
newlines {
7+
sometimesBeforeColonInMethodReturnType = false
8+
}
9+
10+
align {
11+
arrowEnumeratorGenerator = false
12+
ifWhileOpenParen = false
13+
openParenCallSite = false
14+
openParenDefnSite = false
15+
}
16+
17+
docstrings = JavaDoc
18+
19+
rewrite {
20+
rules = [SortImports, RedundantBraces]
21+
redundantBraces.maxLines = 1
22+
}
23+

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,3 @@ after_success:
1515
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
1616
sbt compile publishSigned;
1717
fi
18-
- if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then
19-
echo "Not in master branch, skipping deploy and release";
20-
fi

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
#Scala Exercises - Stdlib library
2-
1+
# Scala Exercises - Stdlib library
32
------------------------
43

54
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.
65

7-
## About Scala exercises
6+
## About Scala exercises
87

98
"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.
109

@@ -15,7 +14,7 @@ Scala Exercises is available at [scala-exercises.org](https://scala-exercises.or
1514
Contributions welcome! Please join our [Gitter channel](https://gitter.im/scala-exercises/scala-exercises)
1615
to get involved, or visit our [GitHub site](https://github.com/scala-exercises).
1716

18-
##License
17+
## License
1918

2019
Copyright (C) 2015-2016 47 Degrees, LLC.
2120
Reactive, scalable software solutions.

build.sbt

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,23 @@
1+
val scalaExerciesV = "0.4.0-SNAPSHOT"
2+
3+
def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExerciesV
4+
15
lazy val stdlib = (project in file("."))
2-
.settings(publishSettings:_*)
36
.enablePlugins(ExerciseCompilerPlugin)
47
.settings(
5-
organization := "org.scala-exercises",
68
name := "exercises-stdlib",
7-
scalaVersion := "2.11.8",
8-
version := "0.3.0-SNAPSHOT",
9-
resolvers ++= Seq(
10-
Resolver.sonatypeRepo("snapshots"),
11-
Resolver.sonatypeRepo("releases")
12-
),
139
libraryDependencies ++= Seq(
14-
"com.chuusai" %% "shapeless" % "2.2.5",
15-
"org.scalatest" %% "scalatest" % "2.2.4",
16-
"org.scala-exercises" %% "exercise-compiler" % version.value,
17-
"org.scala-exercises" %% "definitions" % version.value,
18-
"org.scalacheck" %% "scalacheck" % "1.12.5",
19-
"com.github.alexarchambault" %% "scalacheck-shapeless_1.12" % "0.3.1"
20-
),
21-
licenses := Seq("Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
10+
dep("exercise-compiler"),
11+
dep("definitions"),
12+
%%("shapeless"),
13+
%%("scalatest"),
14+
%%("scalacheck"),
15+
%%("scheckShapeless")
16+
)
2217
)
2318

24-
2519
// Distribution
2620

27-
lazy val gpgFolder = sys.env.getOrElse("PGP_FOLDER", ".")
28-
29-
lazy val publishSettings = Seq(
30-
organizationName := "Scala Exercises",
31-
organizationHomepage := Some(new URL("http://scala-exercises.org")),
32-
startYear := Some(2016),
33-
description := "Scala Exercises: The path to enlightenment",
34-
homepage := Some(url("http://scala-exercises.org")),
35-
pgpPassphrase := Some(sys.env.getOrElse("PGP_PASSPHRASE", "").toCharArray),
36-
pgpPublicRing := file(s"$gpgFolder/pubring.gpg"),
37-
pgpSecretRing := file(s"$gpgFolder/secring.gpg"),
38-
credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", sys.env.getOrElse("PUBLISH_USERNAME", ""), sys.env.getOrElse("PUBLISH_PASSWORD", "")),
39-
scmInfo := Some(ScmInfo(url("https://github.com/scala-exercises/exercises-stdlib"), "https://github.com/scala-exercises/exercises-stdlib.git")),
40-
licenses := Seq("Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
41-
publishMavenStyle := true,
42-
publishArtifact in Test := false,
43-
pomIncludeRepository := Function.const(false),
44-
publishTo := {
45-
val nexus = "https://oss.sonatype.org/"
46-
if (isSnapshot.value)
47-
Some("Snapshots" at nexus + "content/repositories/snapshots")
48-
else
49-
Some("Releases" at nexus + "service/local/staging/deploy/maven2")
50-
}
51-
)
21+
pgpPassphrase := Some(getEnvVar("PGP_PASSPHRASE").getOrElse("").toCharArray)
22+
pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
23+
pgpSecretRing := file(s"$gpgFolder/secring.gpg")

project/ProjectPlugin.scala

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import de.heikoseeberger.sbtheader.HeaderPattern
2+
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._
3+
import sbt.Keys._
4+
import sbt._
5+
import sbtorgpolicies._
6+
import sbtorgpolicies.model._
7+
import sbtorgpolicies.OrgPoliciesPlugin.autoImport._
8+
9+
object ProjectPlugin extends AutoPlugin {
10+
11+
override def trigger: PluginTrigger = allRequirements
12+
13+
override def requires: Plugins = plugins.JvmPlugin && OrgPoliciesPlugin
14+
15+
override def projectSettings: Seq[Def.Setting[_]] =
16+
Seq(
17+
description := "Scala Exercises: The path to enlightenment",
18+
startYear := Option(2016),
19+
orgGithubSetting := GitHubSettings(
20+
organization = "scala-exercises",
21+
project = name.value,
22+
organizationName = "Scala Exercises",
23+
groupId = "org.scala-exercises",
24+
organizationHomePage = url("https://www.scala-exercises.org"),
25+
organizationEmail = "[email protected]"
26+
),
27+
orgLicenseSetting := ApacheLicense,
28+
scalaVersion := "2.11.8",
29+
scalaOrganization := "org.scala-lang",
30+
crossScalaVersions := Seq("2.11.8"),
31+
resolvers ++= Seq(
32+
Resolver.mavenLocal,
33+
Resolver.sonatypeRepo("snapshots"),
34+
Resolver.sonatypeRepo("releases")
35+
),
36+
scalacOptions := sbtorgpolicies.model.scalacCommonOptions,
37+
headers := Map(
38+
"scala" -> (HeaderPattern.cStyleBlockComment,
39+
s"""|/*
40+
| * scala-exercises - ${name.value}
41+
| * Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
42+
| */
43+
|
44+
|""".stripMargin)
45+
)
46+
)
47+
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.12
1+
sbt.version=0.13.13

project/plugins.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ resolvers ++= Seq(
22
Resolver.sonatypeRepo("snapshots")
33
)
44

5-
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.3.0-SNAPSHOT", "0.13", "2.10")
6-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
5+
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.4.0-SNAPSHOT", "0.13", "2.10")
6+
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.3.2")

src/main/scala/stdlib/Asserts.scala

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,54 @@
1+
/*
2+
* scala-exercises - exercises-stdlib
3+
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
4+
*/
5+
16
package stdlib
27

38
import org.scalatest._
49

510
/** @param name asserts
6-
*/
11+
*/
712
object Asserts extends FlatSpec with Matchers with org.scalaexercises.definitions.Section {
813

914
/** ScalaTest makes three assertions available by default in any style trait. You can use:
10-
*
11-
* - `assert` for general assertions;
12-
* - `assertResult` to differentiate expected from actual values;
13-
* - `intercept` to ensure a bit of code throws an expected exception.
14-
*
15-
* In any Scala program, you can write assertions by invoking `assert` and passing in a `Boolean` expression:
16-
*
17-
* {{{
18-
* val left = 2
19-
* val right = 1
20-
* assert(left == right)
21-
* }}}
22-
*
23-
* If the passed expression is `true`, `assert` will return normally. If `false`,
24-
* Scala's `assert` will complete abruptly with an `AssertionError`. This behavior is provided by
25-
* the `assert` method defined in object `Predef`, whose members are implicitly imported into every Scala source file.
26-
*
27-
*
28-
* ScalaTest provides a domain specific language (DSL) for expressing assertions in tests
29-
* using the word `should`. ScalaTest matchers provides five different ways to check equality, each designed to address a different need. They are:
30-
*
31-
* {{{
32-
* result should equal (3) // can customize equality
33-
* result should === (3) // can customize equality and enforce type constraints
34-
* result should be (3) // cannot customize equality, so fastest to compile
35-
* result shouldEqual 3 // can customize equality, no parentheses required
36-
* result shouldBe 3 // cannot customize equality, so fastest to compile, no parentheses required
37-
* }}}
38-
*
39-
* Come on, your turn: true and false values can be compared with should matchers:
40-
*/
15+
*
16+
* - `assert` for general assertions;
17+
* - `assertResult` to differentiate expected from actual values;
18+
* - `intercept` to ensure a bit of code throws an expected exception.
19+
*
20+
* In any Scala program, you can write assertions by invoking `assert` and passing in a `Boolean` expression:
21+
*
22+
* {{{
23+
* val left = 2
24+
* val right = 1
25+
* assert(left == right)
26+
* }}}
27+
*
28+
* If the passed expression is `true`, `assert` will return normally. If `false`,
29+
* Scala's `assert` will complete abruptly with an `AssertionError`. This behavior is provided by
30+
* the `assert` method defined in object `Predef`, whose members are implicitly imported into every Scala source file.
31+
*
32+
*
33+
* ScalaTest provides a domain specific language (DSL) for expressing assertions in tests
34+
* using the word `should`. ScalaTest matchers provides five different ways to check equality, each designed to address a different need. They are:
35+
*
36+
* {{{
37+
* result should equal (3) // can customize equality
38+
* result should === (3) // can customize equality and enforce type constraints
39+
* result should be (3) // cannot customize equality, so fastest to compile
40+
* result shouldEqual 3 // can customize equality, no parentheses required
41+
* result shouldBe 3 // cannot customize equality, so fastest to compile, no parentheses required
42+
* }}}
43+
*
44+
* Come on, your turn: true and false values can be compared with should matchers:
45+
*/
4146
def scalaTestAsserts(res0: Boolean) {
4247
true should be(res0)
4348
}
4449

4550
/** Booleans in asserts can test equality:
46-
*/
51+
*/
4752
def booleanAsserts(res0: Int) {
4853
val v1 = 4
4954
v1 shouldEqual res0
@@ -52,7 +57,7 @@ object Asserts extends FlatSpec with Matchers with org.scalaexercises.definition
5257
}
5358

5459
/** Sometimes we expect you to fill in the values:
55-
*/
60+
*/
5661
def valuesAsserts(res0: Int) {
5762
assert(res0 == 1 + 1)
5863
}

src/main/scala/stdlib/ByNameParameter.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
/*
2+
* scala-exercises - exercises-stdlib
3+
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
4+
*/
5+
16
package stdlib
27

38
import org.scalatest._
49

510
/** @param name byname_parameter
6-
*/
11+
*/
712
object ByNameParameter extends FlatSpec with Matchers with org.scalaexercises.definitions.Section {
813

914
/** `() => 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:
10-
*/
15+
*/
1116
def takesUnitByNameParameter(res0: Either[Throwable, Int]) {
1217
def calc(x: () Int): Either[Throwable, Int] = {
1318
try {
@@ -25,7 +30,7 @@ object ByNameParameter extends FlatSpec with Matchers with org.scalaexercises.de
2530
}
2631

2732
/** 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:
28-
*/
33+
*/
2934
def byNameParameter(res0: Either[Throwable, Int]) {
3035
def calc(x: Int): Either[Throwable, Int] = {
3136
//x is a call by name parameter
@@ -47,7 +52,7 @@ object ByNameParameter extends FlatSpec with Matchers with org.scalaexercises.de
4752
}
4853

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

0 commit comments

Comments
 (0)