diff --git a/.travis.yml b/.travis.yml index 25a4cf3..6d2a38c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,12 @@ +language: go go: - - 1.1 + - 1.7 + - 1.8 + - 1.9 - tip -install: - - go get github.com/onsi/ginkgo - - go get github.com/onsi/gomega -before_script: go test -i ./... -script: go test ./... +sudo: false +before_install: + - go get github.com/mattn/goveralls +script: + - export PATH=$PATH:$HOME/gopath/bin + - make ci diff --git a/Gopkg.lock b/Gopkg.lock new file mode 100644 index 0000000..d778e80 --- /dev/null +++ b/Gopkg.lock @@ -0,0 +1,45 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + name = "github.com/onsi/ginkgo" + packages = [".","config","internal/codelocation","internal/containernode","internal/failer","internal/leafnodes","internal/remote","internal/spec","internal/spec_iterator","internal/specrunner","internal/suite","internal/testingtproxy","internal/writer","reporters","reporters/stenographer","reporters/stenographer/support/go-colorable","reporters/stenographer/support/go-isatty","types"] + revision = "9eda700730cba42af70d53180f9dcce9266bc2bc" + version = "v1.4.0" + +[[projects]] + name = "github.com/onsi/gomega" + packages = [".","format","internal/assertion","internal/asyncassertion","internal/oraclematcher","internal/testingtsupport","matchers","matchers/support/goraph/bipartitegraph","matchers/support/goraph/edge","matchers/support/goraph/node","matchers/support/goraph/util","types"] + revision = "c893efa28eb45626cdaa76c9f653b62488858837" + version = "v1.2.0" + +[[projects]] + branch = "master" + name = "golang.org/x/net" + packages = ["html","html/atom","html/charset"] + revision = "57efc9c3d9f91fb3277f8da1cff370539c4d3dc5" + +[[projects]] + branch = "master" + name = "golang.org/x/sys" + packages = ["unix"] + revision = "2d6f6f883a06fc0d5f4b14a81e4c28705ea64c15" + +[[projects]] + branch = "master" + name = "golang.org/x/text" + packages = ["encoding","encoding/charmap","encoding/htmlindex","encoding/internal","encoding/internal/identifier","encoding/japanese","encoding/korean","encoding/simplifiedchinese","encoding/traditionalchinese","encoding/unicode","internal/gen","internal/tag","internal/utf8internal","language","runes","transform","unicode/cldr"] + revision = "ac87088df8ef557f1e32cd00ed0b6fbc3f7ddafb" + +[[projects]] + branch = "v2" + name = "gopkg.in/yaml.v2" + packages = ["."] + revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "dca1bcd6639a944d8a343d0f9d51d7e96e82079e138c45cc607f268535967727" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml new file mode 100644 index 0000000..8a45d86 --- /dev/null +++ b/Gopkg.toml @@ -0,0 +1,30 @@ + +# Gopkg.toml example +# +# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md +# for detailed Gopkg.toml documentation. +# +# required = ["github.com/user/thing/cmd/thing"] +# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] +# +# [[constraint]] +# name = "github.com/user/project" +# version = "1.0.0" +# +# [[constraint]] +# name = "github.com/user/project2" +# branch = "dev" +# source = "github.com/myfork/project2" +# +# [[override]] +# name = "github.com/x/y" +# version = "2.4.0" + + +[[constraint]] + name = "github.com/onsi/ginkgo" + version = "1.4.0" + +[[constraint]] + name = "github.com/onsi/gomega" + version = "1.2.0" diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..c1fcb9e --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 mtchavez jenkins + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Makefile b/Makefile index f05d467..7fffb25 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,27 @@ -build: - go build jenkins.go +ROOT := $(CURDIR) +GOPKGS = \ + golang.org/x/tools/cmd/cover \ + github.com/golang/lint/golint \ + github.com/golang/dep/cmd/dep -run: - go run jenkins.go +default: test + +deps: + @go get -u -v $(GOPKGS) + @dep ensure + +lint: + @echo "[Lint] running golint" + @golint + +vet: + @echo "[Vet] running go vet" + @go vet + +ci: deps vet lint test test: - go test -cover + @echo "[Test] running tests" + @if [ "$(CI)" ]; then goveralls -service=travis-ci; else go test -v -cover; fi -default: - go run jenkins.go +.PHONY: default golint test vet deps diff --git a/README.md b/README.md index 409f996..2d298be 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,12 @@ -Jenkins -================= +# Jenkins Hash -Golang Jenkins hash +[![Latest Version](http://img.shields.io/github/release/mtchavez/jenkins.svg?style=flat-square)](https://github.com/mtchavez/jenkins/releases) +[![Build Status](https://travis-ci.org/mtchavez/jenkins.svg?branch=master)](https://travis-ci.org/mtchavez/jenkins) +[![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/mtchavez/jenkins) +[![Coverage Status](https://coveralls.io/repos/github/mtchavez/jenkins/badge.svg)](https://coveralls.io/github/mtchavez/jenkins) +[![Go Report Card](https://goreportcard.com/badge/github.com/mtchavez/jenkins)](https://goreportcard.com/report/github.com/mtchavez/jenkins) -[![Build Status](https://travis-ci.org/mtchavez/go-jenkins-hashes.png?branch=master)](https://travis-ci.org/mtchavez/go-jenkins-hashes) +Golang Jenkins hash ## Install @@ -11,7 +14,7 @@ Golang Jenkins hash ## Usage -Jenkins follows the [Hash32](http://golang.org/pkg/hash/#Hash32) interface from the Go standard library +Jenkins conforms to the [Hash32](http://golang.org/pkg/hash/#Hash32) interface from the Go standard library ```go // Create a new hash @@ -30,7 +33,7 @@ sumbytes := jenkhash.Sum(key) ## Testing -Uses [Ginkgo](http://onsi.github.io/ginkgo/) for testing. +Uses [Ginkgo][ginkgo] and [Gomega][gomega] for testing. Run via `make test` which will run `go test -cover` @@ -38,8 +41,5 @@ Run via `make test` which will run `go test -cover` Docs on [godoc](http://godoc.org/github.com/mtchavez/jenkins) -## License - -Written by Chavez - -Released under the MIT License: http://www.opensource.org/licenses/mit-license.php +[ginkgo]: https://github.com/onsi/ginkgo +[gomega]: https://github.com/onsi/gomega diff --git a/jenkins.go b/jenkins.go index 7966762..77873f4 100644 --- a/jenkins.go +++ b/jenkins.go @@ -4,8 +4,14 @@ import "hash" type jenkhash uint32 +const ( + blockSize = 1 + hashSize = 4 +) + +// New returns a new jenkins hash conforming to hash.Hash32 interface func New() hash.Hash32 { - var j jenkhash = 0 + var j jenkhash return &j } @@ -31,11 +37,11 @@ func (j *jenkhash) Reset() { } func (j *jenkhash) Size() int { - return 4 + return hashSize } func (j *jenkhash) BlockSize() int { - return 1 + return blockSize } func (j *jenkhash) Sum32() uint32 {