Permalink
Browse files

Integrates sbt-org-policies plugin (#81)

  • Loading branch information...
juanpedromoreno committed Mar 28, 2017
1 parent a70967a commit a8132f7d9b15ea733aa6073a0417b64789d584de
Showing with 1,753 additions and 1,150 deletions.
  1. +23 −0 .scalafmt.conf
  2. +0 −3 .travis.yml
  3. +3 −4 README.md
  4. +14 −42 build.sbt
  5. +47 −0 project/ProjectPlugin.scala
  6. +1 −1 project/build.properties
  7. +2 −2 project/plugins.sbt
  8. +39 −34 src/main/scala/stdlib/Asserts.scala
  9. +9 −4 src/main/scala/stdlib/ByNameParameter.scala
  10. +109 −91 src/main/scala/stdlib/CaseClasses.scala
  11. +33 −28 src/main/scala/stdlib/Classes.scala
  12. +40 −35 src/main/scala/stdlib/EmptyValues.scala
  13. +66 −37 src/main/scala/stdlib/Enumerations.scala
  14. +64 −57 src/main/scala/stdlib/Extractors.scala
  15. +10 −5 src/main/scala/stdlib/ForExpressions.scala
  16. +12 −7 src/main/scala/stdlib/Formatting.scala
  17. +52 −35 src/main/scala/stdlib/HigherOrderFunctions.scala
  18. +71 −56 src/main/scala/stdlib/Implicits.scala
  19. +24 −16 src/main/scala/stdlib/InfixPrefixandPostfixOperators.scala
  20. +19 −16 src/main/scala/stdlib/InfixTypes.scala
  21. +82 −40 src/main/scala/stdlib/Iterables.scala
  22. +44 −23 src/main/scala/stdlib/Lists.scala
  23. +15 −4 src/main/scala/stdlib/LiteralBooleans.scala
  24. +38 −10 src/main/scala/stdlib/LiteralNumbers.scala
  25. +22 −17 src/main/scala/stdlib/LiteralStrings.scala
  26. +52 −38 src/main/scala/stdlib/Maps.scala
  27. +77 −69 src/main/scala/stdlib/NamedandDefaultArguments.scala
  28. +15 −13 src/main/scala/stdlib/NamedandDefaultArgumentsHelper.scala
  29. +11 −6 src/main/scala/stdlib/Objects.scala
  30. +34 −29 src/main/scala/stdlib/Options.scala
  31. +6 −2 src/main/scala/stdlib/OptionsHelper.scala
  32. +30 −25 src/main/scala/stdlib/ParentClasses.scala
  33. +23 −14 src/main/scala/stdlib/PartialFunctions.scala
  34. +25 −13 src/main/scala/stdlib/PartiallyAppliedFunctions.scala
  35. +46 −39 src/main/scala/stdlib/PatternMatching.scala
  36. +24 −19 src/main/scala/stdlib/Ranges.scala
  37. +32 −19 src/main/scala/stdlib/RepeatedParameters.scala
  38. +6 −2 src/main/scala/stdlib/RepeatedParametersHelper.scala
  39. +25 −17 src/main/scala/stdlib/SequencesandArrays.scala
  40. +39 −34 src/main/scala/stdlib/Sets.scala
  41. +5 −5 src/main/scala/stdlib/StdLib.scala
  42. +33 −25 src/main/scala/stdlib/Traits.scala
  43. +116 −106 src/main/scala/stdlib/Traversables.scala
  44. +25 −20 src/main/scala/stdlib/Tuples.scala
  45. +25 −20 src/main/scala/stdlib/TypeSignatures.scala
  46. +52 −46 src/main/scala/stdlib/TypeVariance.scala
  47. +9 −4 src/main/scala/stdlib/TypeVarianceHelper.scala
  48. +15 −7 src/main/scala/stdlib/UniformAccessPrinciple.scala
  49. +8 −6 src/test/scala/stdlib/AssertsSpec.scala
  50. +5 −0 src/test/scala/stdlib/ByNameParameterSpec.scala
  51. +5 −0 src/test/scala/stdlib/CaseClassesSpec.scala
  52. +5 −0 src/test/scala/stdlib/ClassesSpec.scala
  53. +5 −0 src/test/scala/stdlib/EmptyValuesSpec.scala
  54. +5 −1 src/test/scala/stdlib/EnumerationsSpec.scala
  55. +5 −0 src/test/scala/stdlib/ExtractorsSpec.scala
  56. +5 −0 src/test/scala/stdlib/ForExpressionsSpec.scala
  57. +5 −0 src/test/scala/stdlib/FormattingSpec.scala
  58. +10 −4 src/test/scala/stdlib/HigherOrderFunctionsSpec.scala
  59. +5 −0 src/test/scala/stdlib/ImplicitsSpec.scala
  60. +5 −0 src/test/scala/stdlib/InfixPrefixAndPostfixOperatorsSpec.scala
  61. +5 −0 src/test/scala/stdlib/InfixTypesSpec.scala
  62. +5 −0 src/test/scala/stdlib/IterablesSpec.scala
  63. +5 −0 src/test/scala/stdlib/ListsSpec.scala
  64. +5 −0 src/test/scala/stdlib/LiteralBooleansSpec.scala
  65. +5 −0 src/test/scala/stdlib/LiteralNumbersSpec.scala
  66. +5 −0 src/test/scala/stdlib/LiteralStringsSpec.scala
  67. +5 −0 src/test/scala/stdlib/MapsSpec.scala
  68. +5 −0 src/test/scala/stdlib/NamedAndDefaultArgumentsSpec.scala
  69. +5 −0 src/test/scala/stdlib/ObjectsSpec.scala
  70. +5 −0 src/test/scala/stdlib/OptionsSpec.scala
  71. +5 −0 src/test/scala/stdlib/ParentClassesSpec.scala
  72. +5 −0 src/test/scala/stdlib/PartialFunctionsSpec.scala
  73. +5 −0 src/test/scala/stdlib/PartiallyAppliedFunctionsSpec.scala
  74. +5 −0 src/test/scala/stdlib/PatternMatchingSpec.scala
  75. +5 −0 src/test/scala/stdlib/RangesSpec.scala
  76. +5 −0 src/test/scala/stdlib/RepeatedParametersSpec.scala
  77. +5 −0 src/test/scala/stdlib/SequencesAndArraysSpec.scala
  78. +5 −0 src/test/scala/stdlib/SetsSpec.scala
  79. +5 −0 src/test/scala/stdlib/TraitsSpec.scala
  80. +5 −0 src/test/scala/stdlib/TraversablesSpec.scala
  81. +5 −0 src/test/scala/stdlib/TuplesSpec.scala
  82. +5 −0 src/test/scala/stdlib/TypeSignaturesSpec.scala
  83. +5 −0 src/test/scala/stdlib/TypeVarianceSpec.scala
  84. +5 −0 src/test/scala/stdlib/UniformAccessPrincipleSpec.scala
  85. +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 - 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.
@@ -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 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")
@@ -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,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
@@ -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)
}
@@ -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 {
@@ -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
@@ -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"
Oops, something went wrong.

0 comments on commit a8132f7

Please sign in to comment.