Skip to content

Commit

Permalink
Merge pull request #1 from delphi-hub/develop
Browse files Browse the repository at this point in the history
Update to 0.9.1
  • Loading branch information
bhermann authored Dec 30, 2019
2 parents a9e80b1 + 7e3435c commit 83f2653
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 11 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
language: scala
scala:
- 2.12.4
- 2.12.10
- 2.13.1
script:
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then sbt ++$TRAVIS_SCALA_VERSION test; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sbt ++$TRAVIS_SCALA_VERSION coverage test coverageReport coverageAggregate codacyCoverage; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sbt ++$TRAVIS_SCALA_VERSION test; fi'
# - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sbt ++$TRAVIS_SCALA_VERSION coverage test coverageReport coverageAggregate codacyCoverage; fi'
after_success:
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash <(curl -s https://codecov.io/bash); fi'
# - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash <(curl -s https://codecov.io/bash); fi'
4 changes: 1 addition & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ThisBuild / publishTo := {
}
ThisBuild / publishMavenStyle := true

ThisBuild / version := "0.9.0"
ThisBuild / version := "0.9.1"

lazy val scala212 = "2.12.10"
lazy val scala213 = "2.13.1"
Expand All @@ -38,8 +38,6 @@ lazy val supportedScalaVersions = List(scala212, scala213)
ThisBuild / scalaVersion := scala213


useGpg := true

lazy val root = (project in file("."))
.settings (
crossScalaVersions := Nil,
Expand Down
7 changes: 6 additions & 1 deletion client/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name := "delphi-client"

libraryDependencies += "io.spray" %% "spray-json" % "1.3.5"
libraryDependencies += "joda-time" % "joda-time" % "2.10.5"


libraryDependencies ++= Seq(
"com.softwaremill.sttp" %% "core" % "1.7.2",
"com.softwaremill.sttp" %% "spray-json" % "1.7.2"
)

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % "test"
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package de.upb.cs.swt.delphi.client

import com.softwaremill.sttp._
import com.softwaremill.sttp.sprayJson._
import spray.json._

import scala.util.Try
import de.upb.cs.swt.delphi.core.model.Artifact
import de.upb.cs.swt.delphi.client.QueryJson._

abstract class DelphiClient(baseUri : String) {
def search(query : Query, prettyPrint : Boolean = false) : Try[Seq[SearchResult]]
/* = {
val queryParams = prettyPrint match {
case true => Map("pretty" -> "")
case false => Map()
}
val searchUri = uri"${baseUri}/search?$queryParams"
val request = sttp.body(query.toJson).post(searchUri)
//val (res, time) = processRequest(request)
//res.foreach(processResults(_, time))
}*/

def features() : Try[Seq[FieldDefinition]]

def retrieve(identifier : String) : Try[Artifact]

def version() : Try[String]

def statistics() : Try[Statistics]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (C) 2018 The Delphi Team.
// See the LICENCE file distributed with this work for additional
// information regarding copyright ownership.
//
// 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 de.upb.cs.swt.delphi.client

import spray.json.DefaultJsonProtocol

case class FieldDefinition(name : String, description : String)

object FieldDefinitionJson extends DefaultJsonProtocol {
implicit val transform = jsonFormat2(FieldDefinition)
}
9 changes: 9 additions & 0 deletions client/src/main/scala/de/upb/cs/swt/delphi/client/Query.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package de.upb.cs.swt.delphi.client

import spray.json.DefaultJsonProtocol

case class Query(query : String, limit : Option[Int] = Some(50))

object QueryJson extends DefaultJsonProtocol {
implicit val queryRequestFormat = jsonFormat2(Query)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package de.upb.cs.swt.delphi.client

case class Statistics(total : Long, hermesEnabled : Long)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package de.upb.cs.swt.delphi.client

import spray.json.DefaultJsonProtocol

object StatisticsJson extends DefaultJsonProtocol {
implicit val statisticsFormat = jsonFormat2(Statistics)
}
4 changes: 2 additions & 2 deletions core/src/main/scala/de/upb/cs/swt/delphi/core/ql/Syntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ class Syntax(val input : ParserInput) extends Parser {
def IsTrue = rule { FieldReferenceRule ~> IsTrueExpr }

// Literals
def FieldReferenceRule = rule { "[" ~ capture(oneOrMore(CharPredicate.AlphaNum ++ '-' ++ ' ' ++ '_' ++ '(' ++ ':' ++')')) ~ "]" ~> FieldReference }
def FieldReferenceRule = rule { "[" ~ capture(oneOrMore(CharPredicate.AlphaNum ++ '.' ++ '-' ++ ' ' ++ '_' ++ '(' ++ ':' ++')')) ~ "]" ~> FieldReference }

def IntegerLiteral = rule { capture(oneOrMore(CharPredicate.Digit)) }
def StringLiteral = rule { '"' ~ capture(oneOrMore(CharPredicate.AlphaNum)) ~ '"'}
def StringLiteral = rule { '"' ~ capture(oneOrMore(CharPredicate.Printable -- '"' )) ~ '"'}

def Literal = rule { (IntegerLiteral | StringLiteral ) ~> (_.toString) }

Expand Down
24 changes: 22 additions & 2 deletions core/src/test/scala/de/upb/cs/swt/delphi/core/SyntaxTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

package de.upb.cs.swt.delphi.core

import de.upb.cs.swt.delphi.core.ql.Syntax
import de.upb.cs.swt.delphi.core.ql._
import org.parboiled2.ParseError
import org.scalatest.{FlatSpec, Matchers}

import scala.util.{Failure, Success}
Expand Down Expand Up @@ -166,7 +167,7 @@ class SyntaxTest extends FlatSpec with Matchers {

"Syntax.notConditionComplex" should "be valid" in {
val parseResult = new Syntax("!!([Filter1])&&!([Filter2]<=0||!([Filter3]&&![Filter4]%\"abc\"))").QueryRule.run()
parseResult shouldBe a [Success[_]]
parseResult shouldBe a[Success[_]]
parseResult match {
case Success(ast) => {
ast.toString shouldEqual "AndExpr(NotExpr(NotExpr(IsTrueExpr(FieldReference(Filter1))))," +
Expand All @@ -175,4 +176,23 @@ class SyntaxTest extends FlatSpec with Matchers {
}
}
}

"Complex query" should "be valid" in {
val parser = new Syntax("[metrics.classversion.9] > 0 && [metrics.classversion.8] = 0 && [maven.groupId] = \"com.github.xmlet\"")
val parseResult = parser.QueryRule.run()
parseResult match {
case Success(ast) => {
ast shouldEqual
AndExpr(
AndExpr(
GreaterThanExpr(FieldReference("metrics.classversion.9"),"0"),
EqualExpr(FieldReference("metrics.classversion.8"),"0")),
EqualExpr(FieldReference("maven.groupId"),"com.github.xmlet"))
}
case Failure(exception : ParseError) => {
fail(parser.formatError(exception))
}
case _ => fail()
}
}
}
29 changes: 29 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2019 The Delphi Team.
// See the LICENCE file distributed with this work for additional
// information regarding copyright ownership.
//
// 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.

// build management and packaging
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.5.1")

// coverage
//addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
//addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "3.0.3")

// preparation for dependency checking
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.1")

// scalastyle
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")

0 comments on commit 83f2653

Please sign in to comment.