Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit b9e35e2

Browse files
committed
BblfshClient implementation, using ScalaPB for gRPC
1 parent 2a0770d commit b9e35e2

File tree

15 files changed

+1370
-4
lines changed

15 files changed

+1370
-4
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
*.class
22
*.log
3+
target
4+
*~
5+
.idea

.travis.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
dist: trusty
2+
sudo: false
3+
4+
language: scala
5+
services:
6+
- docker
7+
8+
jdk:
9+
- openjdk8
10+
11+
scala:
12+
- 2.11
13+
14+
cache:
15+
directories:
16+
- $HOME/.m2
17+
18+
before_install:
19+
- docker run --privileged -d -p 9432:9432 --name bblfsh bblfsh/server
20+
21+
after_failure:
22+
- docker logs bblfsh

LICENSE

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright {yyyy} {name of copyright owner}
189+
Copyright 2017 Alexander Bezzubov
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

README.md

+35-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
1-
# client-scala
2-
Babelfish Scala client
1+
## Babelfish Scala client [![Build Status](https://travis-ci.org/bzz/client-scala.svg?branch=master)](https://travis-ci.org/bzz/client-scala)
2+
3+
This a pure Scala implementation of [Babelfish](https://doc.bblf.sh/) client.
4+
It uses [ScalaPB](https://scalapb.github.io/grpc.html) for Protobuf/gRPC code generation.
5+
6+
### Usage
7+
8+
API
9+
```scala
10+
import scala.io.Source
11+
import org.bblfsh.client.BblfshClient
12+
13+
val client = BblfshClient("0.0.0.0", 9432)
14+
15+
val filename = "/path/to/file.py" // client responsible for encoding it to utf-8
16+
val fileContent = Source.fromFile(filename).getLines.mkString
17+
println(client.parse(filename, fileContent))
18+
```
19+
20+
Command line
21+
```
22+
java -jar ./target/client-assembly-0.0.1.jar file.py
23+
```
24+
25+
### Build
26+
27+
```
28+
./sbt assembly
29+
```
30+
31+
gRPC/protobuf are re-generate from `src/main/proto` on every `./sbt compile` and are stored under `./target/scala-2.11/src_managed/`
32+
33+
### License
34+
35+
Apache 2.0

build.sbt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name := "client"
2+
organization := "org.bblfsh"
3+
version := "0.0.1"
4+
5+
scalaVersion := "2.11.11"
6+
7+
mainClass in Compile := Some("org.bblfsh.clent.ScalaClient")
8+
9+
PB.targets in Compile := Seq(
10+
scalapb.gen() -> (sourceManaged in Compile).value
11+
)
12+
PB.protoSources in Compile := Seq(file("src/main/proto"))
13+
14+
libraryDependencies += "com.trueaccord.scalapb" %% "scalapb-runtime" % com.trueaccord.scalapb.compiler.Version.scalapbVersion % "protobuf"
15+
16+
libraryDependencies ++= Seq(
17+
"org.scalatest" %% "scalatest" % "3.0.1" % "test",
18+
19+
"io.grpc" % "grpc-netty" % com.trueaccord.scalapb.compiler.Version.grpcJavaVersion,
20+
"com.trueaccord.scalapb" %% "scalapb-runtime-grpc" % com.trueaccord.scalapb.compiler.Version.scalapbVersion
21+
)

project/assembly.sbt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5")

project/build.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version = 0.13.15

project/scalapb.sbt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.11")
2+
3+
libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin" % "0.6.0"

0 commit comments

Comments
 (0)