Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Commit

Permalink
Removes some compilation warnings (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpedromoreno authored Apr 7, 2017
1 parent db64df3 commit 0a8b8bf
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Add the following line to `project/plugins.sbt`:

```scala
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.4.2")
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.4.3")
```

# Copyright
Expand Down
1 change: 0 additions & 1 deletion core/src/main/scala/sbtorgpolicies/libraries.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ object libraries {
"discipline" -> "0.7.3",
"doobie" -> "0.4.1",
"embedded-redis" -> "0.6",
"evaluator" -> "0.1.1-SNAPSHOT",
"export-hook" -> "1.2.0",
"finch" -> "0.13.0",
"fs2" -> "0.9.4",
Expand Down
27 changes: 27 additions & 0 deletions core/src/main/scala/sbtorgpolicies/rules/model.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2017 47 Degrees, LLC. <http://www.47deg.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package sbtorgpolicies.rules

sealed abstract class PolicyLevel extends Product with Serializable

case object PolicyWarning extends PolicyLevel

case object PolicyError extends PolicyLevel

case class Validation(policyLevel: PolicyLevel, validationRule: ValidationRule)

case class ValidationRule(inputPath: String, validationList: List[ValidationFunction])
10 changes: 0 additions & 10 deletions core/src/main/scala/sbtorgpolicies/rules/rules.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ package object rules {

val emptyValidation: ValidationFunction = _ => Validated.valid((): Unit)

sealed abstract class PolicyLevel extends Product with Serializable

case object PolicyWarning extends PolicyLevel

case object PolicyError extends PolicyLevel

case class Validation(policyLevel: PolicyLevel, validationRule: ValidationRule)

case class ValidationRule(inputPath: String, validationList: List[ValidationFunction])

def mkValidation(path: String, list: List[ValidationFunction], policyLevel: PolicyLevel = PolicyError): Validation =
Validation(policyLevel, ValidationRule(path, list))
}
56 changes: 56 additions & 0 deletions core/src/main/scala/sbtorgpolicies/templates/model.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2017 47 Degrees, LLC. <http://www.47deg.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package sbtorgpolicies.templates

import org.joda.time.DateTime
import sbtorgpolicies.templates.syntax._

import scala.util.matching.Regex

trait Replaceable {

def asString: String
}

case class ReplaceableT[T](t: T) extends Replaceable {
override def asString: String = t.toString
}

case class ReplaceableList[T](list: List[T]) extends Replaceable {
override def asString: String = list.map(elem => s"* ${elem.asReplaceable.asString}").mkString("\n")
}

case class FileType(
mandatory: Boolean,
overWritable: Boolean,
templatePath: String,
outputPath: String,
replacements: Replacements,
fileSections: List[FileSection] = Nil)

case class FileSection(
appendPosition: AppendPosition,
template: String,
replacements: Replacements,
shouldAppend: (String) => Boolean = _ => true)

sealed trait AppendPosition
case object AppendAtTheBeginning extends AppendPosition
case object AppendAtTheEnd extends AppendPosition
case class AppendAfter(line: Regex) extends AppendPosition

case class NewReleaseSection(date: DateTime, version: String, changes: String)
35 changes: 0 additions & 35 deletions core/src/main/scala/sbtorgpolicies/templates/templates.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,13 @@ import sbtorgpolicies.utils._
import sbtorgpolicies.templates.syntax._

import scala.language.{implicitConversions, postfixOps}
import scala.util.matching.Regex

package object templates {

val versionFilePath: String = "version.sbt"

type Replacements = Map[String, Replaceable]

trait Replaceable {

def asString: String
}

case class ReplaceableT[T](t: T) extends Replaceable {
override def asString: String = t.toString
}

case class ReplaceableList[T](list: List[T]) extends Replaceable {
override def asString: String = list.map(elem => s"* ${elem.asReplaceable.asString}").mkString("\n")
}

case class FileType(
mandatory: Boolean,
overWritable: Boolean,
templatePath: String,
outputPath: String,
replacements: Replacements,
fileSections: List[FileSection] = Nil)

case class FileSection(
appendPosition: AppendPosition,
template: String,
replacements: Replacements,
shouldAppend: (String) => Boolean = _ => true)

sealed trait AppendPosition
case object AppendAtTheBeginning extends AppendPosition
case object AppendAtTheEnd extends AppendPosition
case class AppendAfter(line: Regex) extends AppendPosition

def LicenseFileType(ghSettings: GitHubSettings, license: License, startYear: Option[Int]): FileType = {

def licenseFile: String = license match {
Expand Down Expand Up @@ -148,8 +115,6 @@ package object templates {
def ChangelogFileType(date: DateTime, version: String, changes: String): FileType =
ChangelogFileType(Some(NewReleaseSection(date, version, changes)))

private[this] case class NewReleaseSection(date: DateTime, version: String, changes: String)

private[this] def ChangelogFileType(newChange: Option[NewReleaseSection]): FileType = {

val template =
Expand Down
3 changes: 1 addition & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
resolvers += Resolver.sonatypeRepo("snapshots")
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.4.3-SNAPSHOT")
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.4.3")
libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value

0 comments on commit 0a8b8bf

Please sign in to comment.