Skip to content

Commit 53f5ac4

Browse files
Revert "Freestyle & sbt-org-policies plugin Integration"
1 parent 7aac650 commit 53f5ac4

File tree

7 files changed

+112
-227
lines changed

7 files changed

+112
-227
lines changed

src/main/scala/org/scalaexercises/exercises/Exercises.scala

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
/*
2-
* scala-exercises
3-
*
4-
* Copyright 2015-2017 47 Degrees, LLC. <http://www.47deg.com>
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*
2+
* scala-exercises-runtime
3+
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
184
*/
195

206
package org.scalaexercises.runtime
@@ -34,38 +20,33 @@ object Exercises {
3420
val LIBRARIES_PACKAGE = "org.scalaexercises.content"
3521

3622
private[this] def classMap(cl: ClassLoader) = {
37-
val files = cl.asInstanceOf[URLClassLoader].getURLs map (_.getFile)
23+
val files = cl.asInstanceOf[URLClassLoader].getURLs map (_.getFile)
3824
val classFinder = ClassFinder(files map (new File(_)) filter (f f.exists()))
39-
val classes = classFinder.getClasses.toIterator
25+
val classes = classFinder.getClasses.toIterator
4026
ClassFinder.classInfoMap(classes)
4127
}
4228

4329
private[this] def subclassesOf[A: ClassTag](cl: ClassLoader): List[String] = {
44-
def loop(currentClassLoader: ClassLoader, acc: List[String]): List[String] =
45-
Option(currentClassLoader) match {
46-
case None acc
47-
case Some(cll: URLClassLoader)
48-
val cn = ClassFinder
49-
.concreteSubclasses(implicitly[ClassTag[A]].runtimeClass.getName, classMap(cll))
50-
.filter(_.name.startsWith(LIBRARIES_PACKAGE))
51-
.map(_.name)
52-
.toList
53-
loop(currentClassLoader.getParent, acc ++ cn)
54-
case Some(o) loop(o.getParent, acc)
55-
}
30+
def loop(currentClassLoader: ClassLoader, acc: List[String]): List[String] = Option(currentClassLoader) match {
31+
case None acc
32+
case Some(cll: URLClassLoader)
33+
val cn = ClassFinder.concreteSubclasses(implicitly[ClassTag[A]].runtimeClass.getName, classMap(cll))
34+
.filter(_.name.startsWith(LIBRARIES_PACKAGE))
35+
.map(_.name)
36+
.toList
37+
loop(currentClassLoader.getParent, acc ++ cn)
38+
case Some(o) loop(o.getParent, acc)
39+
}
5640
loop(cl, Nil)
5741
}
5842

59-
def discoverLibraries(
60-
cl: ClassLoader = classOf[Exercise].getClassLoader): (List[String], List[Library]) = {
43+
def discoverLibraries(cl: ClassLoader = classOf[Exercise].getClassLoader): (List[String], List[Library]) = {
6144
val classNames: List[String] = subclassesOf[Library](cl)
6245

6346
val errorsAndLibraries = classNames.map { name
6447
for {
6548
loadedClass guard(Class.forName(name, true, cl), s"$name not found")
66-
loadedObject guard(
67-
loadedClass.getField("MODULE$").get(null),
68-
s"$name must be defined as an object")
49+
loadedObject guard(loadedClass.getField("MODULE$").get(null), s"$name must be defined as an object")
6950
loadedLibrary guard(loadedObject.asInstanceOf[Library], s"$name must extend Library")
7051
} yield loadedLibrary
7152
}
@@ -77,16 +58,16 @@ object Exercises {
7758
Either.catchNonFatal(f).leftMap(_ message)
7859

7960
def buildEvaluatorRequest(
80-
pkg: String,
81-
qualifiedMethod: String,
82-
rawArgs: List[String],
83-
imports: List[String] = Nil,
84-
resolvers: List[String],
85-
libraryDependencies: List[String]
61+
pkg: String,
62+
qualifiedMethod: String,
63+
rawArgs: List[String],
64+
imports: List[String] = Nil,
65+
resolvers: List[String],
66+
libraryDependencies: List[String]
8667
): (List[String], List[Dependency], String) = {
8768

8869
val extractEvaluatorResolvers: List[String] = {
89-
resolvers.filter(r => !r.isEmpty && r.contains("http")) map { resolver
70+
resolvers.filter(!_.isEmpty) map { resolver
9071
resolver.substring(resolver.indexOf("http"))
9172
}
9273
}
@@ -98,7 +79,7 @@ object Exercises {
9879
}
9980
}
10081

101-
val pre = (s"import $pkg._" :: imports).mkString("; ")
82+
val pre = (s"import $pkg._" :: imports).mkString("; ")
10283
val code = s"""$qualifiedMethod(${rawArgs.mkString(", ")})"""
10384

10485
val allCode = s"{$pre; $code}"
Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
11
/*
2-
* scala-exercises
3-
*
4-
* Copyright 2015-2017 47 Degrees, LLC. <http://www.47deg.com>
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*
2+
* scala-exercises-exercise-compiler
3+
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
184
*/
195

206
package org.scalaexercises.runtime
217

228
import java.text.SimpleDateFormat
23-
import java.util.{Date, TimeZone}
9+
import java.util.{ Date, TimeZone }
2410

2511
object Timestamp {
2612
val ISO8601 = "yyyy-MM-dd'T'HH:mm:ssz"
@@ -31,8 +17,9 @@ object Timestamp {
3117
setTimeZone(UTC)
3218
}
3319

34-
def fromDate(d: Date): String =
20+
def fromDate(d: Date): String = {
3521
FORMAT.format(d)
22+
}
3623

3724
def toDate(timestamp: String): Date = FORMAT.parse(timestamp)
3825
}
Lines changed: 38 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
/*
2-
* scala-exercises
3-
*
4-
* Copyright 2015-2017 47 Degrees, LLC. <http://www.47deg.com>
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*
2+
* scala-exercises-runtime
3+
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
184
*/
195

206
package org.scalaexercises.runtime
@@ -23,7 +9,7 @@ package model
239
// This is the exercise runtime metamodel
2410

2511
/** An exercise library.
26-
*/
12+
*/
2713
trait Library {
2814
def owner: String
2915
def repository: String
@@ -38,14 +24,14 @@ trait Library {
3824
}
3925

4026
/** Library Build Metadata Information
41-
*/
27+
*/
4228
trait BuildInfo {
4329
def resolvers: List[String]
4430
def libraryDependencies: List[String]
4531
}
4632

4733
/** A section in a library.
48-
*/
34+
*/
4935
trait Section {
5036
def name: String
5137
def description: Option[String]
@@ -56,7 +42,7 @@ trait Section {
5642
}
5743

5844
/** A contribution to a section.
59-
*/
45+
*/
6046
trait Contribution {
6147
def sha: String
6248
def message: String
@@ -68,7 +54,7 @@ trait Contribution {
6854
}
6955

7056
/** Exercises within a section.
71-
*/
57+
*/
7258
trait Exercise {
7359
def name: String
7460
def description: Option[String]
@@ -81,47 +67,48 @@ trait Exercise {
8167

8268
// default case class implementations
8369
case class DefaultLibrary(
84-
owner: String,
85-
repository: String,
86-
name: String,
87-
description: String,
88-
color: Option[String],
89-
logoPath: String,
90-
logoData: Option[String],
91-
sections: List[Section] = Nil,
92-
timestamp: String,
93-
buildMetaInfo: BuildInfo
70+
owner: String,
71+
repository: String,
72+
name: String,
73+
description: String,
74+
color: Option[String],
75+
logoPath: String,
76+
logoData: Option[String],
77+
sections: List[Section] = Nil,
78+
timestamp: String,
79+
buildMetaInfo: BuildInfo
9480
) extends Library
9581

9682
case class DefaultContribution(
97-
sha: String,
98-
message: String,
99-
timestamp: String,
100-
url: String,
101-
author: String,
102-
authorUrl: String,
103-
avatarUrl: String
83+
sha: String,
84+
message: String,
85+
timestamp: String,
86+
url: String,
87+
author: String,
88+
authorUrl: String,
89+
avatarUrl: String
10490
) extends Contribution
10591

10692
case class DefaultSection(
107-
name: String,
108-
description: Option[String],
109-
exercises: List[Exercise] = Nil,
110-
imports: List[String] = Nil,
111-
path: Option[String] = None,
112-
contributions: List[DefaultContribution] = Nil
93+
name: String,
94+
description: Option[String],
95+
exercises: List[Exercise] = Nil,
96+
imports: List[String] = Nil,
97+
path: Option[String] = None,
98+
contributions: List[DefaultContribution] = Nil
11399
) extends Section
114100

115101
case class DefaultExercise(
116-
name: String,
117-
description: Option[String] = None,
118-
code: String,
119-
qualifiedMethod: String,
120-
imports: List[String],
121-
explanation: Option[String] = None,
122-
packageName: String
102+
name: String,
103+
description: Option[String] = None,
104+
code: String,
105+
qualifiedMethod: String,
106+
imports: List[String],
107+
explanation: Option[String] = None,
108+
packageName: String
123109
) extends Exercise
124110
/*
125111
* scala-exercises-runtime
126112
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
127113
*/
114+

0 commit comments

Comments
 (0)