Skip to content

Commit

Permalink
chore(release): release v0.4.2
Browse files Browse the repository at this point in the history
Merge pull request #56 from qri-io/release
  • Loading branch information
b5 authored Jun 29, 2020
2 parents 2f560aa + 0558dbe commit 575a727
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
working_directory: /go/src/github.com/qri-io/starlib
docker:
- image: circleci/golang:1.12
- image: circleci/golang:latest
environment:
TEST_RESULTS: /tmp/test-results
GO111MODULE: "on"
Expand Down
64 changes: 64 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,67 @@
<a name="v0.4.2">v0.4.2</a>
# [v0.4.2](https://github.com/qri-io/starlib/compare/v0.4.1...v0.4.2) (2020-06-29)

This release brings a number of enhancements to the `time`, `re`, and golang-side utility packages. It also introduces two new packages: `encoding/yaml` and `hash`. Here's the docs for the two new packages:

### yaml
yaml provides functions for working with yaml data

#### Functions

##### `dumps(obj) string`
serialize obj to a yaml string

**parameters:**

| name | type | description |
|------|------|-------------|
| `obj` | `object` | input object |


##### `loads(source) object`
read a source yaml string to a starlark object

**parameters:**

| name | type | description |
|------|------|-------------|
| `source` | `string` | input string of yaml data |


### hash
hash defines hash primitives for starlark.

#### Functions

##### `md5(string) string`
returns an md5 hash for a string

##### `sha1(string) string`
returns an sha1 hash for a string

##### `sha256(string) string`
returns an sha256 hash for a string


### Bug Fixes

* **time:** unix() and unix_nano() returns 0 for epoch ([c50ebc2](https://github.com/qri-io/starlib/commit/c50ebc2))


### Features

* **customType:** Added support for custom type and fixed bugs ([#49](https://github.com/qri-io/starlib/issues/49)) ([c32c667](https://github.com/qri-io/starlib/commit/c32c667)), closes [#48](https://github.com/qri-io/starlib/issues/48)
* **encoding/yaml:** encoding yaml package based on gopkg.in/yaml.v2 ([68e22bc](https://github.com/qri-io/starlib/commit/68e22bc))
* **hash:** add hash module ([686ae7b](https://github.com/qri-io/starlib/commit/686ae7b))
* **re:** add compile function to regex package ([6fe15cd](https://github.com/qri-io/starlib/commit/6fe15cd))
* **starlib:** util.Marshal extended compatibility and tests ([a310f83](https://github.com/qri-io/starlib/commit/a310f83))
* **time:** Add fromtimestamp method ([4e7be49](https://github.com/qri-io/starlib/commit/4e7be49))
* **time:** Add in_location and format methods ([316e7aa](https://github.com/qri-io/starlib/commit/316e7aa))
* **time:** Add methods hours(), minutes(), etc to duration ([f374e23](https://github.com/qri-io/starlib/commit/f374e23))
* **time:** Add unix and unix_nano methods ([7c32cb7](https://github.com/qri-io/starlib/commit/7c32cb7))



<a name="v0.4.1"></a>
# [v0.4.1](https://github.com/qri-io/starlib/compare/v0.4.0...v0.4.1) (2019-06-10)

Expand Down
20 changes: 11 additions & 9 deletions util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,19 @@ type invalidCustomType struct {

type customType invalidCustomType

func (t *customType) UnmarshalStarlark(v starlark.Value) error {
var (
_ Unmarshaler = (*customType)(nil)
_ Marshaler = (*customType)(nil)
_ starlark.Value = (*customType)(nil)
)

func (c *customType) UnmarshalStarlark(v starlark.Value) error {
// asserts
if v.Type() != "struct" {
return fmt.Errorf("not expected top level type, want struct, got %q", v.Type())
}
if _, ok := v.(*starlarkstruct.Struct).Constructor().(*customType); !ok {
return fmt.Errorf("not expected construct type got %T, want %T", v.(*starlarkstruct.Struct).Constructor(), t)
return fmt.Errorf("not expected construct type got %T, want %T", v.(*starlarkstruct.Struct).Constructor(), c)
}

// TODO: refactoring transform data
Expand All @@ -172,15 +178,15 @@ func (t *customType) UnmarshalStarlark(v starlark.Value) error {
data := starlark.StringDict{}
v.(*starlarkstruct.Struct).ToStringDict(data)

*t = customType{
*c = customType{
Foo: mustInt64(data["foo"]),
}
return nil
}

func (t *customType) MarshalStarlark() (starlark.Value, error) {
func (c *customType) MarshalStarlark() (starlark.Value, error) {
v := starlarkstruct.FromStringDict(&customType{}, starlark.StringDict{
"foo": starlark.MakeInt64(t.Foo),
"foo": starlark.MakeInt64(c.Foo),
})
return v, nil
}
Expand All @@ -200,7 +206,3 @@ func (c customType) Truth() starlark.Bool {
func (c customType) Hash() (uint32, error) {
return 0, fmt.Errorf("unhashable: %s", c.Type())
}

var _ Unmarshaler = (*customType)(nil)
var _ Marshaler = (*customType)(nil)
var _ starlark.Value = (*customType)(nil)

0 comments on commit 575a727

Please sign in to comment.