Skip to content

Commit b23b5fb

Browse files
committed
0.0.5 release
1 parent 04bf849 commit b23b5fb

34 files changed

Lines changed: 724 additions & 152 deletions

.travis.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,28 @@ go:
88

99
os:
1010
- linux
11-
- osx
11+
#- osx
1212

1313
matrix:
1414
allow_failures:
1515
- go: tip
1616
fast_finish: true
1717

18+
before_install:
19+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl -L -s https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 -o $GOPATH/bin/dep; fi
20+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://github.com/golang/dep/releases/download/v0.5.0/dep-darwin-amd64 -O $GOPATH/bin/dep; fi
21+
- chmod +x $GOPATH/bin/dep
22+
1823
install:
19-
- go get -t ./...
24+
- dep ensure
2025
- go get -u github.com/alecthomas/gometalinter
2126
- gometalinter --install
2227

2328
script:
2429
- gometalinter --misspell-locale=US --disable-all --enable=misspell --enable=vet ./dfl/
30+
- gometalinter --misspell-locale=US --disable-all --enable=misspell --enable=vet ./plugins/dfl/
2531
- gometalinter --misspell-locale=US --disable-all --enable=misspell --enable=vet ./cmd/dfl/
26-
- gometalinter --misspell-locale=US --disable-all --enable=misspell --enable=vet ./cmd/dfljs/
32+
- gometalinter --misspell-locale=US --disable-all --enable=misspell --enable=vet ./cmd/dfl.js/
2733
- cd cmd/dfl
2834
- go fmt
2935
- go build

Gopkg.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[[constraint]]
2+
name = "github.com/colinmarc/hdfs"
3+
revision = "279cc88949e23da3364c94a9ee440f5beee3ca65"

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ import (
3939
)
4040
```
4141

42+
See [dfl](https://godoc.org/github.com/spatialcurrent/go-dfl/dfl) in GoDoc for information on how to use Go API.
43+
4244
**JavaScript**
4345

4446
```html
4547
<html>
4648
<head>
47-
<script src="https://...dfljs.js"></script>
49+
<script src="https://...dfl.js"></script>
4850
</head>
4951
<body>
5052
<script>
@@ -65,7 +67,7 @@ A variant of the `EvaluateBool` function is exported in a Shared Object file (`*
6567
err = EvaluateBool(expression, size, ctx, &result);
6668
```
6769

68-
The Go function definition defined in `plugins/dfl/main.go` takes in the expression and context. For complete patterns for `C`, `C++`, and `Python`, see the `examples`.
70+
The Go function definition defined in `plugins/dfl/main.go` takes in the expression and context. For complete patterns for `C`, `C++`, and `Python`, see the `examples` folder.
6971

7072
# Examples:
7173

@@ -138,7 +140,11 @@ You can compile DFL to pure JavaScript with the `scripts/build_javascript.sh` sc
138140

139141
**Shared Object**
140142

141-
The `build_so.sh` script is used to build a Shared Object (`*.go`), which can be called by `C`, `C++`, and `Python` on Linux machines.
143+
The `scripts/build_so.sh` script is used to build a Shared Object (`*.go`), which can be called by `C`, `C++`, and `Python` on Linux machines.
144+
145+
**Changing Destination**
146+
147+
The default destination for build artifacts is `go-dfl/bin`, but you can change the destination with a CLI argument. For building on a Chromebook consider saving the artifacts in `/usr/local/go/bin`, e.g., `bash scripts/build_cli.sh /usr/local/go/bin`
142148

143149
# Contributing
144150

cmd/dfl.js/main.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@ import (
2626
"honnef.co/go/js/console"
2727
)
2828

29-
var GO_DFL_VERSION = "0.0.4"
30-
3129
type Node struct {
32-
Node dfl.Node
30+
Node dfl.Node
3331
FunctionMap dfl.FunctionMap
3432
}
3533

3634
func (n Node) Compile() *js.Object {
3735
return js.MakeWrapper(Node{
38-
Node: n.Node.Compile(),
36+
Node: n.Node.Compile(),
3937
FunctionMap: dfl.NewFuntionMapWithDefaults(),
4038
})
4139
}
@@ -57,11 +55,11 @@ func (n Node) Evaluate(options *js.Object) interface{} {
5755

5856
func main() {
5957
js.Global.Set("dfl", map[string]interface{}{
60-
"version": GO_DFL_VERSION,
61-
"Parse": Parse,
58+
"version": dfl.VERSION,
59+
"Parse": Parse,
6260
"EvaluateBool": EvaluateBool,
6361
"EvaluateInt": EvaluateInt,
64-
"EvaluateFloat": EvaluateFloat64,
62+
"EvaluateFloat": EvaluateFloat64,
6563
"EvaluateString": EvaluateString,
6664
})
6765
}
@@ -72,11 +70,9 @@ func Parse(s string) *js.Object {
7270
console.Log(err.Error())
7371
return js.MakeWrapper(Node{Node: nil})
7472
}
75-
return js.MakeWrapper(Node{Node:root})
73+
return js.MakeWrapper(Node{Node: root})
7674
}
7775

78-
79-
8076
func EvaluateBool(s string, options *js.Object) bool {
8177
root, err := dfl.Parse(s)
8278
if err != nil {

cmd/dfl/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ import (
4444
"github.com/spatialcurrent/go-dfl/dfl"
4545
)
4646

47-
var GO_DFL_VERSION = "0.0.4"
48-
4947
func main() {
5048

5149
start := time.Now()
@@ -83,7 +81,7 @@ func main() {
8381
}
8482

8583
if version {
86-
fmt.Println(GO_DFL_VERSION)
84+
fmt.Println(dfl.VERSION)
8785
os.Exit(0)
8886
}
8987

dfl/AttachLeft.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
// AttachLeft attaches the left Node as the left child node to the parent root Node.
1515
func AttachLeft(root Node, left Node) error {
1616
switch root.(type) {
17+
case *Pipe:
18+
root.(*Pipe).Left = left
1719
case *And:
1820
root.(*And).Left = left
1921
case *Or:

dfl/Attribute.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ func (a Attribute) Compile() Node {
2929
}
3030

3131
func (a Attribute) Evaluate(ctx interface{}, funcs FunctionMap) (interface{}, error) {
32+
if len(a.Name) == 0 {
33+
return ctx, nil
34+
}
3235
return Extract(a.Name, ctx)
3336
}
3437

dfl/CompareNumbers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
// CompareNumbers compares parameter a and parameter b.
20-
// The parameters may be of type int, int64, or float64.
20+
// The parameters may be of type uint8, int, int64, or float64.
2121
// If a > b, then returns 1. If a < b, then returns -1. If a == b, then return 0.
2222
func CompareNumbers(a interface{}, b interface{}) (int, error) {
2323
switch a.(type) {
@@ -163,5 +163,5 @@ func CompareNumbers(a interface{}, b interface{}) (int, error) {
163163
}
164164
}
165165

166-
return 0, errors.New(fmt.Sprintf("Error comparing values %#v (%v) and %#v (%v)", a, reflect.TypeOf(a).String(), b, reflect.TypeOf(b).String()))
166+
return 0, errors.New(fmt.Sprintf("Error comparing numbers %#v (%v) and %#v (%v)", a, reflect.TypeOf(a).String(), b, reflect.TypeOf(b).String()))
167167
}

dfl/Equal.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ func (e Equal) Evaluate(ctx interface{}, funcs FunctionMap) (interface{}, error)
7272
case float64:
7373
return lvs == fmt.Sprint(rv.(float64)), nil
7474
}
75+
case float64:
76+
switch rv.(type) {
77+
case Null:
78+
return false, nil
79+
}
7580
case net.IP:
7681
lvip := lv.(net.IP)
7782
switch rv.(type) {

dfl/EvaluateBool.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// =================================================================
2+
//
3+
// Copyright (C) 2018 Spatial Current, Inc. - All Rights Reserved
4+
// Released as open source under the MIT License. See LICENSE file.
5+
//
6+
// =================================================================
7+
18
package dfl
29

310
import (
@@ -13,7 +20,7 @@ import (
1320
func EvaluateBool(n Node, ctx interface{}, funcs FunctionMap) (bool, error) {
1421
result, err := n.Evaluate(ctx, funcs)
1522
if err != nil {
16-
return false, errors.Wrap(err, "Error evaluating expression")
23+
return false, errors.Wrap(err, "Error evaluating expression "+n.Dfl())
1724
}
1825

1926
switch result.(type) {

0 commit comments

Comments
 (0)