From 90baef95e76483e9a5f3c78c3c7b0afdacb76be0 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Mon, 3 Aug 2015 22:51:08 -0700 Subject: [PATCH 1/3] removed un-used config flag --- cmd/drone-server/drone.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/drone-server/drone.go b/cmd/drone-server/drone.go index 159e80de7..7ab426d27 100644 --- a/cmd/drone-server/drone.go +++ b/cmd/drone-server/drone.go @@ -34,14 +34,13 @@ var ( ) var ( - conf = flag.String("config", "drone.toml", "") debug = flag.Bool("debug", false, "") ) func main() { flag.Parse() - settings, err := config.Load(*conf) + settings, err := config.Load("") if err != nil { panic(err) } From 0b98eb41866724cc3fd0c911b759a6930be72752 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Thu, 6 Aug 2015 08:54:47 -0700 Subject: [PATCH 2/3] improving database & remote setup --- cmd/drone-server/drone.go | 66 ++++++++++++++++++++++++++--- pkg/remote/builtin/github/github.go | 3 +- pkg/remote/remote.go | 34 +++++++-------- pkg/store/builtin/store.go | 12 +----- pkg/store/store.go | 19 ++++----- 5 files changed, 87 insertions(+), 47 deletions(-) diff --git a/cmd/drone-server/drone.go b/cmd/drone-server/drone.go index 7ab426d27..2c2a98a35 100644 --- a/cmd/drone-server/drone.go +++ b/cmd/drone-server/drone.go @@ -1,10 +1,12 @@ package main import ( - "flag" + "fmt" "html/template" "net/http" + "github.com/namsral/flag" + "github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin" "github.com/drone/drone/Godeps/_workspace/src/github.com/elazarl/go-bindata-assetfs" @@ -33,11 +35,61 @@ var ( revision string ) -var ( - debug = flag.Bool("debug", false, "") -) +var conf = struct { + debug bool + + server struct { + addr string + cert string + key string + } + + session struct { + expiry string + secret string + } + + docker struct { + host string + cert string + key string + ca string + } + + remote struct { + driver string + config string + } + + database struct { + driver string + config string + } + + plugin struct { + filter string + } +}{} func main() { + + flag.StringVar(&conf.docker.host, "docker-host", "unix:///var/run/docker/docker.sock", "") + flag.StringVar(&conf.docker.cert, "docker-cert", "", "") + flag.StringVar(&conf.docker.key, "docker-key", "", "") + flag.StringVar(&conf.docker.ca, "docker-ca", "", "") + flag.StringVar(&conf.server.addr, "server-addr", ":8080", "") + flag.StringVar(&conf.server.cert, "server-cert", "", "") + flag.StringVar(&conf.server.key, "server-key", "", "") + flag.StringVar(&conf.session.expiry, "session-expiry", "", "") + flag.StringVar(&conf.session.secret, "session-secret", "", "") + flag.StringVar(&conf.remote.driver, "remote-driver", "github", "") + flag.StringVar(&conf.remote.config, "remote-config", "https://github.com", "") + flag.StringVar(&conf.database.driver, "database-driver", "sqlite3", "") + flag.StringVar(&conf.database.config, "database-config", "drone.sqlite", "") + flag.StringVar(&conf.plugin.filter, "plugin-filter", "plugins/*", "") + flag.BoolVar(&conf.debug, "debug", false, "") + + flag.String("config", "", "") flag.Parse() settings, err := config.Load("") @@ -45,12 +97,12 @@ func main() { panic(err) } - store, err := store.New(settings.Database.Driver + "://" + settings.Database.Datasource) + store, err := store.New(conf.database.driver, conf.database.config) if err != nil { panic(err) } - remote, err := remote.New(settings.Remote.Driver, settings) + remote, err := remote.New(conf.remote.driver, conf.remote.config) if err != nil { panic(err) } @@ -204,7 +256,7 @@ func static() http.Handler { AssetDir: AssetDir, Prefix: "cmd/drone-server/static", }) - if *debug { + if conf.debug { handler = http.FileServer( http.Dir("cmd/drone-server/static"), ) diff --git a/pkg/remote/builtin/github/github.go b/pkg/remote/builtin/github/github.go index cb5b7901f..e08e8351a 100644 --- a/pkg/remote/builtin/github/github.go +++ b/pkg/remote/builtin/github/github.go @@ -41,7 +41,8 @@ func init() { remote.Register("github", NewDriver) } -func NewDriver(conf *config.Config) (remote.Remote, error) { +func NewDriver(config string) (remote.Remote, error) { + //conf *config.Config var github = GitHub{ API: conf.Github.API, URL: conf.Github.Host, diff --git a/pkg/remote/remote.go b/pkg/remote/remote.go index 0da719816..1fbdd2dfd 100644 --- a/pkg/remote/remote.go +++ b/pkg/remote/remote.go @@ -1,12 +1,12 @@ package remote import ( - "fmt" "net/http" - "github.com/drone/drone/pkg/config" "github.com/drone/drone/pkg/oauth2" - common "github.com/drone/drone/pkg/types" + "github.com/drone/drone/pkg/types" + + log "github.com/drone/drone/Godeps/_workspace/src/github.com/Sirupsen/logrus" ) var drivers = make(map[string]DriverFunc) @@ -26,55 +26,55 @@ func Register(name string, driver DriverFunc) { // DriverFunc returns a new connection to the remote. // Config is a struct, with base remote configuration. -type DriverFunc func(conf *config.Config) (Remote, error) +type DriverFunc func(config string) (Remote, error) // New creates a new remote connection. -func New(driver string, conf *config.Config) (Remote, error) { +func New(driver, config string) (Remote, error) { fn, ok := drivers[driver] if !ok { - return nil, fmt.Errorf("remote: unknown driver %q", driver) + log.Fatalf("remote: unknown driver %q", driver) } - return fn(conf) + return fn(config) } type Remote interface { // Login authenticates the session and returns the // remote user details. - Login(token, secret string) (*common.User, error) + Login(token, secret string) (*types.User, error) // Orgs fetches the organizations for the given user. - Orgs(u *common.User) ([]string, error) + Orgs(u *types.User) ([]string, error) // Repo fetches the named repository from the remote system. - Repo(u *common.User, owner, repo string) (*common.Repo, error) + Repo(u *types.User, owner, repo string) (*types.Repo, error) // Perm fetches the named repository permissions from // the remote system for the specified user. - Perm(u *common.User, owner, repo string) (*common.Perm, error) + Perm(u *types.User, owner, repo string) (*types.Perm, error) // Script fetches the build script (.drone.yml) from the remote // repository and returns in string format. - Script(u *common.User, r *common.Repo, b *common.Build) ([]byte, error) + Script(u *types.User, r *types.Repo, b *types.Build) ([]byte, error) // Status sends the commit status to the remote system. // An example would be the GitHub pull request status. - Status(u *common.User, r *common.Repo, b *common.Build) error + Status(u *types.User, r *types.Repo, b *types.Build) error // Netrc returns a .netrc file that can be used to clone // private repositories from a remote system. - Netrc(u *common.User) (*common.Netrc, error) + Netrc(u *types.User) (*types.Netrc, error) // Activate activates a repository by creating the post-commit hook and // adding the SSH deploy key, if applicable. - Activate(u *common.User, r *common.Repo, k *common.Keypair, link string) error + Activate(u *types.User, r *types.Repo, k *types.Keypair, link string) error // Deactivate removes a repository by removing all the post-commit hooks // which are equal to link and removing the SSH deploy key. - Deactivate(u *common.User, r *common.Repo, link string) error + Deactivate(u *types.User, r *types.Repo, link string) error // Hook parses the post-commit hook from the Request body // and returns the required data in a standard format. - Hook(r *http.Request) (*common.Hook, error) + Hook(r *http.Request) (*types.Hook, error) // Oauth2Transport Oauth2Transport(r *http.Request) *oauth2.Transport diff --git a/pkg/store/builtin/store.go b/pkg/store/builtin/store.go index 33800f2db..78977f828 100644 --- a/pkg/store/builtin/store.go +++ b/pkg/store/builtin/store.go @@ -2,7 +2,6 @@ package builtin import ( "database/sql" - "net/url" "os" "github.com/drone/drone/pkg/store" @@ -25,16 +24,7 @@ func init() { store.Register("postgres", NewDriver) } -func NewDriver(dsn string) (store.Store, error) { - uri, err := url.Parse(dsn) - if err != nil { - return nil, err - } - driver := uri.Scheme - if uri.Scheme == "sqlite3" { - uri.Scheme = "" - } - datasource := uri.String() +func NewDriver(driver, datasource string) (store.Store, error) { conn, err := Connect(driver, datasource) if err != nil { return nil, err diff --git a/pkg/store/store.go b/pkg/store/store.go index d71f0ced1..92470571f 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -1,11 +1,11 @@ package store import ( - "fmt" "io" - "net/url" "github.com/drone/drone/pkg/types" + + log "github.com/drone/drone/Godeps/_workspace/src/github.com/Sirupsen/logrus" ) var drivers = make(map[string]DriverFunc) @@ -25,22 +25,19 @@ func Register(name string, driver DriverFunc) { // DriverFunc returns a new connection to the datastore. // The name is a string in a driver-specific format. -type DriverFunc func(name string) (Store, error) +type DriverFunc func(driver, datasource string) (Store, error) // New creates a new database connection specified by its database driver // name and a driver-specific data source name, usually consisting of at // least a database name and connection information. -func New(dsn string) (Store, error) { - uri, err := url.Parse(dsn) - if err != nil { - return nil, err - } - driver := uri.Scheme +func New(driver, datasource string) (Store, error) { fn, ok := drivers[driver] if !ok { - return nil, fmt.Errorf("datastore: unknown driver %q", driver) + log.Fatalf("datastore: unknown driver %q", driver) } - return fn(dsn) + log.Infof("datastore: loading driver %s", driver) + log.Infof("datastore: loading config %s", datasource) + return fn(driver, datasource) } type Store interface { From e28930f997ec912f1461dc6e93bdb13a5ae5841f Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Thu, 6 Aug 2015 09:22:31 -0700 Subject: [PATCH 3/3] adding flag package to deps --- Godeps/Godeps.json | 17 +- .../go-gitlab-client/gitlab_test.go | 2 +- .../go-gitlab-client/hook_payload_test.go | 2 +- .../Bugagazavr/go-gitlab-client/hooks_test.go | 2 +- .../go-gitlab-client/projects_test.go | 2 +- .../go-gitlab-client/public_keys_test.go | 2 +- .../go-gitlab-client/repositories_test.go | 2 +- .../go-gitlab-client/session_test.go | 2 +- .../Bugagazavr/go-gitlab-client/users_test.go | 2 +- .../Bugagazavr/go-gitlab-client/util_test.go | 2 +- .../docker/docker/pkg/units/duration.go | 31 + .../docker/docker/pkg/units/duration_test.go | 46 + .../docker/docker/pkg/units/size.go | 93 + .../docker/docker/pkg/units/size_test.go | 108 + .../gin/examples/app-engine/README.md | 7 - .../gin/examples/app-engine/app.yaml | 8 - .../gin/examples/app-engine/hello.go | 23 - .../gin-gonic/gin/examples/example_basic.go | 56 - .../gin/examples/realtime-advanced/main.go | 39 - .../resources/room_login.templ.html | 208 -- .../resources/static/epoch.min.css | 1 - .../resources/static/prismjs.min.css | 137 - .../resources/static/realtime.js | 144 - .../gin/examples/realtime-advanced/rooms.go | 25 - .../gin/examples/realtime-advanced/routes.go | 96 - .../gin/examples/realtime-advanced/stats.go | 56 - .../gin/examples/realtime-chat/main.go | 58 - .../gin/examples/realtime-chat/rooms.go | 33 - .../gin/examples/realtime-chat/template.go | 44 - .../src/github.com/namsral/flag/LICENSE | 27 + .../src/github.com/namsral/flag/README.md | 184 + .../github.com/namsral/flag/example_test.go | 82 + .../namsral/flag/examples/gopher.conf | 5 + .../namsral/flag/examples/gopher.go | 29 + .../github.com/namsral/flag/export_test.go | 17 + .../src/github.com/namsral/flag/flag.go | 1040 ++++++ .../src/github.com/namsral/flag/flag_test.go | 475 +++ .../namsral/flag/testdata/test.conf | 11 + .../naoina/go-stringutil/.travis.yml | 9 - .../github.com/naoina/go-stringutil/LICENSE | 19 - .../github.com/naoina/go-stringutil/README.md | 13 - .../naoina/go-stringutil/strings.go | 120 - .../go-stringutil/strings_bench_test.go | 35 - .../naoina/go-stringutil/strings_test.go | 88 - .../src/github.com/naoina/toml/.travis.yml | 11 - .../src/github.com/naoina/toml/LICENSE | 19 - .../src/github.com/naoina/toml/Makefile | 16 - .../src/github.com/naoina/toml/README.md | 364 -- .../src/github.com/naoina/toml/ast/ast.go | 184 - .../src/github.com/naoina/toml/decode.go | 649 ---- .../naoina/toml/decode_bench_test.go | 49 - .../src/github.com/naoina/toml/decode_test.go | 1083 ------ .../src/github.com/naoina/toml/encode.go | 211 -- .../src/github.com/naoina/toml/encode_test.go | 298 -- .../src/github.com/naoina/toml/error.go | 31 - .../src/github.com/naoina/toml/parse.go | 54 - .../src/github.com/naoina/toml/parse.peg | 138 - .../src/github.com/naoina/toml/parse.peg.go | 3065 ----------------- .../src/github.com/naoina/toml/util.go | 79 - cmd/drone-server/drone.go | 2 +- pkg/runner/builtin/runner.go | 8 +- 61 files changed, 2171 insertions(+), 7492 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/docker/docker/pkg/units/duration.go create mode 100644 Godeps/_workspace/src/github.com/docker/docker/pkg/units/duration_test.go create mode 100644 Godeps/_workspace/src/github.com/docker/docker/pkg/units/size.go create mode 100644 Godeps/_workspace/src/github.com/docker/docker/pkg/units/size_test.go delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/README.md delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/app.yaml delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/hello.go delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/example_basic.go delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/main.go delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/room_login.templ.html delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/static/epoch.min.css delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/static/prismjs.min.css delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/static/realtime.js delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/rooms.go delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/routes.go delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/stats.go delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/main.go delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/rooms.go delete mode 100644 Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/template.go create mode 100644 Godeps/_workspace/src/github.com/namsral/flag/LICENSE create mode 100644 Godeps/_workspace/src/github.com/namsral/flag/README.md create mode 100644 Godeps/_workspace/src/github.com/namsral/flag/example_test.go create mode 100644 Godeps/_workspace/src/github.com/namsral/flag/examples/gopher.conf create mode 100644 Godeps/_workspace/src/github.com/namsral/flag/examples/gopher.go create mode 100644 Godeps/_workspace/src/github.com/namsral/flag/export_test.go create mode 100644 Godeps/_workspace/src/github.com/namsral/flag/flag.go create mode 100644 Godeps/_workspace/src/github.com/namsral/flag/flag_test.go create mode 100644 Godeps/_workspace/src/github.com/namsral/flag/testdata/test.conf delete mode 100644 Godeps/_workspace/src/github.com/naoina/go-stringutil/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/naoina/go-stringutil/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/naoina/go-stringutil/README.md delete mode 100644 Godeps/_workspace/src/github.com/naoina/go-stringutil/strings.go delete mode 100644 Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_bench_test.go delete mode 100644 Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_test.go delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/Makefile delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/README.md delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/ast/ast.go delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/decode.go delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/decode_bench_test.go delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/decode_test.go delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/encode.go delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/encode_test.go delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/error.go delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/parse.go delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/parse.peg delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/parse.peg.go delete mode 100644 Godeps/_workspace/src/github.com/naoina/toml/util.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 827cac72f..dce9a7248 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,8 +1,8 @@ { "ImportPath": "github.com/drone/drone", - "GoVersion": "go1.4.2", + "GoVersion": "go1.3.1", "Packages": [ - "github.com/drone/drone..." + "./..." ], "Deps": [ { @@ -28,6 +28,11 @@ "Comment": "v2.2.0-16-gc48cfd5", "Rev": "c48cfd5d9711c75acb6036d2698ef3aef7bb655a" }, + { + "ImportPath": "github.com/docker/docker/pkg/units", + "Comment": "v1.4.1-4375-g9356c76", + "Rev": "9356c76d9f6e285e71f04df33ef7870455a42775" + }, { "ImportPath": "github.com/elazarl/go-bindata-assetfs", "Rev": "bea323321994103859d60197d229f1a94699dde3" @@ -76,12 +81,8 @@ "Rev": "542ae647f8601bafd96233961b150cae198e0295" }, { - "ImportPath": "github.com/naoina/go-stringutil", - "Rev": "360db0db4b01d34e12a2ec042c09e7d37fece761" - }, - { - "ImportPath": "github.com/naoina/toml", - "Rev": "7b2dffbeaee47506726f29e36d19cf4ee90d361b" + "ImportPath": "github.com/namsral/flag", + "Rev": "881a43080604bcf99ab1118a814d1cb2c268fc36" }, { "ImportPath": "github.com/russross/meddler", diff --git a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/gitlab_test.go b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/gitlab_test.go index f4088e457..654e39dc1 100644 --- a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/gitlab_test.go +++ b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/gitlab_test.go @@ -1,7 +1,7 @@ package gogitlab import ( - "github.com/stretchr/testify/assert" + "github.com/drone/drone/Godeps/_workspace/src/github.com/stretchr/testify/assert" "testing" ) diff --git a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/hook_payload_test.go b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/hook_payload_test.go index 483d1bbae..a85e21375 100644 --- a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/hook_payload_test.go +++ b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/hook_payload_test.go @@ -1,7 +1,7 @@ package gogitlab import ( - "github.com/stretchr/testify/assert" + "github.com/drone/drone/Godeps/_workspace/src/github.com/stretchr/testify/assert" "io/ioutil" "testing" ) diff --git a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/hooks_test.go b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/hooks_test.go index 18ae7fc1f..0b9f79b6e 100644 --- a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/hooks_test.go +++ b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/hooks_test.go @@ -1,7 +1,7 @@ package gogitlab import ( - "github.com/stretchr/testify/assert" + "github.com/drone/drone/Godeps/_workspace/src/github.com/stretchr/testify/assert" "testing" ) diff --git a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/projects_test.go b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/projects_test.go index 56511ce5e..2484d6f48 100644 --- a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/projects_test.go +++ b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/projects_test.go @@ -1,7 +1,7 @@ package gogitlab import ( - "github.com/stretchr/testify/assert" + "github.com/drone/drone/Godeps/_workspace/src/github.com/stretchr/testify/assert" "testing" ) diff --git a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/public_keys_test.go b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/public_keys_test.go index d3be64a1f..03ded77cb 100644 --- a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/public_keys_test.go +++ b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/public_keys_test.go @@ -1,7 +1,7 @@ package gogitlab import ( - "github.com/stretchr/testify/assert" + "github.com/drone/drone/Godeps/_workspace/src/github.com/stretchr/testify/assert" "testing" ) diff --git a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/repositories_test.go b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/repositories_test.go index f009fb23f..ab445fbc5 100644 --- a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/repositories_test.go +++ b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/repositories_test.go @@ -1,7 +1,7 @@ package gogitlab import ( - "github.com/stretchr/testify/assert" + "github.com/drone/drone/Godeps/_workspace/src/github.com/stretchr/testify/assert" "testing" ) diff --git a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/session_test.go b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/session_test.go index 28665563b..05cd272df 100644 --- a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/session_test.go +++ b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/session_test.go @@ -1,7 +1,7 @@ package gogitlab import ( - "github.com/stretchr/testify/assert" + "github.com/drone/drone/Godeps/_workspace/src/github.com/stretchr/testify/assert" "testing" ) diff --git a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/users_test.go b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/users_test.go index 0102697a5..ef1cefbf7 100644 --- a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/users_test.go +++ b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/users_test.go @@ -1,7 +1,7 @@ package gogitlab import ( - "github.com/stretchr/testify/assert" + "github.com/drone/drone/Godeps/_workspace/src/github.com/stretchr/testify/assert" "testing" ) diff --git a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/util_test.go b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/util_test.go index fdaed9cd3..ea46535c7 100644 --- a/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/util_test.go +++ b/Godeps/_workspace/src/github.com/Bugagazavr/go-gitlab-client/util_test.go @@ -1,7 +1,7 @@ package gogitlab import ( - "github.com/stretchr/testify/assert" + "github.com/drone/drone/Godeps/_workspace/src/github.com/stretchr/testify/assert" "testing" ) diff --git a/Godeps/_workspace/src/github.com/docker/docker/pkg/units/duration.go b/Godeps/_workspace/src/github.com/docker/docker/pkg/units/duration.go new file mode 100644 index 000000000..44012aafb --- /dev/null +++ b/Godeps/_workspace/src/github.com/docker/docker/pkg/units/duration.go @@ -0,0 +1,31 @@ +package units + +import ( + "fmt" + "time" +) + +// HumanDuration returns a human-readable approximation of a duration +// (eg. "About a minute", "4 hours ago", etc.) +func HumanDuration(d time.Duration) string { + if seconds := int(d.Seconds()); seconds < 1 { + return "Less than a second" + } else if seconds < 60 { + return fmt.Sprintf("%d seconds", seconds) + } else if minutes := int(d.Minutes()); minutes == 1 { + return "About a minute" + } else if minutes < 60 { + return fmt.Sprintf("%d minutes", minutes) + } else if hours := int(d.Hours()); hours == 1 { + return "About an hour" + } else if hours < 48 { + return fmt.Sprintf("%d hours", hours) + } else if hours < 24*7*2 { + return fmt.Sprintf("%d days", hours/24) + } else if hours < 24*30*3 { + return fmt.Sprintf("%d weeks", hours/24/7) + } else if hours < 24*365*2 { + return fmt.Sprintf("%d months", hours/24/30) + } + return fmt.Sprintf("%d years", int(d.Hours())/24/365) +} diff --git a/Godeps/_workspace/src/github.com/docker/docker/pkg/units/duration_test.go b/Godeps/_workspace/src/github.com/docker/docker/pkg/units/duration_test.go new file mode 100644 index 000000000..fcfb6b7bb --- /dev/null +++ b/Godeps/_workspace/src/github.com/docker/docker/pkg/units/duration_test.go @@ -0,0 +1,46 @@ +package units + +import ( + "testing" + "time" +) + +func TestHumanDuration(t *testing.T) { + // Useful duration abstractions + day := 24 * time.Hour + week := 7 * day + month := 30 * day + year := 365 * day + + assertEquals(t, "Less than a second", HumanDuration(450*time.Millisecond)) + assertEquals(t, "47 seconds", HumanDuration(47*time.Second)) + assertEquals(t, "About a minute", HumanDuration(1*time.Minute)) + assertEquals(t, "3 minutes", HumanDuration(3*time.Minute)) + assertEquals(t, "35 minutes", HumanDuration(35*time.Minute)) + assertEquals(t, "35 minutes", HumanDuration(35*time.Minute+40*time.Second)) + assertEquals(t, "About an hour", HumanDuration(1*time.Hour)) + assertEquals(t, "About an hour", HumanDuration(1*time.Hour+45*time.Minute)) + assertEquals(t, "3 hours", HumanDuration(3*time.Hour)) + assertEquals(t, "3 hours", HumanDuration(3*time.Hour+59*time.Minute)) + assertEquals(t, "4 hours", HumanDuration(3*time.Hour+60*time.Minute)) + assertEquals(t, "24 hours", HumanDuration(24*time.Hour)) + assertEquals(t, "36 hours", HumanDuration(1*day+12*time.Hour)) + assertEquals(t, "2 days", HumanDuration(2*day)) + assertEquals(t, "7 days", HumanDuration(7*day)) + assertEquals(t, "13 days", HumanDuration(13*day+5*time.Hour)) + assertEquals(t, "2 weeks", HumanDuration(2*week)) + assertEquals(t, "2 weeks", HumanDuration(2*week+4*day)) + assertEquals(t, "3 weeks", HumanDuration(3*week)) + assertEquals(t, "4 weeks", HumanDuration(4*week)) + assertEquals(t, "4 weeks", HumanDuration(4*week+3*day)) + assertEquals(t, "4 weeks", HumanDuration(1*month)) + assertEquals(t, "6 weeks", HumanDuration(1*month+2*week)) + assertEquals(t, "8 weeks", HumanDuration(2*month)) + assertEquals(t, "3 months", HumanDuration(3*month+1*week)) + assertEquals(t, "5 months", HumanDuration(5*month+2*week)) + assertEquals(t, "13 months", HumanDuration(13*month)) + assertEquals(t, "23 months", HumanDuration(23*month)) + assertEquals(t, "24 months", HumanDuration(24*month)) + assertEquals(t, "2 years", HumanDuration(24*month+2*week)) + assertEquals(t, "3 years", HumanDuration(3*year+2*month)) +} diff --git a/Godeps/_workspace/src/github.com/docker/docker/pkg/units/size.go b/Godeps/_workspace/src/github.com/docker/docker/pkg/units/size.go new file mode 100644 index 000000000..9e84697ca --- /dev/null +++ b/Godeps/_workspace/src/github.com/docker/docker/pkg/units/size.go @@ -0,0 +1,93 @@ +package units + +import ( + "fmt" + "regexp" + "strconv" + "strings" +) + +// See: http://en.wikipedia.org/wiki/Binary_prefix +const ( + // Decimal + + KB = 1000 + MB = 1000 * KB + GB = 1000 * MB + TB = 1000 * GB + PB = 1000 * TB + + // Binary + + KiB = 1024 + MiB = 1024 * KiB + GiB = 1024 * MiB + TiB = 1024 * GiB + PiB = 1024 * TiB +) + +type unitMap map[string]int64 + +var ( + decimalMap = unitMap{"k": KB, "m": MB, "g": GB, "t": TB, "p": PB} + binaryMap = unitMap{"k": KiB, "m": MiB, "g": GiB, "t": TiB, "p": PiB} + sizeRegex = regexp.MustCompile(`^(\d+)([kKmMgGtTpP])?[bB]?$`) +) + +var decimapAbbrs = []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} +var binaryAbbrs = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"} + +// CustomSize returns a human-readable approximation of a size +// using custom format +func CustomSize(format string, size float64, base float64, _map []string) string { + i := 0 + for size >= base { + size = size / base + i++ + } + return fmt.Sprintf(format, size, _map[i]) +} + +// HumanSize returns a human-readable approximation of a size +// using SI standard (eg. "44kB", "17MB") +func HumanSize(size float64) string { + return CustomSize("%.4g %s", size, 1000.0, decimapAbbrs) +} + +func BytesSize(size float64) string { + return CustomSize("%.4g %s", size, 1024.0, binaryAbbrs) +} + +// FromHumanSize returns an integer from a human-readable specification of a +// size using SI standard (eg. "44kB", "17MB") +func FromHumanSize(size string) (int64, error) { + return parseSize(size, decimalMap) +} + +// RAMInBytes parses a human-readable string representing an amount of RAM +// in bytes, kibibytes, mebibytes, gibibytes, or tebibytes and +// returns the number of bytes, or -1 if the string is unparseable. +// Units are case-insensitive, and the 'b' suffix is optional. +func RAMInBytes(size string) (int64, error) { + return parseSize(size, binaryMap) +} + +// Parses the human-readable size string into the amount it represents +func parseSize(sizeStr string, uMap unitMap) (int64, error) { + matches := sizeRegex.FindStringSubmatch(sizeStr) + if len(matches) != 3 { + return -1, fmt.Errorf("invalid size: '%s'", sizeStr) + } + + size, err := strconv.ParseInt(matches[1], 10, 0) + if err != nil { + return -1, err + } + + unitPrefix := strings.ToLower(matches[2]) + if mul, ok := uMap[unitPrefix]; ok { + size *= mul + } + + return size, nil +} diff --git a/Godeps/_workspace/src/github.com/docker/docker/pkg/units/size_test.go b/Godeps/_workspace/src/github.com/docker/docker/pkg/units/size_test.go new file mode 100644 index 000000000..67c3b81e6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/docker/docker/pkg/units/size_test.go @@ -0,0 +1,108 @@ +package units + +import ( + "reflect" + "runtime" + "strings" + "testing" +) + +func TestBytesSize(t *testing.T) { + assertEquals(t, "1 KiB", BytesSize(1024)) + assertEquals(t, "1 MiB", BytesSize(1024*1024)) + assertEquals(t, "1 MiB", BytesSize(1048576)) + assertEquals(t, "2 MiB", BytesSize(2*MiB)) + assertEquals(t, "3.42 GiB", BytesSize(3.42*GiB)) + assertEquals(t, "5.372 TiB", BytesSize(5.372*TiB)) + assertEquals(t, "2.22 PiB", BytesSize(2.22*PiB)) +} + +func TestHumanSize(t *testing.T) { + assertEquals(t, "1 kB", HumanSize(1000)) + assertEquals(t, "1.024 kB", HumanSize(1024)) + assertEquals(t, "1 MB", HumanSize(1000000)) + assertEquals(t, "1.049 MB", HumanSize(1048576)) + assertEquals(t, "2 MB", HumanSize(2*MB)) + assertEquals(t, "3.42 GB", HumanSize(float64(3.42*GB))) + assertEquals(t, "5.372 TB", HumanSize(float64(5.372*TB))) + assertEquals(t, "2.22 PB", HumanSize(float64(2.22*PB))) +} + +func TestFromHumanSize(t *testing.T) { + assertSuccessEquals(t, 32, FromHumanSize, "32") + assertSuccessEquals(t, 32, FromHumanSize, "32b") + assertSuccessEquals(t, 32, FromHumanSize, "32B") + assertSuccessEquals(t, 32*KB, FromHumanSize, "32k") + assertSuccessEquals(t, 32*KB, FromHumanSize, "32K") + assertSuccessEquals(t, 32*KB, FromHumanSize, "32kb") + assertSuccessEquals(t, 32*KB, FromHumanSize, "32Kb") + assertSuccessEquals(t, 32*MB, FromHumanSize, "32Mb") + assertSuccessEquals(t, 32*GB, FromHumanSize, "32Gb") + assertSuccessEquals(t, 32*TB, FromHumanSize, "32Tb") + assertSuccessEquals(t, 32*PB, FromHumanSize, "32Pb") + + assertError(t, FromHumanSize, "") + assertError(t, FromHumanSize, "hello") + assertError(t, FromHumanSize, "-32") + assertError(t, FromHumanSize, "32.3") + assertError(t, FromHumanSize, " 32 ") + assertError(t, FromHumanSize, "32.3Kb") + assertError(t, FromHumanSize, "32 mb") + assertError(t, FromHumanSize, "32m b") + assertError(t, FromHumanSize, "32bm") +} + +func TestRAMInBytes(t *testing.T) { + assertSuccessEquals(t, 32, RAMInBytes, "32") + assertSuccessEquals(t, 32, RAMInBytes, "32b") + assertSuccessEquals(t, 32, RAMInBytes, "32B") + assertSuccessEquals(t, 32*KiB, RAMInBytes, "32k") + assertSuccessEquals(t, 32*KiB, RAMInBytes, "32K") + assertSuccessEquals(t, 32*KiB, RAMInBytes, "32kb") + assertSuccessEquals(t, 32*KiB, RAMInBytes, "32Kb") + assertSuccessEquals(t, 32*MiB, RAMInBytes, "32Mb") + assertSuccessEquals(t, 32*GiB, RAMInBytes, "32Gb") + assertSuccessEquals(t, 32*TiB, RAMInBytes, "32Tb") + assertSuccessEquals(t, 32*PiB, RAMInBytes, "32Pb") + assertSuccessEquals(t, 32*PiB, RAMInBytes, "32PB") + assertSuccessEquals(t, 32*PiB, RAMInBytes, "32P") + + assertError(t, RAMInBytes, "") + assertError(t, RAMInBytes, "hello") + assertError(t, RAMInBytes, "-32") + assertError(t, RAMInBytes, "32.3") + assertError(t, RAMInBytes, " 32 ") + assertError(t, RAMInBytes, "32.3Kb") + assertError(t, RAMInBytes, "32 mb") + assertError(t, RAMInBytes, "32m b") + assertError(t, RAMInBytes, "32bm") +} + +func assertEquals(t *testing.T, expected, actual interface{}) { + if expected != actual { + t.Errorf("Expected '%v' but got '%v'", expected, actual) + } +} + +// func that maps to the parse function signatures as testing abstraction +type parseFn func(string) (int64, error) + +// Define 'String()' for pretty-print +func (fn parseFn) String() string { + fnName := runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name() + return fnName[strings.LastIndex(fnName, ".")+1:] +} + +func assertSuccessEquals(t *testing.T, expected int64, fn parseFn, arg string) { + res, err := fn(arg) + if err != nil || res != expected { + t.Errorf("%s(\"%s\") -> expected '%d' but got '%d' with error '%v'", fn, arg, expected, res, err) + } +} + +func assertError(t *testing.T, fn parseFn, arg string) { + res, err := fn(arg) + if err == nil && res != -1 { + t.Errorf("%s(\"%s\") -> expected error but got '%d'", fn, arg, res) + } +} diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/README.md b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/README.md deleted file mode 100644 index 48505de83..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Guide to run Gin under App Engine LOCAL Development Server - -1. Download, install and setup Go in your computer. (That includes setting your `$GOPATH`.) -2. Download SDK for your platform from here: `https://developers.google.com/appengine/downloads?hl=es#Google_App_Engine_SDK_for_Go` -3. Download Gin source code using: `$ go get github.com/gin-gonic/gin` -4. Navigate to examples folder: `$ cd $GOPATH/src/github.com/gin-gonic/gin/examples/` -5. Run it: `$ goapp serve app-engine/` \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/app.yaml b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/app.yaml deleted file mode 100644 index 5f20cf3f2..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/app.yaml +++ /dev/null @@ -1,8 +0,0 @@ -application: hello -version: 1 -runtime: go -api_version: go1 - -handlers: -- url: /.* - script: _go_app \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/hello.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/hello.go deleted file mode 100644 index 6b82c726f..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/hello.go +++ /dev/null @@ -1,23 +0,0 @@ -package hello - -import ( - "github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin" - "net/http" -) - -// This function's name is a must. App Engine uses it to drive the requests properly. -func init() { - // Starts a new Gin instance with no middle-ware - r := gin.New() - - // Define your handlers - r.GET("/", func(c *gin.Context) { - c.String(200, "Hello World!") - }) - r.GET("/ping", func(c *gin.Context) { - c.String(200, "pong") - }) - - // Handle all requests using net/http - http.Handle("/", r) -} diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/example_basic.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/example_basic.go deleted file mode 100644 index e70fca839..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/example_basic.go +++ /dev/null @@ -1,56 +0,0 @@ -package main - -import ( - "github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin" -) - -var DB = make(map[string]string) - -func main() { - r := gin.Default() - - // Ping test - r.GET("/ping", func(c *gin.Context) { - c.String(200, "pong") - }) - - // Get user value - r.GET("/user/:name", func(c *gin.Context) { - user := c.Params.ByName("name") - value, ok := DB[user] - if ok { - c.JSON(200, gin.H{"user": user, "value": value}) - } else { - c.JSON(200, gin.H{"user": user, "status": "no value"}) - } - }) - - // Authorized group (uses gin.BasicAuth() middleware) - // Same than: - // authorized := r.Group("/") - // authorized.Use(gin.BasicAuth(gin.Credentials{ - // "foo": "bar", - // "manu": "123", - //})) - authorized := r.Group("/", gin.BasicAuth(gin.Accounts{ - "foo": "bar", // user:foo password:bar - "manu": "123", // user:manu password:123 - })) - - authorized.POST("admin", func(c *gin.Context) { - user := c.MustGet(gin.AuthUserKey).(string) - - // Parse JSON - var json struct { - Value string `json:"value" binding:"required"` - } - - if c.Bind(&json) { - DB[user] = json.Value - c.JSON(200, gin.H{"status": "ok"}) - } - }) - - // Listen and Server in 0.0.0.0:8080 - r.Run(":8080") -} diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/main.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/main.go deleted file mode 100644 index e8667236f..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/main.go +++ /dev/null @@ -1,39 +0,0 @@ -package main - -import ( - "fmt" - "runtime" - - "github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin" -) - -func main() { - ConfigRuntime() - StartWorkers() - StartGin() -} - -func ConfigRuntime() { - nuCPU := runtime.NumCPU() - runtime.GOMAXPROCS(nuCPU) - fmt.Printf("Running with %d CPUs\n", nuCPU) -} - -func StartWorkers() { - go statsWorker() -} - -func StartGin() { - gin.SetMode(gin.ReleaseMode) - - router := gin.New() - router.Use(rateLimit, gin.Recovery()) - router.LoadHTMLGlob("resources/*.templ.html") - router.Static("/static", "resources/static") - router.GET("/", index) - router.GET("/room/:roomid", roomGET) - router.POST("/room-post/:roomid", roomPOST) - router.GET("/stream/:roomid", streamRoom) - - router.Run(":80") -} diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/room_login.templ.html b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/room_login.templ.html deleted file mode 100644 index 27dac3879..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/room_login.templ.html +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - Server-Sent Events. Room "{{.roomid}}" - - - - - - - - - - - - - - - - - - - - - - - -
-
-

Server-Sent Events in Go

-

Server-sent events (SSE) is a technology where a browser receives automatic updates from a server via HTTP connection. It is not websockets. Learn more.

-

The chat and the charts data is provided in realtime using the SSE implemention of Gin Framework.

-
-
-
- - - - - - - - -
NickMessage
-
- {{if .nick}} -
-
- -
-
{{.nick}}
- -
-
- -
- {{else}} -
- Join the SSE real-time chat -
- -
-
- -
-
- {{end}} -
-
-
-

- ◼︎ Users
- ◼︎ Inbound messages / sec
- ◼︎ Outbound messages / sec
-

-
-
-
-
-
-
-

Realtime server Go stats

-
-

Memory usage

-

-

-

-

- ◼︎ Heap bytes
- ◼︎ Stack bytes
-

-
-
-

Allocations per second

-

-

-

-

- ◼︎ Mallocs / sec
- ◼︎ Frees / sec
-

-
-
-
-

MIT Open Sourced

- -
- -

Server-side (Go)

-
func streamRoom(c *gin.Context) {
-    roomid := c.ParamValue("roomid")
-    listener := openListener(roomid)
-    statsTicker := time.NewTicker(1 * time.Second)
-    defer closeListener(roomid, listener)
-    defer statsTicker.Stop()
-
-    c.Stream(func(w io.Writer) bool {
-        select {
-        case msg := <-listener:
-            c.SSEvent("message", msg)
-        case <-statsTicker.C:
-            c.SSEvent("stats", Stats())
-        }
-        return true
-    })
-}
-
-
-

Client-side (JS)

-
function StartSSE(roomid) {
-    var source = new EventSource('/stream/'+roomid);
-    source.addEventListener('message', newChatMessage, false);
-    source.addEventListener('stats', stats, false);
-}
-
-
-
-
-

SSE package

-
import "github.com/manucorporat/sse"
-
-func httpHandler(w http.ResponseWriter, req *http.Request) {
-    // data can be a primitive like a string, an integer or a float
-    sse.Encode(w, sse.Event{
-        Event: "message",
-        Data:  "some data\nmore data",
-    })
-
-    // also a complex type, like a map, a struct or a slice
-    sse.Encode(w, sse.Event{
-        Id:    "124",
-        Event: "message",
-        Data: map[string]interface{}{
-            "user":    "manu",
-            "date":    time.Now().Unix(),
-            "content": "hi!",
-        },
-    })
-}
-
event: message
-data: some data\\nmore data
-
-id: 124
-event: message
-data: {"content":"hi!","date":1431540810,"user":"manu"}
-
-
-
- -
- - diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/static/epoch.min.css b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/static/epoch.min.css deleted file mode 100644 index 47a80cdc2..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/static/epoch.min.css +++ /dev/null @@ -1 +0,0 @@ -.epoch .axis path,.epoch .axis line{shape-rendering:crispEdges;}.epoch .axis.canvas .tick line{shape-rendering:geometricPrecision;}div#_canvas_css_reference{width:0;height:0;position:absolute;top:-1000px;left:-1000px;}div#_canvas_css_reference svg{position:absolute;width:0;height:0;top:-1000px;left:-1000px;}.epoch{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:12pt;}.epoch .axis path,.epoch .axis line{fill:none;stroke:#000;}.epoch .axis .tick text{font-size:9pt;}.epoch .line{fill:none;stroke-width:2px;}.epoch.sparklines .line{stroke-width:1px;}.epoch .area{stroke:none;}.epoch .arc.pie{stroke:#fff;stroke-width:1.5px;}.epoch .arc.pie text{stroke:none;fill:white;font-size:9pt;}.epoch .gauge-labels .value{text-anchor:middle;font-size:140%;fill:#666;}.epoch.gauge-tiny{width:120px;height:90px;}.epoch.gauge-tiny .gauge-labels .value{font-size:80%;}.epoch.gauge-tiny .gauge .arc.outer{stroke-width:2px;}.epoch.gauge-small{width:180px;height:135px;}.epoch.gauge-small .gauge-labels .value{font-size:120%;}.epoch.gauge-small .gauge .arc.outer{stroke-width:3px;}.epoch.gauge-medium{width:240px;height:180px;}.epoch.gauge-medium .gauge .arc.outer{stroke-width:3px;}.epoch.gauge-large{width:320px;height:240px;}.epoch.gauge-large .gauge-labels .value{font-size:180%;}.epoch .gauge .arc.outer{stroke-width:4px;stroke:#666;}.epoch .gauge .arc.inner{stroke-width:1px;stroke:#555;}.epoch .gauge .tick{stroke-width:1px;stroke:#555;}.epoch .gauge .needle{fill:orange;}.epoch .gauge .needle-base{fill:#666;}.epoch div.ref.category1,.epoch.category10 div.ref.category1{background-color:#1f77b4;}.epoch .category1 .line,.epoch.category10 .category1 .line{stroke:#1f77b4;}.epoch .category1 .area,.epoch .category1 .dot,.epoch.category10 .category1 .area,.epoch.category10 .category1 .dot{fill:#1f77b4;stroke:rgba(0, 0, 0, 0);}.epoch .arc.category1 path,.epoch.category10 .arc.category1 path{fill:#1f77b4;}.epoch .bar.category1,.epoch.category10 .bar.category1{fill:#1f77b4;}.epoch div.ref.category2,.epoch.category10 div.ref.category2{background-color:#ff7f0e;}.epoch .category2 .line,.epoch.category10 .category2 .line{stroke:#ff7f0e;}.epoch .category2 .area,.epoch .category2 .dot,.epoch.category10 .category2 .area,.epoch.category10 .category2 .dot{fill:#ff7f0e;stroke:rgba(0, 0, 0, 0);}.epoch .arc.category2 path,.epoch.category10 .arc.category2 path{fill:#ff7f0e;}.epoch .bar.category2,.epoch.category10 .bar.category2{fill:#ff7f0e;}.epoch div.ref.category3,.epoch.category10 div.ref.category3{background-color:#2ca02c;}.epoch .category3 .line,.epoch.category10 .category3 .line{stroke:#2ca02c;}.epoch .category3 .area,.epoch .category3 .dot,.epoch.category10 .category3 .area,.epoch.category10 .category3 .dot{fill:#2ca02c;stroke:rgba(0, 0, 0, 0);}.epoch .arc.category3 path,.epoch.category10 .arc.category3 path{fill:#2ca02c;}.epoch .bar.category3,.epoch.category10 .bar.category3{fill:#2ca02c;}.epoch div.ref.category4,.epoch.category10 div.ref.category4{background-color:#d62728;}.epoch .category4 .line,.epoch.category10 .category4 .line{stroke:#d62728;}.epoch .category4 .area,.epoch .category4 .dot,.epoch.category10 .category4 .area,.epoch.category10 .category4 .dot{fill:#d62728;stroke:rgba(0, 0, 0, 0);}.epoch .arc.category4 path,.epoch.category10 .arc.category4 path{fill:#d62728;}.epoch .bar.category4,.epoch.category10 .bar.category4{fill:#d62728;}.epoch div.ref.category5,.epoch.category10 div.ref.category5{background-color:#9467bd;}.epoch .category5 .line,.epoch.category10 .category5 .line{stroke:#9467bd;}.epoch .category5 .area,.epoch .category5 .dot,.epoch.category10 .category5 .area,.epoch.category10 .category5 .dot{fill:#9467bd;stroke:rgba(0, 0, 0, 0);}.epoch .arc.category5 path,.epoch.category10 .arc.category5 path{fill:#9467bd;}.epoch .bar.category5,.epoch.category10 .bar.category5{fill:#9467bd;}.epoch div.ref.category6,.epoch.category10 div.ref.category6{background-color:#8c564b;}.epoch .category6 .line,.epoch.category10 .category6 .line{stroke:#8c564b;}.epoch .category6 .area,.epoch .category6 .dot,.epoch.category10 .category6 .area,.epoch.category10 .category6 .dot{fill:#8c564b;stroke:rgba(0, 0, 0, 0);}.epoch .arc.category6 path,.epoch.category10 .arc.category6 path{fill:#8c564b;}.epoch .bar.category6,.epoch.category10 .bar.category6{fill:#8c564b;}.epoch div.ref.category7,.epoch.category10 div.ref.category7{background-color:#e377c2;}.epoch .category7 .line,.epoch.category10 .category7 .line{stroke:#e377c2;}.epoch .category7 .area,.epoch .category7 .dot,.epoch.category10 .category7 .area,.epoch.category10 .category7 .dot{fill:#e377c2;stroke:rgba(0, 0, 0, 0);}.epoch .arc.category7 path,.epoch.category10 .arc.category7 path{fill:#e377c2;}.epoch .bar.category7,.epoch.category10 .bar.category7{fill:#e377c2;}.epoch div.ref.category8,.epoch.category10 div.ref.category8{background-color:#7f7f7f;}.epoch .category8 .line,.epoch.category10 .category8 .line{stroke:#7f7f7f;}.epoch .category8 .area,.epoch .category8 .dot,.epoch.category10 .category8 .area,.epoch.category10 .category8 .dot{fill:#7f7f7f;stroke:rgba(0, 0, 0, 0);}.epoch .arc.category8 path,.epoch.category10 .arc.category8 path{fill:#7f7f7f;}.epoch .bar.category8,.epoch.category10 .bar.category8{fill:#7f7f7f;}.epoch div.ref.category9,.epoch.category10 div.ref.category9{background-color:#bcbd22;}.epoch .category9 .line,.epoch.category10 .category9 .line{stroke:#bcbd22;}.epoch .category9 .area,.epoch .category9 .dot,.epoch.category10 .category9 .area,.epoch.category10 .category9 .dot{fill:#bcbd22;stroke:rgba(0, 0, 0, 0);}.epoch .arc.category9 path,.epoch.category10 .arc.category9 path{fill:#bcbd22;}.epoch .bar.category9,.epoch.category10 .bar.category9{fill:#bcbd22;}.epoch div.ref.category10,.epoch.category10 div.ref.category10{background-color:#17becf;}.epoch .category10 .line,.epoch.category10 .category10 .line{stroke:#17becf;}.epoch .category10 .area,.epoch .category10 .dot,.epoch.category10 .category10 .area,.epoch.category10 .category10 .dot{fill:#17becf;stroke:rgba(0, 0, 0, 0);}.epoch .arc.category10 path,.epoch.category10 .arc.category10 path{fill:#17becf;}.epoch .bar.category10,.epoch.category10 .bar.category10{fill:#17becf;}.epoch.category20 div.ref.category1{background-color:#1f77b4;}.epoch.category20 .category1 .line{stroke:#1f77b4;}.epoch.category20 .category1 .area,.epoch.category20 .category1 .dot{fill:#1f77b4;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category1 path{fill:#1f77b4;}.epoch.category20 .bar.category1{fill:#1f77b4;}.epoch.category20 div.ref.category2{background-color:#aec7e8;}.epoch.category20 .category2 .line{stroke:#aec7e8;}.epoch.category20 .category2 .area,.epoch.category20 .category2 .dot{fill:#aec7e8;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category2 path{fill:#aec7e8;}.epoch.category20 .bar.category2{fill:#aec7e8;}.epoch.category20 div.ref.category3{background-color:#ff7f0e;}.epoch.category20 .category3 .line{stroke:#ff7f0e;}.epoch.category20 .category3 .area,.epoch.category20 .category3 .dot{fill:#ff7f0e;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category3 path{fill:#ff7f0e;}.epoch.category20 .bar.category3{fill:#ff7f0e;}.epoch.category20 div.ref.category4{background-color:#ffbb78;}.epoch.category20 .category4 .line{stroke:#ffbb78;}.epoch.category20 .category4 .area,.epoch.category20 .category4 .dot{fill:#ffbb78;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category4 path{fill:#ffbb78;}.epoch.category20 .bar.category4{fill:#ffbb78;}.epoch.category20 div.ref.category5{background-color:#2ca02c;}.epoch.category20 .category5 .line{stroke:#2ca02c;}.epoch.category20 .category5 .area,.epoch.category20 .category5 .dot{fill:#2ca02c;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category5 path{fill:#2ca02c;}.epoch.category20 .bar.category5{fill:#2ca02c;}.epoch.category20 div.ref.category6{background-color:#98df8a;}.epoch.category20 .category6 .line{stroke:#98df8a;}.epoch.category20 .category6 .area,.epoch.category20 .category6 .dot{fill:#98df8a;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category6 path{fill:#98df8a;}.epoch.category20 .bar.category6{fill:#98df8a;}.epoch.category20 div.ref.category7{background-color:#d62728;}.epoch.category20 .category7 .line{stroke:#d62728;}.epoch.category20 .category7 .area,.epoch.category20 .category7 .dot{fill:#d62728;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category7 path{fill:#d62728;}.epoch.category20 .bar.category7{fill:#d62728;}.epoch.category20 div.ref.category8{background-color:#ff9896;}.epoch.category20 .category8 .line{stroke:#ff9896;}.epoch.category20 .category8 .area,.epoch.category20 .category8 .dot{fill:#ff9896;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category8 path{fill:#ff9896;}.epoch.category20 .bar.category8{fill:#ff9896;}.epoch.category20 div.ref.category9{background-color:#9467bd;}.epoch.category20 .category9 .line{stroke:#9467bd;}.epoch.category20 .category9 .area,.epoch.category20 .category9 .dot{fill:#9467bd;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category9 path{fill:#9467bd;}.epoch.category20 .bar.category9{fill:#9467bd;}.epoch.category20 div.ref.category10{background-color:#c5b0d5;}.epoch.category20 .category10 .line{stroke:#c5b0d5;}.epoch.category20 .category10 .area,.epoch.category20 .category10 .dot{fill:#c5b0d5;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category10 path{fill:#c5b0d5;}.epoch.category20 .bar.category10{fill:#c5b0d5;}.epoch.category20 div.ref.category11{background-color:#8c564b;}.epoch.category20 .category11 .line{stroke:#8c564b;}.epoch.category20 .category11 .area,.epoch.category20 .category11 .dot{fill:#8c564b;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category11 path{fill:#8c564b;}.epoch.category20 .bar.category11{fill:#8c564b;}.epoch.category20 div.ref.category12{background-color:#c49c94;}.epoch.category20 .category12 .line{stroke:#c49c94;}.epoch.category20 .category12 .area,.epoch.category20 .category12 .dot{fill:#c49c94;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category12 path{fill:#c49c94;}.epoch.category20 .bar.category12{fill:#c49c94;}.epoch.category20 div.ref.category13{background-color:#e377c2;}.epoch.category20 .category13 .line{stroke:#e377c2;}.epoch.category20 .category13 .area,.epoch.category20 .category13 .dot{fill:#e377c2;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category13 path{fill:#e377c2;}.epoch.category20 .bar.category13{fill:#e377c2;}.epoch.category20 div.ref.category14{background-color:#f7b6d2;}.epoch.category20 .category14 .line{stroke:#f7b6d2;}.epoch.category20 .category14 .area,.epoch.category20 .category14 .dot{fill:#f7b6d2;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category14 path{fill:#f7b6d2;}.epoch.category20 .bar.category14{fill:#f7b6d2;}.epoch.category20 div.ref.category15{background-color:#7f7f7f;}.epoch.category20 .category15 .line{stroke:#7f7f7f;}.epoch.category20 .category15 .area,.epoch.category20 .category15 .dot{fill:#7f7f7f;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category15 path{fill:#7f7f7f;}.epoch.category20 .bar.category15{fill:#7f7f7f;}.epoch.category20 div.ref.category16{background-color:#c7c7c7;}.epoch.category20 .category16 .line{stroke:#c7c7c7;}.epoch.category20 .category16 .area,.epoch.category20 .category16 .dot{fill:#c7c7c7;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category16 path{fill:#c7c7c7;}.epoch.category20 .bar.category16{fill:#c7c7c7;}.epoch.category20 div.ref.category17{background-color:#bcbd22;}.epoch.category20 .category17 .line{stroke:#bcbd22;}.epoch.category20 .category17 .area,.epoch.category20 .category17 .dot{fill:#bcbd22;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category17 path{fill:#bcbd22;}.epoch.category20 .bar.category17{fill:#bcbd22;}.epoch.category20 div.ref.category18{background-color:#dbdb8d;}.epoch.category20 .category18 .line{stroke:#dbdb8d;}.epoch.category20 .category18 .area,.epoch.category20 .category18 .dot{fill:#dbdb8d;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category18 path{fill:#dbdb8d;}.epoch.category20 .bar.category18{fill:#dbdb8d;}.epoch.category20 div.ref.category19{background-color:#17becf;}.epoch.category20 .category19 .line{stroke:#17becf;}.epoch.category20 .category19 .area,.epoch.category20 .category19 .dot{fill:#17becf;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category19 path{fill:#17becf;}.epoch.category20 .bar.category19{fill:#17becf;}.epoch.category20 div.ref.category20{background-color:#9edae5;}.epoch.category20 .category20 .line{stroke:#9edae5;}.epoch.category20 .category20 .area,.epoch.category20 .category20 .dot{fill:#9edae5;stroke:rgba(0, 0, 0, 0);}.epoch.category20 .arc.category20 path{fill:#9edae5;}.epoch.category20 .bar.category20{fill:#9edae5;}.epoch.category20b div.ref.category1{background-color:#393b79;}.epoch.category20b .category1 .line{stroke:#393b79;}.epoch.category20b .category1 .area,.epoch.category20b .category1 .dot{fill:#393b79;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category1 path{fill:#393b79;}.epoch.category20b .bar.category1{fill:#393b79;}.epoch.category20b div.ref.category2{background-color:#5254a3;}.epoch.category20b .category2 .line{stroke:#5254a3;}.epoch.category20b .category2 .area,.epoch.category20b .category2 .dot{fill:#5254a3;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category2 path{fill:#5254a3;}.epoch.category20b .bar.category2{fill:#5254a3;}.epoch.category20b div.ref.category3{background-color:#6b6ecf;}.epoch.category20b .category3 .line{stroke:#6b6ecf;}.epoch.category20b .category3 .area,.epoch.category20b .category3 .dot{fill:#6b6ecf;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category3 path{fill:#6b6ecf;}.epoch.category20b .bar.category3{fill:#6b6ecf;}.epoch.category20b div.ref.category4{background-color:#9c9ede;}.epoch.category20b .category4 .line{stroke:#9c9ede;}.epoch.category20b .category4 .area,.epoch.category20b .category4 .dot{fill:#9c9ede;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category4 path{fill:#9c9ede;}.epoch.category20b .bar.category4{fill:#9c9ede;}.epoch.category20b div.ref.category5{background-color:#637939;}.epoch.category20b .category5 .line{stroke:#637939;}.epoch.category20b .category5 .area,.epoch.category20b .category5 .dot{fill:#637939;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category5 path{fill:#637939;}.epoch.category20b .bar.category5{fill:#637939;}.epoch.category20b div.ref.category6{background-color:#8ca252;}.epoch.category20b .category6 .line{stroke:#8ca252;}.epoch.category20b .category6 .area,.epoch.category20b .category6 .dot{fill:#8ca252;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category6 path{fill:#8ca252;}.epoch.category20b .bar.category6{fill:#8ca252;}.epoch.category20b div.ref.category7{background-color:#b5cf6b;}.epoch.category20b .category7 .line{stroke:#b5cf6b;}.epoch.category20b .category7 .area,.epoch.category20b .category7 .dot{fill:#b5cf6b;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category7 path{fill:#b5cf6b;}.epoch.category20b .bar.category7{fill:#b5cf6b;}.epoch.category20b div.ref.category8{background-color:#cedb9c;}.epoch.category20b .category8 .line{stroke:#cedb9c;}.epoch.category20b .category8 .area,.epoch.category20b .category8 .dot{fill:#cedb9c;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category8 path{fill:#cedb9c;}.epoch.category20b .bar.category8{fill:#cedb9c;}.epoch.category20b div.ref.category9{background-color:#8c6d31;}.epoch.category20b .category9 .line{stroke:#8c6d31;}.epoch.category20b .category9 .area,.epoch.category20b .category9 .dot{fill:#8c6d31;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category9 path{fill:#8c6d31;}.epoch.category20b .bar.category9{fill:#8c6d31;}.epoch.category20b div.ref.category10{background-color:#bd9e39;}.epoch.category20b .category10 .line{stroke:#bd9e39;}.epoch.category20b .category10 .area,.epoch.category20b .category10 .dot{fill:#bd9e39;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category10 path{fill:#bd9e39;}.epoch.category20b .bar.category10{fill:#bd9e39;}.epoch.category20b div.ref.category11{background-color:#e7ba52;}.epoch.category20b .category11 .line{stroke:#e7ba52;}.epoch.category20b .category11 .area,.epoch.category20b .category11 .dot{fill:#e7ba52;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category11 path{fill:#e7ba52;}.epoch.category20b .bar.category11{fill:#e7ba52;}.epoch.category20b div.ref.category12{background-color:#e7cb94;}.epoch.category20b .category12 .line{stroke:#e7cb94;}.epoch.category20b .category12 .area,.epoch.category20b .category12 .dot{fill:#e7cb94;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category12 path{fill:#e7cb94;}.epoch.category20b .bar.category12{fill:#e7cb94;}.epoch.category20b div.ref.category13{background-color:#843c39;}.epoch.category20b .category13 .line{stroke:#843c39;}.epoch.category20b .category13 .area,.epoch.category20b .category13 .dot{fill:#843c39;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category13 path{fill:#843c39;}.epoch.category20b .bar.category13{fill:#843c39;}.epoch.category20b div.ref.category14{background-color:#ad494a;}.epoch.category20b .category14 .line{stroke:#ad494a;}.epoch.category20b .category14 .area,.epoch.category20b .category14 .dot{fill:#ad494a;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category14 path{fill:#ad494a;}.epoch.category20b .bar.category14{fill:#ad494a;}.epoch.category20b div.ref.category15{background-color:#d6616b;}.epoch.category20b .category15 .line{stroke:#d6616b;}.epoch.category20b .category15 .area,.epoch.category20b .category15 .dot{fill:#d6616b;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category15 path{fill:#d6616b;}.epoch.category20b .bar.category15{fill:#d6616b;}.epoch.category20b div.ref.category16{background-color:#e7969c;}.epoch.category20b .category16 .line{stroke:#e7969c;}.epoch.category20b .category16 .area,.epoch.category20b .category16 .dot{fill:#e7969c;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category16 path{fill:#e7969c;}.epoch.category20b .bar.category16{fill:#e7969c;}.epoch.category20b div.ref.category17{background-color:#7b4173;}.epoch.category20b .category17 .line{stroke:#7b4173;}.epoch.category20b .category17 .area,.epoch.category20b .category17 .dot{fill:#7b4173;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category17 path{fill:#7b4173;}.epoch.category20b .bar.category17{fill:#7b4173;}.epoch.category20b div.ref.category18{background-color:#a55194;}.epoch.category20b .category18 .line{stroke:#a55194;}.epoch.category20b .category18 .area,.epoch.category20b .category18 .dot{fill:#a55194;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category18 path{fill:#a55194;}.epoch.category20b .bar.category18{fill:#a55194;}.epoch.category20b div.ref.category19{background-color:#ce6dbd;}.epoch.category20b .category19 .line{stroke:#ce6dbd;}.epoch.category20b .category19 .area,.epoch.category20b .category19 .dot{fill:#ce6dbd;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category19 path{fill:#ce6dbd;}.epoch.category20b .bar.category19{fill:#ce6dbd;}.epoch.category20b div.ref.category20{background-color:#de9ed6;}.epoch.category20b .category20 .line{stroke:#de9ed6;}.epoch.category20b .category20 .area,.epoch.category20b .category20 .dot{fill:#de9ed6;stroke:rgba(0, 0, 0, 0);}.epoch.category20b .arc.category20 path{fill:#de9ed6;}.epoch.category20b .bar.category20{fill:#de9ed6;}.epoch.category20c div.ref.category1{background-color:#3182bd;}.epoch.category20c .category1 .line{stroke:#3182bd;}.epoch.category20c .category1 .area,.epoch.category20c .category1 .dot{fill:#3182bd;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category1 path{fill:#3182bd;}.epoch.category20c .bar.category1{fill:#3182bd;}.epoch.category20c div.ref.category2{background-color:#6baed6;}.epoch.category20c .category2 .line{stroke:#6baed6;}.epoch.category20c .category2 .area,.epoch.category20c .category2 .dot{fill:#6baed6;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category2 path{fill:#6baed6;}.epoch.category20c .bar.category2{fill:#6baed6;}.epoch.category20c div.ref.category3{background-color:#9ecae1;}.epoch.category20c .category3 .line{stroke:#9ecae1;}.epoch.category20c .category3 .area,.epoch.category20c .category3 .dot{fill:#9ecae1;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category3 path{fill:#9ecae1;}.epoch.category20c .bar.category3{fill:#9ecae1;}.epoch.category20c div.ref.category4{background-color:#c6dbef;}.epoch.category20c .category4 .line{stroke:#c6dbef;}.epoch.category20c .category4 .area,.epoch.category20c .category4 .dot{fill:#c6dbef;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category4 path{fill:#c6dbef;}.epoch.category20c .bar.category4{fill:#c6dbef;}.epoch.category20c div.ref.category5{background-color:#e6550d;}.epoch.category20c .category5 .line{stroke:#e6550d;}.epoch.category20c .category5 .area,.epoch.category20c .category5 .dot{fill:#e6550d;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category5 path{fill:#e6550d;}.epoch.category20c .bar.category5{fill:#e6550d;}.epoch.category20c div.ref.category6{background-color:#fd8d3c;}.epoch.category20c .category6 .line{stroke:#fd8d3c;}.epoch.category20c .category6 .area,.epoch.category20c .category6 .dot{fill:#fd8d3c;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category6 path{fill:#fd8d3c;}.epoch.category20c .bar.category6{fill:#fd8d3c;}.epoch.category20c div.ref.category7{background-color:#fdae6b;}.epoch.category20c .category7 .line{stroke:#fdae6b;}.epoch.category20c .category7 .area,.epoch.category20c .category7 .dot{fill:#fdae6b;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category7 path{fill:#fdae6b;}.epoch.category20c .bar.category7{fill:#fdae6b;}.epoch.category20c div.ref.category8{background-color:#fdd0a2;}.epoch.category20c .category8 .line{stroke:#fdd0a2;}.epoch.category20c .category8 .area,.epoch.category20c .category8 .dot{fill:#fdd0a2;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category8 path{fill:#fdd0a2;}.epoch.category20c .bar.category8{fill:#fdd0a2;}.epoch.category20c div.ref.category9{background-color:#31a354;}.epoch.category20c .category9 .line{stroke:#31a354;}.epoch.category20c .category9 .area,.epoch.category20c .category9 .dot{fill:#31a354;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category9 path{fill:#31a354;}.epoch.category20c .bar.category9{fill:#31a354;}.epoch.category20c div.ref.category10{background-color:#74c476;}.epoch.category20c .category10 .line{stroke:#74c476;}.epoch.category20c .category10 .area,.epoch.category20c .category10 .dot{fill:#74c476;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category10 path{fill:#74c476;}.epoch.category20c .bar.category10{fill:#74c476;}.epoch.category20c div.ref.category11{background-color:#a1d99b;}.epoch.category20c .category11 .line{stroke:#a1d99b;}.epoch.category20c .category11 .area,.epoch.category20c .category11 .dot{fill:#a1d99b;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category11 path{fill:#a1d99b;}.epoch.category20c .bar.category11{fill:#a1d99b;}.epoch.category20c div.ref.category12{background-color:#c7e9c0;}.epoch.category20c .category12 .line{stroke:#c7e9c0;}.epoch.category20c .category12 .area,.epoch.category20c .category12 .dot{fill:#c7e9c0;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category12 path{fill:#c7e9c0;}.epoch.category20c .bar.category12{fill:#c7e9c0;}.epoch.category20c div.ref.category13{background-color:#756bb1;}.epoch.category20c .category13 .line{stroke:#756bb1;}.epoch.category20c .category13 .area,.epoch.category20c .category13 .dot{fill:#756bb1;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category13 path{fill:#756bb1;}.epoch.category20c .bar.category13{fill:#756bb1;}.epoch.category20c div.ref.category14{background-color:#9e9ac8;}.epoch.category20c .category14 .line{stroke:#9e9ac8;}.epoch.category20c .category14 .area,.epoch.category20c .category14 .dot{fill:#9e9ac8;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category14 path{fill:#9e9ac8;}.epoch.category20c .bar.category14{fill:#9e9ac8;}.epoch.category20c div.ref.category15{background-color:#bcbddc;}.epoch.category20c .category15 .line{stroke:#bcbddc;}.epoch.category20c .category15 .area,.epoch.category20c .category15 .dot{fill:#bcbddc;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category15 path{fill:#bcbddc;}.epoch.category20c .bar.category15{fill:#bcbddc;}.epoch.category20c div.ref.category16{background-color:#dadaeb;}.epoch.category20c .category16 .line{stroke:#dadaeb;}.epoch.category20c .category16 .area,.epoch.category20c .category16 .dot{fill:#dadaeb;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category16 path{fill:#dadaeb;}.epoch.category20c .bar.category16{fill:#dadaeb;}.epoch.category20c div.ref.category17{background-color:#636363;}.epoch.category20c .category17 .line{stroke:#636363;}.epoch.category20c .category17 .area,.epoch.category20c .category17 .dot{fill:#636363;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category17 path{fill:#636363;}.epoch.category20c .bar.category17{fill:#636363;}.epoch.category20c div.ref.category18{background-color:#969696;}.epoch.category20c .category18 .line{stroke:#969696;}.epoch.category20c .category18 .area,.epoch.category20c .category18 .dot{fill:#969696;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category18 path{fill:#969696;}.epoch.category20c .bar.category18{fill:#969696;}.epoch.category20c div.ref.category19{background-color:#bdbdbd;}.epoch.category20c .category19 .line{stroke:#bdbdbd;}.epoch.category20c .category19 .area,.epoch.category20c .category19 .dot{fill:#bdbdbd;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category19 path{fill:#bdbdbd;}.epoch.category20c .bar.category19{fill:#bdbdbd;}.epoch.category20c div.ref.category20{background-color:#d9d9d9;}.epoch.category20c .category20 .line{stroke:#d9d9d9;}.epoch.category20c .category20 .area,.epoch.category20c .category20 .dot{fill:#d9d9d9;stroke:rgba(0, 0, 0, 0);}.epoch.category20c .arc.category20 path{fill:#d9d9d9;}.epoch.category20c .bar.category20{fill:#d9d9d9;}.epoch .category1 .bucket,.epoch.heatmap5 .category1 .bucket{fill:#1f77b4;}.epoch .category2 .bucket,.epoch.heatmap5 .category2 .bucket{fill:#2ca02c;}.epoch .category3 .bucket,.epoch.heatmap5 .category3 .bucket{fill:#d62728;}.epoch .category4 .bucket,.epoch.heatmap5 .category4 .bucket{fill:#8c564b;}.epoch .category5 .bucket,.epoch.heatmap5 .category5 .bucket{fill:#7f7f7f;}.epoch-theme-dark .epoch .axis path,.epoch-theme-dark .epoch .axis line{stroke:#d0d0d0;}.epoch-theme-dark .epoch .axis .tick text{fill:#d0d0d0;}.epoch-theme-dark .arc.pie{stroke:#333;}.epoch-theme-dark .arc.pie text{fill:#333;}.epoch-theme-dark .epoch .gauge-labels .value{fill:#BBB;}.epoch-theme-dark .epoch .gauge .arc.outer{stroke:#999;}.epoch-theme-dark .epoch .gauge .arc.inner{stroke:#AAA;}.epoch-theme-dark .epoch .gauge .tick{stroke:#AAA;}.epoch-theme-dark .epoch .gauge .needle{fill:#F3DE88;}.epoch-theme-dark .epoch .gauge .needle-base{fill:#999;}.epoch-theme-dark .epoch div.ref.category1,.epoch-theme-dark .epoch.category10 div.ref.category1{background-color:#909CFF;}.epoch-theme-dark .epoch .category1 .line,.epoch-theme-dark .epoch.category10 .category1 .line{stroke:#909CFF;}.epoch-theme-dark .epoch .category1 .area,.epoch-theme-dark .epoch .category1 .dot,.epoch-theme-dark .epoch.category10 .category1 .area,.epoch-theme-dark .epoch.category10 .category1 .dot{fill:#909CFF;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch .arc.category1 path,.epoch-theme-dark .epoch.category10 .arc.category1 path{fill:#909CFF;}.epoch-theme-dark .epoch .bar.category1,.epoch-theme-dark .epoch.category10 .bar.category1{fill:#909CFF;}.epoch-theme-dark .epoch div.ref.category2,.epoch-theme-dark .epoch.category10 div.ref.category2{background-color:#FFAC89;}.epoch-theme-dark .epoch .category2 .line,.epoch-theme-dark .epoch.category10 .category2 .line{stroke:#FFAC89;}.epoch-theme-dark .epoch .category2 .area,.epoch-theme-dark .epoch .category2 .dot,.epoch-theme-dark .epoch.category10 .category2 .area,.epoch-theme-dark .epoch.category10 .category2 .dot{fill:#FFAC89;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch .arc.category2 path,.epoch-theme-dark .epoch.category10 .arc.category2 path{fill:#FFAC89;}.epoch-theme-dark .epoch .bar.category2,.epoch-theme-dark .epoch.category10 .bar.category2{fill:#FFAC89;}.epoch-theme-dark .epoch div.ref.category3,.epoch-theme-dark .epoch.category10 div.ref.category3{background-color:#E889E8;}.epoch-theme-dark .epoch .category3 .line,.epoch-theme-dark .epoch.category10 .category3 .line{stroke:#E889E8;}.epoch-theme-dark .epoch .category3 .area,.epoch-theme-dark .epoch .category3 .dot,.epoch-theme-dark .epoch.category10 .category3 .area,.epoch-theme-dark .epoch.category10 .category3 .dot{fill:#E889E8;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch .arc.category3 path,.epoch-theme-dark .epoch.category10 .arc.category3 path{fill:#E889E8;}.epoch-theme-dark .epoch .bar.category3,.epoch-theme-dark .epoch.category10 .bar.category3{fill:#E889E8;}.epoch-theme-dark .epoch div.ref.category4,.epoch-theme-dark .epoch.category10 div.ref.category4{background-color:#78E8D3;}.epoch-theme-dark .epoch .category4 .line,.epoch-theme-dark .epoch.category10 .category4 .line{stroke:#78E8D3;}.epoch-theme-dark .epoch .category4 .area,.epoch-theme-dark .epoch .category4 .dot,.epoch-theme-dark .epoch.category10 .category4 .area,.epoch-theme-dark .epoch.category10 .category4 .dot{fill:#78E8D3;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch .arc.category4 path,.epoch-theme-dark .epoch.category10 .arc.category4 path{fill:#78E8D3;}.epoch-theme-dark .epoch .bar.category4,.epoch-theme-dark .epoch.category10 .bar.category4{fill:#78E8D3;}.epoch-theme-dark .epoch div.ref.category5,.epoch-theme-dark .epoch.category10 div.ref.category5{background-color:#C2FF97;}.epoch-theme-dark .epoch .category5 .line,.epoch-theme-dark .epoch.category10 .category5 .line{stroke:#C2FF97;}.epoch-theme-dark .epoch .category5 .area,.epoch-theme-dark .epoch .category5 .dot,.epoch-theme-dark .epoch.category10 .category5 .area,.epoch-theme-dark .epoch.category10 .category5 .dot{fill:#C2FF97;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch .arc.category5 path,.epoch-theme-dark .epoch.category10 .arc.category5 path{fill:#C2FF97;}.epoch-theme-dark .epoch .bar.category5,.epoch-theme-dark .epoch.category10 .bar.category5{fill:#C2FF97;}.epoch-theme-dark .epoch div.ref.category6,.epoch-theme-dark .epoch.category10 div.ref.category6{background-color:#B7BCD1;}.epoch-theme-dark .epoch .category6 .line,.epoch-theme-dark .epoch.category10 .category6 .line{stroke:#B7BCD1;}.epoch-theme-dark .epoch .category6 .area,.epoch-theme-dark .epoch .category6 .dot,.epoch-theme-dark .epoch.category10 .category6 .area,.epoch-theme-dark .epoch.category10 .category6 .dot{fill:#B7BCD1;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch .arc.category6 path,.epoch-theme-dark .epoch.category10 .arc.category6 path{fill:#B7BCD1;}.epoch-theme-dark .epoch .bar.category6,.epoch-theme-dark .epoch.category10 .bar.category6{fill:#B7BCD1;}.epoch-theme-dark .epoch div.ref.category7,.epoch-theme-dark .epoch.category10 div.ref.category7{background-color:#FF857F;}.epoch-theme-dark .epoch .category7 .line,.epoch-theme-dark .epoch.category10 .category7 .line{stroke:#FF857F;}.epoch-theme-dark .epoch .category7 .area,.epoch-theme-dark .epoch .category7 .dot,.epoch-theme-dark .epoch.category10 .category7 .area,.epoch-theme-dark .epoch.category10 .category7 .dot{fill:#FF857F;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch .arc.category7 path,.epoch-theme-dark .epoch.category10 .arc.category7 path{fill:#FF857F;}.epoch-theme-dark .epoch .bar.category7,.epoch-theme-dark .epoch.category10 .bar.category7{fill:#FF857F;}.epoch-theme-dark .epoch div.ref.category8,.epoch-theme-dark .epoch.category10 div.ref.category8{background-color:#F3DE88;}.epoch-theme-dark .epoch .category8 .line,.epoch-theme-dark .epoch.category10 .category8 .line{stroke:#F3DE88;}.epoch-theme-dark .epoch .category8 .area,.epoch-theme-dark .epoch .category8 .dot,.epoch-theme-dark .epoch.category10 .category8 .area,.epoch-theme-dark .epoch.category10 .category8 .dot{fill:#F3DE88;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch .arc.category8 path,.epoch-theme-dark .epoch.category10 .arc.category8 path{fill:#F3DE88;}.epoch-theme-dark .epoch .bar.category8,.epoch-theme-dark .epoch.category10 .bar.category8{fill:#F3DE88;}.epoch-theme-dark .epoch div.ref.category9,.epoch-theme-dark .epoch.category10 div.ref.category9{background-color:#C9935E;}.epoch-theme-dark .epoch .category9 .line,.epoch-theme-dark .epoch.category10 .category9 .line{stroke:#C9935E;}.epoch-theme-dark .epoch .category9 .area,.epoch-theme-dark .epoch .category9 .dot,.epoch-theme-dark .epoch.category10 .category9 .area,.epoch-theme-dark .epoch.category10 .category9 .dot{fill:#C9935E;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch .arc.category9 path,.epoch-theme-dark .epoch.category10 .arc.category9 path{fill:#C9935E;}.epoch-theme-dark .epoch .bar.category9,.epoch-theme-dark .epoch.category10 .bar.category9{fill:#C9935E;}.epoch-theme-dark .epoch div.ref.category10,.epoch-theme-dark .epoch.category10 div.ref.category10{background-color:#A488FF;}.epoch-theme-dark .epoch .category10 .line,.epoch-theme-dark .epoch.category10 .category10 .line{stroke:#A488FF;}.epoch-theme-dark .epoch .category10 .area,.epoch-theme-dark .epoch .category10 .dot,.epoch-theme-dark .epoch.category10 .category10 .area,.epoch-theme-dark .epoch.category10 .category10 .dot{fill:#A488FF;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch .arc.category10 path,.epoch-theme-dark .epoch.category10 .arc.category10 path{fill:#A488FF;}.epoch-theme-dark .epoch .bar.category10,.epoch-theme-dark .epoch.category10 .bar.category10{fill:#A488FF;}.epoch-theme-dark .epoch.category20 div.ref.category1{background-color:#909CFF;}.epoch-theme-dark .epoch.category20 .category1 .line{stroke:#909CFF;}.epoch-theme-dark .epoch.category20 .category1 .area,.epoch-theme-dark .epoch.category20 .category1 .dot{fill:#909CFF;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category1 path{fill:#909CFF;}.epoch-theme-dark .epoch.category20 .bar.category1{fill:#909CFF;}.epoch-theme-dark .epoch.category20 div.ref.category2{background-color:#626AAD;}.epoch-theme-dark .epoch.category20 .category2 .line{stroke:#626AAD;}.epoch-theme-dark .epoch.category20 .category2 .area,.epoch-theme-dark .epoch.category20 .category2 .dot{fill:#626AAD;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category2 path{fill:#626AAD;}.epoch-theme-dark .epoch.category20 .bar.category2{fill:#626AAD;}.epoch-theme-dark .epoch.category20 div.ref.category3{background-color:#FFAC89;}.epoch-theme-dark .epoch.category20 .category3 .line{stroke:#FFAC89;}.epoch-theme-dark .epoch.category20 .category3 .area,.epoch-theme-dark .epoch.category20 .category3 .dot{fill:#FFAC89;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category3 path{fill:#FFAC89;}.epoch-theme-dark .epoch.category20 .bar.category3{fill:#FFAC89;}.epoch-theme-dark .epoch.category20 div.ref.category4{background-color:#BD7F66;}.epoch-theme-dark .epoch.category20 .category4 .line{stroke:#BD7F66;}.epoch-theme-dark .epoch.category20 .category4 .area,.epoch-theme-dark .epoch.category20 .category4 .dot{fill:#BD7F66;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category4 path{fill:#BD7F66;}.epoch-theme-dark .epoch.category20 .bar.category4{fill:#BD7F66;}.epoch-theme-dark .epoch.category20 div.ref.category5{background-color:#E889E8;}.epoch-theme-dark .epoch.category20 .category5 .line{stroke:#E889E8;}.epoch-theme-dark .epoch.category20 .category5 .area,.epoch-theme-dark .epoch.category20 .category5 .dot{fill:#E889E8;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category5 path{fill:#E889E8;}.epoch-theme-dark .epoch.category20 .bar.category5{fill:#E889E8;}.epoch-theme-dark .epoch.category20 div.ref.category6{background-color:#995A99;}.epoch-theme-dark .epoch.category20 .category6 .line{stroke:#995A99;}.epoch-theme-dark .epoch.category20 .category6 .area,.epoch-theme-dark .epoch.category20 .category6 .dot{fill:#995A99;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category6 path{fill:#995A99;}.epoch-theme-dark .epoch.category20 .bar.category6{fill:#995A99;}.epoch-theme-dark .epoch.category20 div.ref.category7{background-color:#78E8D3;}.epoch-theme-dark .epoch.category20 .category7 .line{stroke:#78E8D3;}.epoch-theme-dark .epoch.category20 .category7 .area,.epoch-theme-dark .epoch.category20 .category7 .dot{fill:#78E8D3;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category7 path{fill:#78E8D3;}.epoch-theme-dark .epoch.category20 .bar.category7{fill:#78E8D3;}.epoch-theme-dark .epoch.category20 div.ref.category8{background-color:#4F998C;}.epoch-theme-dark .epoch.category20 .category8 .line{stroke:#4F998C;}.epoch-theme-dark .epoch.category20 .category8 .area,.epoch-theme-dark .epoch.category20 .category8 .dot{fill:#4F998C;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category8 path{fill:#4F998C;}.epoch-theme-dark .epoch.category20 .bar.category8{fill:#4F998C;}.epoch-theme-dark .epoch.category20 div.ref.category9{background-color:#C2FF97;}.epoch-theme-dark .epoch.category20 .category9 .line{stroke:#C2FF97;}.epoch-theme-dark .epoch.category20 .category9 .area,.epoch-theme-dark .epoch.category20 .category9 .dot{fill:#C2FF97;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category9 path{fill:#C2FF97;}.epoch-theme-dark .epoch.category20 .bar.category9{fill:#C2FF97;}.epoch-theme-dark .epoch.category20 div.ref.category10{background-color:#789E5E;}.epoch-theme-dark .epoch.category20 .category10 .line{stroke:#789E5E;}.epoch-theme-dark .epoch.category20 .category10 .area,.epoch-theme-dark .epoch.category20 .category10 .dot{fill:#789E5E;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category10 path{fill:#789E5E;}.epoch-theme-dark .epoch.category20 .bar.category10{fill:#789E5E;}.epoch-theme-dark .epoch.category20 div.ref.category11{background-color:#B7BCD1;}.epoch-theme-dark .epoch.category20 .category11 .line{stroke:#B7BCD1;}.epoch-theme-dark .epoch.category20 .category11 .area,.epoch-theme-dark .epoch.category20 .category11 .dot{fill:#B7BCD1;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category11 path{fill:#B7BCD1;}.epoch-theme-dark .epoch.category20 .bar.category11{fill:#B7BCD1;}.epoch-theme-dark .epoch.category20 div.ref.category12{background-color:#7F8391;}.epoch-theme-dark .epoch.category20 .category12 .line{stroke:#7F8391;}.epoch-theme-dark .epoch.category20 .category12 .area,.epoch-theme-dark .epoch.category20 .category12 .dot{fill:#7F8391;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category12 path{fill:#7F8391;}.epoch-theme-dark .epoch.category20 .bar.category12{fill:#7F8391;}.epoch-theme-dark .epoch.category20 div.ref.category13{background-color:#CCB889;}.epoch-theme-dark .epoch.category20 .category13 .line{stroke:#CCB889;}.epoch-theme-dark .epoch.category20 .category13 .area,.epoch-theme-dark .epoch.category20 .category13 .dot{fill:#CCB889;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category13 path{fill:#CCB889;}.epoch-theme-dark .epoch.category20 .bar.category13{fill:#CCB889;}.epoch-theme-dark .epoch.category20 div.ref.category14{background-color:#A1906B;}.epoch-theme-dark .epoch.category20 .category14 .line{stroke:#A1906B;}.epoch-theme-dark .epoch.category20 .category14 .area,.epoch-theme-dark .epoch.category20 .category14 .dot{fill:#A1906B;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category14 path{fill:#A1906B;}.epoch-theme-dark .epoch.category20 .bar.category14{fill:#A1906B;}.epoch-theme-dark .epoch.category20 div.ref.category15{background-color:#F3DE88;}.epoch-theme-dark .epoch.category20 .category15 .line{stroke:#F3DE88;}.epoch-theme-dark .epoch.category20 .category15 .area,.epoch-theme-dark .epoch.category20 .category15 .dot{fill:#F3DE88;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category15 path{fill:#F3DE88;}.epoch-theme-dark .epoch.category20 .bar.category15{fill:#F3DE88;}.epoch-theme-dark .epoch.category20 div.ref.category16{background-color:#A89A5E;}.epoch-theme-dark .epoch.category20 .category16 .line{stroke:#A89A5E;}.epoch-theme-dark .epoch.category20 .category16 .area,.epoch-theme-dark .epoch.category20 .category16 .dot{fill:#A89A5E;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category16 path{fill:#A89A5E;}.epoch-theme-dark .epoch.category20 .bar.category16{fill:#A89A5E;}.epoch-theme-dark .epoch.category20 div.ref.category17{background-color:#FF857F;}.epoch-theme-dark .epoch.category20 .category17 .line{stroke:#FF857F;}.epoch-theme-dark .epoch.category20 .category17 .area,.epoch-theme-dark .epoch.category20 .category17 .dot{fill:#FF857F;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category17 path{fill:#FF857F;}.epoch-theme-dark .epoch.category20 .bar.category17{fill:#FF857F;}.epoch-theme-dark .epoch.category20 div.ref.category18{background-color:#BA615D;}.epoch-theme-dark .epoch.category20 .category18 .line{stroke:#BA615D;}.epoch-theme-dark .epoch.category20 .category18 .area,.epoch-theme-dark .epoch.category20 .category18 .dot{fill:#BA615D;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category18 path{fill:#BA615D;}.epoch-theme-dark .epoch.category20 .bar.category18{fill:#BA615D;}.epoch-theme-dark .epoch.category20 div.ref.category19{background-color:#A488FF;}.epoch-theme-dark .epoch.category20 .category19 .line{stroke:#A488FF;}.epoch-theme-dark .epoch.category20 .category19 .area,.epoch-theme-dark .epoch.category20 .category19 .dot{fill:#A488FF;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category19 path{fill:#A488FF;}.epoch-theme-dark .epoch.category20 .bar.category19{fill:#A488FF;}.epoch-theme-dark .epoch.category20 div.ref.category20{background-color:#7662B8;}.epoch-theme-dark .epoch.category20 .category20 .line{stroke:#7662B8;}.epoch-theme-dark .epoch.category20 .category20 .area,.epoch-theme-dark .epoch.category20 .category20 .dot{fill:#7662B8;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20 .arc.category20 path{fill:#7662B8;}.epoch-theme-dark .epoch.category20 .bar.category20{fill:#7662B8;}.epoch-theme-dark .epoch.category20b div.ref.category1{background-color:#909CFF;}.epoch-theme-dark .epoch.category20b .category1 .line{stroke:#909CFF;}.epoch-theme-dark .epoch.category20b .category1 .area,.epoch-theme-dark .epoch.category20b .category1 .dot{fill:#909CFF;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category1 path{fill:#909CFF;}.epoch-theme-dark .epoch.category20b .bar.category1{fill:#909CFF;}.epoch-theme-dark .epoch.category20b div.ref.category2{background-color:#7680D1;}.epoch-theme-dark .epoch.category20b .category2 .line{stroke:#7680D1;}.epoch-theme-dark .epoch.category20b .category2 .area,.epoch-theme-dark .epoch.category20b .category2 .dot{fill:#7680D1;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category2 path{fill:#7680D1;}.epoch-theme-dark .epoch.category20b .bar.category2{fill:#7680D1;}.epoch-theme-dark .epoch.category20b div.ref.category3{background-color:#656DB2;}.epoch-theme-dark .epoch.category20b .category3 .line{stroke:#656DB2;}.epoch-theme-dark .epoch.category20b .category3 .area,.epoch-theme-dark .epoch.category20b .category3 .dot{fill:#656DB2;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category3 path{fill:#656DB2;}.epoch-theme-dark .epoch.category20b .bar.category3{fill:#656DB2;}.epoch-theme-dark .epoch.category20b div.ref.category4{background-color:#525992;}.epoch-theme-dark .epoch.category20b .category4 .line{stroke:#525992;}.epoch-theme-dark .epoch.category20b .category4 .area,.epoch-theme-dark .epoch.category20b .category4 .dot{fill:#525992;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category4 path{fill:#525992;}.epoch-theme-dark .epoch.category20b .bar.category4{fill:#525992;}.epoch-theme-dark .epoch.category20b div.ref.category5{background-color:#FFAC89;}.epoch-theme-dark .epoch.category20b .category5 .line{stroke:#FFAC89;}.epoch-theme-dark .epoch.category20b .category5 .area,.epoch-theme-dark .epoch.category20b .category5 .dot{fill:#FFAC89;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category5 path{fill:#FFAC89;}.epoch-theme-dark .epoch.category20b .bar.category5{fill:#FFAC89;}.epoch-theme-dark .epoch.category20b div.ref.category6{background-color:#D18D71;}.epoch-theme-dark .epoch.category20b .category6 .line{stroke:#D18D71;}.epoch-theme-dark .epoch.category20b .category6 .area,.epoch-theme-dark .epoch.category20b .category6 .dot{fill:#D18D71;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category6 path{fill:#D18D71;}.epoch-theme-dark .epoch.category20b .bar.category6{fill:#D18D71;}.epoch-theme-dark .epoch.category20b div.ref.category7{background-color:#AB735C;}.epoch-theme-dark .epoch.category20b .category7 .line{stroke:#AB735C;}.epoch-theme-dark .epoch.category20b .category7 .area,.epoch-theme-dark .epoch.category20b .category7 .dot{fill:#AB735C;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category7 path{fill:#AB735C;}.epoch-theme-dark .epoch.category20b .bar.category7{fill:#AB735C;}.epoch-theme-dark .epoch.category20b div.ref.category8{background-color:#92624E;}.epoch-theme-dark .epoch.category20b .category8 .line{stroke:#92624E;}.epoch-theme-dark .epoch.category20b .category8 .area,.epoch-theme-dark .epoch.category20b .category8 .dot{fill:#92624E;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category8 path{fill:#92624E;}.epoch-theme-dark .epoch.category20b .bar.category8{fill:#92624E;}.epoch-theme-dark .epoch.category20b div.ref.category9{background-color:#E889E8;}.epoch-theme-dark .epoch.category20b .category9 .line{stroke:#E889E8;}.epoch-theme-dark .epoch.category20b .category9 .area,.epoch-theme-dark .epoch.category20b .category9 .dot{fill:#E889E8;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category9 path{fill:#E889E8;}.epoch-theme-dark .epoch.category20b .bar.category9{fill:#E889E8;}.epoch-theme-dark .epoch.category20b div.ref.category10{background-color:#BA6EBA;}.epoch-theme-dark .epoch.category20b .category10 .line{stroke:#BA6EBA;}.epoch-theme-dark .epoch.category20b .category10 .area,.epoch-theme-dark .epoch.category20b .category10 .dot{fill:#BA6EBA;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category10 path{fill:#BA6EBA;}.epoch-theme-dark .epoch.category20b .bar.category10{fill:#BA6EBA;}.epoch-theme-dark .epoch.category20b div.ref.category11{background-color:#9B5C9B;}.epoch-theme-dark .epoch.category20b .category11 .line{stroke:#9B5C9B;}.epoch-theme-dark .epoch.category20b .category11 .area,.epoch-theme-dark .epoch.category20b .category11 .dot{fill:#9B5C9B;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category11 path{fill:#9B5C9B;}.epoch-theme-dark .epoch.category20b .bar.category11{fill:#9B5C9B;}.epoch-theme-dark .epoch.category20b div.ref.category12{background-color:#7B487B;}.epoch-theme-dark .epoch.category20b .category12 .line{stroke:#7B487B;}.epoch-theme-dark .epoch.category20b .category12 .area,.epoch-theme-dark .epoch.category20b .category12 .dot{fill:#7B487B;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category12 path{fill:#7B487B;}.epoch-theme-dark .epoch.category20b .bar.category12{fill:#7B487B;}.epoch-theme-dark .epoch.category20b div.ref.category13{background-color:#78E8D3;}.epoch-theme-dark .epoch.category20b .category13 .line{stroke:#78E8D3;}.epoch-theme-dark .epoch.category20b .category13 .area,.epoch-theme-dark .epoch.category20b .category13 .dot{fill:#78E8D3;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category13 path{fill:#78E8D3;}.epoch-theme-dark .epoch.category20b .bar.category13{fill:#78E8D3;}.epoch-theme-dark .epoch.category20b div.ref.category14{background-color:#60BAAA;}.epoch-theme-dark .epoch.category20b .category14 .line{stroke:#60BAAA;}.epoch-theme-dark .epoch.category20b .category14 .area,.epoch-theme-dark .epoch.category20b .category14 .dot{fill:#60BAAA;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category14 path{fill:#60BAAA;}.epoch-theme-dark .epoch.category20b .bar.category14{fill:#60BAAA;}.epoch-theme-dark .epoch.category20b div.ref.category15{background-color:#509B8D;}.epoch-theme-dark .epoch.category20b .category15 .line{stroke:#509B8D;}.epoch-theme-dark .epoch.category20b .category15 .area,.epoch-theme-dark .epoch.category20b .category15 .dot{fill:#509B8D;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category15 path{fill:#509B8D;}.epoch-theme-dark .epoch.category20b .bar.category15{fill:#509B8D;}.epoch-theme-dark .epoch.category20b div.ref.category16{background-color:#3F7B70;}.epoch-theme-dark .epoch.category20b .category16 .line{stroke:#3F7B70;}.epoch-theme-dark .epoch.category20b .category16 .area,.epoch-theme-dark .epoch.category20b .category16 .dot{fill:#3F7B70;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category16 path{fill:#3F7B70;}.epoch-theme-dark .epoch.category20b .bar.category16{fill:#3F7B70;}.epoch-theme-dark .epoch.category20b div.ref.category17{background-color:#C2FF97;}.epoch-theme-dark .epoch.category20b .category17 .line{stroke:#C2FF97;}.epoch-theme-dark .epoch.category20b .category17 .area,.epoch-theme-dark .epoch.category20b .category17 .dot{fill:#C2FF97;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category17 path{fill:#C2FF97;}.epoch-theme-dark .epoch.category20b .bar.category17{fill:#C2FF97;}.epoch-theme-dark .epoch.category20b div.ref.category18{background-color:#9FD17C;}.epoch-theme-dark .epoch.category20b .category18 .line{stroke:#9FD17C;}.epoch-theme-dark .epoch.category20b .category18 .area,.epoch-theme-dark .epoch.category20b .category18 .dot{fill:#9FD17C;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category18 path{fill:#9FD17C;}.epoch-theme-dark .epoch.category20b .bar.category18{fill:#9FD17C;}.epoch-theme-dark .epoch.category20b div.ref.category19{background-color:#7DA361;}.epoch-theme-dark .epoch.category20b .category19 .line{stroke:#7DA361;}.epoch-theme-dark .epoch.category20b .category19 .area,.epoch-theme-dark .epoch.category20b .category19 .dot{fill:#7DA361;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category19 path{fill:#7DA361;}.epoch-theme-dark .epoch.category20b .bar.category19{fill:#7DA361;}.epoch-theme-dark .epoch.category20b div.ref.category20{background-color:#65854E;}.epoch-theme-dark .epoch.category20b .category20 .line{stroke:#65854E;}.epoch-theme-dark .epoch.category20b .category20 .area,.epoch-theme-dark .epoch.category20b .category20 .dot{fill:#65854E;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20b .arc.category20 path{fill:#65854E;}.epoch-theme-dark .epoch.category20b .bar.category20{fill:#65854E;}.epoch-theme-dark .epoch.category20c div.ref.category1{background-color:#B7BCD1;}.epoch-theme-dark .epoch.category20c .category1 .line{stroke:#B7BCD1;}.epoch-theme-dark .epoch.category20c .category1 .area,.epoch-theme-dark .epoch.category20c .category1 .dot{fill:#B7BCD1;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category1 path{fill:#B7BCD1;}.epoch-theme-dark .epoch.category20c .bar.category1{fill:#B7BCD1;}.epoch-theme-dark .epoch.category20c div.ref.category2{background-color:#979DAD;}.epoch-theme-dark .epoch.category20c .category2 .line{stroke:#979DAD;}.epoch-theme-dark .epoch.category20c .category2 .area,.epoch-theme-dark .epoch.category20c .category2 .dot{fill:#979DAD;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category2 path{fill:#979DAD;}.epoch-theme-dark .epoch.category20c .bar.category2{fill:#979DAD;}.epoch-theme-dark .epoch.category20c div.ref.category3{background-color:#6E717D;}.epoch-theme-dark .epoch.category20c .category3 .line{stroke:#6E717D;}.epoch-theme-dark .epoch.category20c .category3 .area,.epoch-theme-dark .epoch.category20c .category3 .dot{fill:#6E717D;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category3 path{fill:#6E717D;}.epoch-theme-dark .epoch.category20c .bar.category3{fill:#6E717D;}.epoch-theme-dark .epoch.category20c div.ref.category4{background-color:#595C66;}.epoch-theme-dark .epoch.category20c .category4 .line{stroke:#595C66;}.epoch-theme-dark .epoch.category20c .category4 .area,.epoch-theme-dark .epoch.category20c .category4 .dot{fill:#595C66;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category4 path{fill:#595C66;}.epoch-theme-dark .epoch.category20c .bar.category4{fill:#595C66;}.epoch-theme-dark .epoch.category20c div.ref.category5{background-color:#FF857F;}.epoch-theme-dark .epoch.category20c .category5 .line{stroke:#FF857F;}.epoch-theme-dark .epoch.category20c .category5 .area,.epoch-theme-dark .epoch.category20c .category5 .dot{fill:#FF857F;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category5 path{fill:#FF857F;}.epoch-theme-dark .epoch.category20c .bar.category5{fill:#FF857F;}.epoch-theme-dark .epoch.category20c div.ref.category6{background-color:#DE746E;}.epoch-theme-dark .epoch.category20c .category6 .line{stroke:#DE746E;}.epoch-theme-dark .epoch.category20c .category6 .area,.epoch-theme-dark .epoch.category20c .category6 .dot{fill:#DE746E;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category6 path{fill:#DE746E;}.epoch-theme-dark .epoch.category20c .bar.category6{fill:#DE746E;}.epoch-theme-dark .epoch.category20c div.ref.category7{background-color:#B55F5A;}.epoch-theme-dark .epoch.category20c .category7 .line{stroke:#B55F5A;}.epoch-theme-dark .epoch.category20c .category7 .area,.epoch-theme-dark .epoch.category20c .category7 .dot{fill:#B55F5A;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category7 path{fill:#B55F5A;}.epoch-theme-dark .epoch.category20c .bar.category7{fill:#B55F5A;}.epoch-theme-dark .epoch.category20c div.ref.category8{background-color:#964E4B;}.epoch-theme-dark .epoch.category20c .category8 .line{stroke:#964E4B;}.epoch-theme-dark .epoch.category20c .category8 .area,.epoch-theme-dark .epoch.category20c .category8 .dot{fill:#964E4B;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category8 path{fill:#964E4B;}.epoch-theme-dark .epoch.category20c .bar.category8{fill:#964E4B;}.epoch-theme-dark .epoch.category20c div.ref.category9{background-color:#F3DE88;}.epoch-theme-dark .epoch.category20c .category9 .line{stroke:#F3DE88;}.epoch-theme-dark .epoch.category20c .category9 .area,.epoch-theme-dark .epoch.category20c .category9 .dot{fill:#F3DE88;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category9 path{fill:#F3DE88;}.epoch-theme-dark .epoch.category20c .bar.category9{fill:#F3DE88;}.epoch-theme-dark .epoch.category20c div.ref.category10{background-color:#DBC87B;}.epoch-theme-dark .epoch.category20c .category10 .line{stroke:#DBC87B;}.epoch-theme-dark .epoch.category20c .category10 .area,.epoch-theme-dark .epoch.category20c .category10 .dot{fill:#DBC87B;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category10 path{fill:#DBC87B;}.epoch-theme-dark .epoch.category20c .bar.category10{fill:#DBC87B;}.epoch-theme-dark .epoch.category20c div.ref.category11{background-color:#BAAA68;}.epoch-theme-dark .epoch.category20c .category11 .line{stroke:#BAAA68;}.epoch-theme-dark .epoch.category20c .category11 .area,.epoch-theme-dark .epoch.category20c .category11 .dot{fill:#BAAA68;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category11 path{fill:#BAAA68;}.epoch-theme-dark .epoch.category20c .bar.category11{fill:#BAAA68;}.epoch-theme-dark .epoch.category20c div.ref.category12{background-color:#918551;}.epoch-theme-dark .epoch.category20c .category12 .line{stroke:#918551;}.epoch-theme-dark .epoch.category20c .category12 .area,.epoch-theme-dark .epoch.category20c .category12 .dot{fill:#918551;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category12 path{fill:#918551;}.epoch-theme-dark .epoch.category20c .bar.category12{fill:#918551;}.epoch-theme-dark .epoch.category20c div.ref.category13{background-color:#C9935E;}.epoch-theme-dark .epoch.category20c .category13 .line{stroke:#C9935E;}.epoch-theme-dark .epoch.category20c .category13 .area,.epoch-theme-dark .epoch.category20c .category13 .dot{fill:#C9935E;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category13 path{fill:#C9935E;}.epoch-theme-dark .epoch.category20c .bar.category13{fill:#C9935E;}.epoch-theme-dark .epoch.category20c div.ref.category14{background-color:#B58455;}.epoch-theme-dark .epoch.category20c .category14 .line{stroke:#B58455;}.epoch-theme-dark .epoch.category20c .category14 .area,.epoch-theme-dark .epoch.category20c .category14 .dot{fill:#B58455;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category14 path{fill:#B58455;}.epoch-theme-dark .epoch.category20c .bar.category14{fill:#B58455;}.epoch-theme-dark .epoch.category20c div.ref.category15{background-color:#997048;}.epoch-theme-dark .epoch.category20c .category15 .line{stroke:#997048;}.epoch-theme-dark .epoch.category20c .category15 .area,.epoch-theme-dark .epoch.category20c .category15 .dot{fill:#997048;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category15 path{fill:#997048;}.epoch-theme-dark .epoch.category20c .bar.category15{fill:#997048;}.epoch-theme-dark .epoch.category20c div.ref.category16{background-color:#735436;}.epoch-theme-dark .epoch.category20c .category16 .line{stroke:#735436;}.epoch-theme-dark .epoch.category20c .category16 .area,.epoch-theme-dark .epoch.category20c .category16 .dot{fill:#735436;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category16 path{fill:#735436;}.epoch-theme-dark .epoch.category20c .bar.category16{fill:#735436;}.epoch-theme-dark .epoch.category20c div.ref.category17{background-color:#A488FF;}.epoch-theme-dark .epoch.category20c .category17 .line{stroke:#A488FF;}.epoch-theme-dark .epoch.category20c .category17 .area,.epoch-theme-dark .epoch.category20c .category17 .dot{fill:#A488FF;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category17 path{fill:#A488FF;}.epoch-theme-dark .epoch.category20c .bar.category17{fill:#A488FF;}.epoch-theme-dark .epoch.category20c div.ref.category18{background-color:#8670D1;}.epoch-theme-dark .epoch.category20c .category18 .line{stroke:#8670D1;}.epoch-theme-dark .epoch.category20c .category18 .area,.epoch-theme-dark .epoch.category20c .category18 .dot{fill:#8670D1;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category18 path{fill:#8670D1;}.epoch-theme-dark .epoch.category20c .bar.category18{fill:#8670D1;}.epoch-theme-dark .epoch.category20c div.ref.category19{background-color:#705CAD;}.epoch-theme-dark .epoch.category20c .category19 .line{stroke:#705CAD;}.epoch-theme-dark .epoch.category20c .category19 .area,.epoch-theme-dark .epoch.category20c .category19 .dot{fill:#705CAD;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category19 path{fill:#705CAD;}.epoch-theme-dark .epoch.category20c .bar.category19{fill:#705CAD;}.epoch-theme-dark .epoch.category20c div.ref.category20{background-color:#52447F;}.epoch-theme-dark .epoch.category20c .category20 .line{stroke:#52447F;}.epoch-theme-dark .epoch.category20c .category20 .area,.epoch-theme-dark .epoch.category20c .category20 .dot{fill:#52447F;stroke:rgba(0, 0, 0, 0);}.epoch-theme-dark .epoch.category20c .arc.category20 path{fill:#52447F;}.epoch-theme-dark .epoch.category20c .bar.category20{fill:#52447F;} \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/static/prismjs.min.css b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/static/prismjs.min.css deleted file mode 100644 index 0d9d8fb13..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/static/prismjs.min.css +++ /dev/null @@ -1,137 +0,0 @@ -/* http://prismjs.com/download.html?themes=prism&languages=clike+javascript+go */ -/** - * prism.js default theme for JavaScript, CSS and HTML - * Based on dabblet (http://dabblet.com) - * @author Lea Verou - */ - -code[class*="language-"], -pre[class*="language-"] { - color: black; - text-shadow: 0 1px white; - font-family: Consolas, Monaco, 'Andale Mono', monospace; - direction: ltr; - text-align: left; - white-space: pre; - word-spacing: normal; - word-break: normal; - line-height: 1.5; - - -moz-tab-size: 4; - -o-tab-size: 4; - tab-size: 4; - - -webkit-hyphens: none; - -moz-hyphens: none; - -ms-hyphens: none; - hyphens: none; -} - -pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection, -code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection { - text-shadow: none; - background: #b3d4fc; -} - -pre[class*="language-"]::selection, pre[class*="language-"] ::selection, -code[class*="language-"]::selection, code[class*="language-"] ::selection { - text-shadow: none; - background: #b3d4fc; -} - -@media print { - code[class*="language-"], - pre[class*="language-"] { - text-shadow: none; - } -} - -/* Code blocks */ -pre[class*="language-"] { - padding: 1em; - margin: .5em 0; - overflow: auto; -} - -:not(pre) > code[class*="language-"], -pre[class*="language-"] { - background: #f5f2f0; -} - -/* Inline code */ -:not(pre) > code[class*="language-"] { - padding: .1em; - border-radius: .3em; -} - -.token.comment, -.token.prolog, -.token.doctype, -.token.cdata { - color: slategray; -} - -.token.punctuation { - color: #999; -} - -.namespace { - opacity: .7; -} - -.token.property, -.token.tag, -.token.boolean, -.token.number, -.token.constant, -.token.symbol, -.token.deleted { - color: #905; -} - -.token.selector, -.token.attr-name, -.token.string, -.token.char, -.token.builtin, -.token.inserted { - color: #690; -} - -.token.operator, -.token.entity, -.token.url, -.language-css .token.string, -.style .token.string { - color: #a67f59; - background: hsla(0, 0%, 100%, .5); -} - -.token.atrule, -.token.attr-value, -.token.keyword { - color: #07a; -} - -.token.function { - color: #DD4A68; -} - -.token.regex, -.token.important, -.token.variable { - color: #e90; -} - -.token.important, -.token.bold { - font-weight: bold; -} -.token.italic { - font-style: italic; -} - -.token.entity { - cursor: help; -} - diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/static/realtime.js b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/static/realtime.js deleted file mode 100644 index 919dae26c..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/resources/static/realtime.js +++ /dev/null @@ -1,144 +0,0 @@ - - -function StartRealtime(roomid, timestamp) { - StartEpoch(timestamp); - StartSSE(roomid); - StartForm(); -} - -function StartForm() { - $('#chat-message').focus(); - $('#chat-form').ajaxForm(function() { - $('#chat-message').val(''); - $('#chat-message').focus(); - }); -} - -function StartEpoch(timestamp) { - var windowSize = 60; - var height = 200; - var defaultData = histogram(windowSize, timestamp); - - window.heapChart = $('#heapChart').epoch({ - type: 'time.area', - axes: ['bottom', 'left'], - height: height, - historySize: 10, - data: [ - {values: defaultData}, - {values: defaultData} - ] - }); - - window.mallocsChart = $('#mallocsChart').epoch({ - type: 'time.area', - axes: ['bottom', 'left'], - height: height, - historySize: 10, - data: [ - {values: defaultData}, - {values: defaultData} - ] - }); - - window.messagesChart = $('#messagesChart').epoch({ - type: 'time.line', - axes: ['bottom', 'left'], - height: 240, - historySize: 10, - data: [ - {values: defaultData}, - {values: defaultData}, - {values: defaultData} - ] - }); -} - -function StartSSE(roomid) { - if (!window.EventSource) { - alert("EventSource is not enabled in this browser"); - return; - } - var source = new EventSource('/stream/'+roomid); - source.addEventListener('message', newChatMessage, false); - source.addEventListener('stats', stats, false); -} - -function stats(e) { - var data = parseJSONStats(e.data); - heapChart.push(data.heap); - mallocsChart.push(data.mallocs); - messagesChart.push(data.messages); -} - -function parseJSONStats(e) { - var data = jQuery.parseJSON(e); - var timestamp = data.timestamp; - - var heap = [ - {time: timestamp, y: data.HeapInuse}, - {time: timestamp, y: data.StackInuse} - ]; - - var mallocs = [ - {time: timestamp, y: data.Mallocs}, - {time: timestamp, y: data.Frees} - ]; - var messages = [ - {time: timestamp, y: data.Connected}, - {time: timestamp, y: data.Inbound}, - {time: timestamp, y: data.Outbound} - ]; - - return { - heap: heap, - mallocs: mallocs, - messages: messages - } -} - -function newChatMessage(e) { - var data = jQuery.parseJSON(e.data); - var nick = data.nick; - var message = data.message; - var style = rowStyle(nick); - var html = ""+nick+""+message+""; - $('#chat').append(html); - - $("#chat-scroll").scrollTop($("#chat-scroll")[0].scrollHeight); -} - -function histogram(windowSize, timestamp) { - var entries = new Array(windowSize); - for(var i = 0; i < windowSize; i++) { - entries[i] = {time: (timestamp-windowSize+i-1), y:0}; - } - return entries; -} - -var entityMap = { - "&": "&", - "<": "<", - ">": ">", - '"': '"', - "'": ''', - "/": '/' -}; - -function rowStyle(nick) { - var classes = ['active', 'success', 'info', 'warning', 'danger']; - var index = hashCode(nick)%5; - return classes[index]; -} - -function hashCode(s){ - return Math.abs(s.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0)); -} - -function escapeHtml(string) { - return String(string).replace(/[&<>"'\/]/g, function (s) { - return entityMap[s]; - }); -} - -window.StartRealtime = StartRealtime diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/rooms.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/rooms.go deleted file mode 100644 index 82396ba37..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/rooms.go +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import "github.com/dustin/go-broadcast" - -var roomChannels = make(map[string]broadcast.Broadcaster) - -func openListener(roomid string) chan interface{} { - listener := make(chan interface{}) - room(roomid).Register(listener) - return listener -} - -func closeListener(roomid string, listener chan interface{}) { - room(roomid).Unregister(listener) - close(listener) -} - -func room(roomid string) broadcast.Broadcaster { - b, ok := roomChannels[roomid] - if !ok { - b = broadcast.NewBroadcaster(10) - roomChannels[roomid] = b - } - return b -} diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/routes.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/routes.go deleted file mode 100644 index d27f86559..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/routes.go +++ /dev/null @@ -1,96 +0,0 @@ -package main - -import ( - "fmt" - "html" - "io" - "strings" - "time" - - "github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin" -) - -func rateLimit(c *gin.Context) { - - ip := c.ClientIP() - value := int(ips.Add(ip, 1)) - if value%50 == 0 { - fmt.Printf("ip: %s, count: %d\n", ip, value) - } - if value >= 200 { - if value%200 == 0 { - fmt.Println("ip blocked") - } - c.Abort() - c.String(503, "you were automatically banned :)") - } -} - -func index(c *gin.Context) { - c.Redirect(301, "/room/hn") -} - -func roomGET(c *gin.Context) { - roomid := c.ParamValue("roomid") - nick := c.FormValue("nick") - if len(nick) < 2 { - nick = "" - } - if len(nick) > 13 { - nick = nick[0:12] + "..." - } - c.HTML(200, "room_login.templ.html", gin.H{ - "roomid": roomid, - "nick": nick, - "timestamp": time.Now().Unix(), - }) - -} - -func roomPOST(c *gin.Context) { - roomid := c.ParamValue("roomid") - nick := c.FormValue("nick") - message := c.PostFormValue("message") - message = strings.TrimSpace(message) - - validMessage := len(message) > 1 && len(message) < 200 - validNick := len(nick) > 1 && len(nick) < 14 - if !validMessage || !validNick { - c.JSON(400, gin.H{ - "status": "failed", - "error": "the message or nickname is too long", - }) - return - } - - post := gin.H{ - "nick": html.EscapeString(nick), - "message": html.EscapeString(message), - } - messages.Add("inbound", 1) - room(roomid).Submit(post) - c.JSON(200, post) -} - -func streamRoom(c *gin.Context) { - roomid := c.ParamValue("roomid") - listener := openListener(roomid) - ticker := time.NewTicker(1 * time.Second) - users.Add("connected", 1) - defer func() { - closeListener(roomid, listener) - ticker.Stop() - users.Add("disconnected", 1) - }() - - c.Stream(func(w io.Writer) bool { - select { - case msg := <-listener: - messages.Add("outbound", 1) - c.SSEvent("message", msg) - case <-ticker.C: - c.SSEvent("stats", Stats()) - } - return true - }) -} diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/stats.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/stats.go deleted file mode 100644 index 32c52835b..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/stats.go +++ /dev/null @@ -1,56 +0,0 @@ -package main - -import ( - "runtime" - "sync" - "time" - - "github.com/manucorporat/stats" -) - -var ips = stats.New() -var messages = stats.New() -var users = stats.New() -var mutexStats sync.RWMutex -var savedStats map[string]uint64 - -func statsWorker() { - c := time.Tick(1 * time.Second) - var lastMallocs uint64 = 0 - var lastFrees uint64 = 0 - for range c { - var stats runtime.MemStats - runtime.ReadMemStats(&stats) - - mutexStats.Lock() - savedStats = map[string]uint64{ - "timestamp": uint64(time.Now().Unix()), - "HeapInuse": stats.HeapInuse, - "StackInuse": stats.StackInuse, - "Mallocs": (stats.Mallocs - lastMallocs), - "Frees": (stats.Frees - lastFrees), - "Inbound": uint64(messages.Get("inbound")), - "Outbound": uint64(messages.Get("outbound")), - "Connected": connectedUsers(), - } - lastMallocs = stats.Mallocs - lastFrees = stats.Frees - messages.Reset() - mutexStats.Unlock() - } -} - -func connectedUsers() uint64 { - connected := users.Get("connected") - users.Get("disconnected") - if connected < 0 { - return 0 - } - return uint64(connected) -} - -func Stats() map[string]uint64 { - mutexStats.RLock() - defer mutexStats.RUnlock() - - return savedStats -} diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/main.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/main.go deleted file mode 100644 index 40205d2c0..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/main.go +++ /dev/null @@ -1,58 +0,0 @@ -package main - -import ( - "fmt" - "io" - "math/rand" - - "github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin" -) - -func main() { - router := gin.Default() - router.SetHTMLTemplate(html) - - router.GET("/room/:roomid", roomGET) - router.POST("/room/:roomid", roomPOST) - router.DELETE("/room/:roomid", roomDELETE) - router.GET("/stream/:roomid", stream) - - router.Run(":8080") -} - -func stream(c *gin.Context) { - roomid := c.ParamValue("roomid") - listener := openListener(roomid) - defer closeListener(roomid, listener) - - c.Stream(func(w io.Writer) bool { - c.SSEvent("message", <-listener) - return true - }) -} - -func roomGET(c *gin.Context) { - roomid := c.ParamValue("roomid") - userid := fmt.Sprint(rand.Int31()) - c.HTML(200, "chat_room", gin.H{ - "roomid": roomid, - "userid": userid, - }) -} - -func roomPOST(c *gin.Context) { - roomid := c.ParamValue("roomid") - userid := c.PostFormValue("user") - message := c.PostFormValue("message") - room(roomid).Submit(userid + ": " + message) - - c.JSON(200, gin.H{ - "status": "success", - "message": message, - }) -} - -func roomDELETE(c *gin.Context) { - roomid := c.ParamValue("roomid") - deleteBroadcast(roomid) -} diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/rooms.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/rooms.go deleted file mode 100644 index 8c62bece1..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/rooms.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import "github.com/dustin/go-broadcast" - -var roomChannels = make(map[string]broadcast.Broadcaster) - -func openListener(roomid string) chan interface{} { - listener := make(chan interface{}) - room(roomid).Register(listener) - return listener -} - -func closeListener(roomid string, listener chan interface{}) { - room(roomid).Unregister(listener) - close(listener) -} - -func deleteBroadcast(roomid string) { - b, ok := roomChannels[roomid] - if ok { - b.Close() - delete(roomChannels, roomid) - } -} - -func room(roomid string) broadcast.Broadcaster { - b, ok := roomChannels[roomid] - if !ok { - b = broadcast.NewBroadcaster(10) - roomChannels[roomid] = b - } - return b -} diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/template.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/template.go deleted file mode 100644 index b9024de6d..000000000 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/template.go +++ /dev/null @@ -1,44 +0,0 @@ -package main - -import "html/template" - -var html = template.Must(template.New("chat_room").Parse(` - - - {{.roomid}} - - - - - - -

Welcome to {{.roomid}} room

-
-
- User: - Message: - -
- - -`)) diff --git a/Godeps/_workspace/src/github.com/namsral/flag/LICENSE b/Godeps/_workspace/src/github.com/namsral/flag/LICENSE new file mode 100644 index 000000000..0f2498b19 --- /dev/null +++ b/Godeps/_workspace/src/github.com/namsral/flag/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/namsral/flag/README.md b/Godeps/_workspace/src/github.com/namsral/flag/README.md new file mode 100644 index 000000000..b5f6f8272 --- /dev/null +++ b/Godeps/_workspace/src/github.com/namsral/flag/README.md @@ -0,0 +1,184 @@ +Flag +=== + +Flag is a drop in replacement for Go's flag package with the addition to parse files and environment variables. If you support the [twelve-factor app methodology][], Flag complies with the third factor; "Store config in the environment". + +[twelve-factor app methodology]: http://12factor.net + +An example using a gopher: + +```go +$ cat > gopher.go + package main + + import ( + "fmt" + "github.com/namsral/flag" + ) + + var age int + + flag.IntVar(&age, "age", 0, "age of gopher") + flag.Parse() + + fmt.Print("age:", age) + +$ go run gopher.go -age 1 +age: 1 +``` + +Same code but using an environment variable: + +```go +$ export AGE=2 +$ go run gopher.go +age: 2 +``` + + +Same code but using a configuration file: + +```go +$ cat > gopher.conf +age 3 + +$ go run gopher.go -config gopher.conf +age: 3 +``` + +The following table shows how flags are translated to environment variables and configuration files: + +| Type | Flag | Environment | File | +| ------ | :------------ |:------------ |:------------ | +| int | -age 2 | AGE=2 | age 2 | +| bool | -female | FEMALE=true | female true | +| float | -length 175.5 | LENGTH=175.5 | length 175.5 | +| string | -name Gloria | NAME=Gloria | name Gloria | + +This package is a port of Go's [flag][] package from the standard library with the addition of two functions `ParseEnv` and `ParseFile`. + +[flag]: http://golang.org/src/pkg/flagconfiguration + + +Why? +--- + +Why not use one of the many INI, JSON or YAML parsers? + +I find it best practice to have simple configuration options to control the behaviour of an applications when it starts up. Use basic types like ints, floats and strings for configuration options and store more complex data structures in the "datastore" layer. + + +Usage +--- + +It's intended for projects which require a simple configuration made available through command-line flags, configuration files and shell environments. It's similar to the original `flag` package. + +Example: + +```go +import "github/namsral/flag" + +flag.String("config", "", "help message for config") +flag.Int("age", 24, "help message for age") + +flag.Parse() +``` + +Order of precedence: + +1. Command line options +2. Environment variables +3. Configuration file +4. Default values + + +#### Parsing Configuration Files + +Create a configuration file: + +```go +$ cat > ./gopher.conf +# empty newlines and lines beginning with a "#" character are ignored. +name bob + +# keys and values can also be separated by the "=" character +age=20 + +# booleans can be empty, set with 0, 1, true, false, etc +hacker +``` + +Add a "config" flag: + +```go +flag.String("config", "", "help message for config") +``` + +Run the command: + +```go +$ go run ./gopher.go -config ./gopher.conf +``` + +#### Parsing Environment Variables + +Environment variables are parsed 1-on-1 with defined flags: + +```go +$ export AGE=44 +$ go run ./gopher.go +age=44 +``` + + +You can also parse prefixed environment variables by setting a prefix name when creating a new empty flag set: + +```go +fs := flag.NewFlagSetWithEnvPrefix(os.Args[0], "GO", 0) +fs.Int("age", 24, "help message for age") +fs.Parse(os.Args[1:]) +... +$ go export GO_AGE=33 +$ go run ./gopher.go +age=33 +``` + + +For more examples see the [examples][] directory in the project repository. + +[examples]: https://github.com/namsral/flag/tree/master/examples + +That's it. + + +License +--- + + +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Godeps/_workspace/src/github.com/namsral/flag/example_test.go b/Godeps/_workspace/src/github.com/namsral/flag/example_test.go new file mode 100644 index 000000000..08273cb5b --- /dev/null +++ b/Godeps/_workspace/src/github.com/namsral/flag/example_test.go @@ -0,0 +1,82 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// These examples demonstrate more intricate uses of the flag package. +package flag + +import ( + "errors" + "fmt" + "strings" + "time" +) + +// Example 1: A single string flag called "species" with default value "gopher". +var species = String("species", "gopher", "the species we are studying") + +// Example 2: Two flags sharing a variable, so we can have a shorthand. +// The order of initialization is undefined, so make sure both use the +// same default value. They must be set up with an init function. +var gopherType string + +func init() { + const ( + defaultGopher = "pocket" + usage = "the variety of gopher" + ) + StringVar(&gopherType, "gopher_type", defaultGopher, usage) + StringVar(&gopherType, "g", defaultGopher, usage+" (shorthand)") +} + +// Example 3: A user-defined flag type, a slice of durations. +type interval []time.Duration + +// String is the method to format the flag's value, part of the Value interface. +// The String method's output will be used in diagnostics. +func (i *interval) String() string { + return fmt.Sprint(*i) +} + +// Set is the method to set the flag value, part of the Value interface. +// Set's argument is a string to be parsed to set the +// It's a comma-separated list, so we split it. +func (i *interval) Set(value string) error { + // If we wanted to allow the flag to be set multiple times, + // accumulating values, we would delete this if statement. + // That would permit usages such as + // -deltaT 10s -deltaT 15s + // and other combinations. + if len(*i) > 0 { + return errors.New("interval flag already set") + } + for _, dt := range strings.Split(value, ",") { + duration, err := time.ParseDuration(dt) + if err != nil { + return err + } + *i = append(*i, duration) + } + return nil +} + +// Define a flag to accumulate durations. Because it has a special type, +// we need to use the Var function and therefore create the flag during +// init. + +var intervalFlag interval + +func init() { + // Tie the command-line flag to the intervalFlag variable and + // set a usage message. + Var(&intervalFlag, "deltaT", "comma-separated list of intervals to use between events") +} + +func Example() { + // All the interesting pieces are with the variables declared above, but + // to enable the flag package to see the flags defined there, one must + // execute, typically at the start of main (not init!): + // flag.Parse() + // We don't run it here because this is not a main function and + // the testing suite has already parsed the flags. +} diff --git a/Godeps/_workspace/src/github.com/namsral/flag/examples/gopher.conf b/Godeps/_workspace/src/github.com/namsral/flag/examples/gopher.conf new file mode 100644 index 000000000..e0b90045b --- /dev/null +++ b/Godeps/_workspace/src/github.com/namsral/flag/examples/gopher.conf @@ -0,0 +1,5 @@ +# this is a comment followed by an empty line + +length 175.5 +age 2 +name Gloria \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/namsral/flag/examples/gopher.go b/Godeps/_workspace/src/github.com/namsral/flag/examples/gopher.go new file mode 100644 index 000000000..3541f1491 --- /dev/null +++ b/Godeps/_workspace/src/github.com/namsral/flag/examples/gopher.go @@ -0,0 +1,29 @@ +package main + +import ( + "github.com/drone/drone/Godeps/_workspace/src/github.com/namsral/flag" + "fmt" +) + +func main() { + var ( + config string + length float64 + age int + name string + female bool + ) + + flag.StringVar(&config, "config", "", "help message") + flag.StringVar(&name, "name", "", "help message") + flag.IntVar(&age, "age", 0, "help message") + flag.Float64Var(&length, "length", 0, "help message") + flag.BoolVar(&female, "female", false, "help message") + + flag.Parse() + + fmt.Println("length:", length) + fmt.Println("age:", age) + fmt.Println("name:", name) + fmt.Println("female:", female) +} diff --git a/Godeps/_workspace/src/github.com/namsral/flag/export_test.go b/Godeps/_workspace/src/github.com/namsral/flag/export_test.go new file mode 100644 index 000000000..82b35ccbf --- /dev/null +++ b/Godeps/_workspace/src/github.com/namsral/flag/export_test.go @@ -0,0 +1,17 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package flag + +import "os" + +// Additional routines compiled into the package only during testing. + +// ResetForTesting clears all flag state and sets the usage function as directed. +// After calling ResetForTesting, parse errors in flag handling will not +// exit the program. +func ResetForTesting(usage func()) { + CommandLine = NewFlagSet(os.Args[0], ContinueOnError) + Usage = usage +} \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/namsral/flag/flag.go b/Godeps/_workspace/src/github.com/namsral/flag/flag.go new file mode 100644 index 000000000..151cae11b --- /dev/null +++ b/Godeps/_workspace/src/github.com/namsral/flag/flag.go @@ -0,0 +1,1040 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +/*Package flag implements command-line flag parsing. + +Usage: + +Define flags using flag.String(), Bool(), Int(), etc. + +This declares an integer flag, -flagname, stored in the pointer ip, with type *int. + import "flag" + var ip = flag.Int("flagname", 1234, "help message for flagname") +If you like, you can bind the flag to a variable using the Var() functions. + var flagvar int + func init() { + flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") + } +Or you can create custom flags that satisfy the Value interface (with +pointer receivers) and couple them to flag parsing by + flag.Var(&flagVal, "name", "help message for flagname") +For such flags, the default value is just the initial value of the variable. + +After all flags are defined, call + flag.Parse() +to parse the command line into the defined flags. + +Flags may then be used directly. If you're using the flags themselves, +they are all pointers; if you bind to variables, they're values. + fmt.Println("ip has value ", *ip) + fmt.Println("flagvar has value ", flagvar) + +After parsing, the arguments after the flag are available as the +slice flag.Args() or individually as flag.Arg(i). +The arguments are indexed from 0 through flag.NArg()-1. + +Command line flag syntax: + -flag + -flag=x + -flag x // non-boolean flags only +One or two minus signs may be used; they are equivalent. +The last form is not permitted for boolean flags because the +meaning of the command + cmd -x * +will change if there is a file called 0, false, etc. You must +use the -flag=false form to turn off a boolean flag. + +Flag parsing stops just before the first non-flag argument +("-" is a non-flag argument) or after the terminator "--". + +Integer flags accept 1234, 0664, 0x1234 and may be negative. +Boolean flags may be 1, 0, t, f, true, false, TRUE, FALSE, True, False. +Duration flags accept any input valid for time.ParseDuration. + +The default set of command-line flags is controlled by +top-level functions. The FlagSet type allows one to define +independent sets of flags, such as to implement subcommands +in a command-line interface. The methods of FlagSet are +analogous to the top-level functions for the command-line +flag set. +*/ +package flag + +import ( + "bufio" + "errors" + "fmt" + "io" + "os" + "sort" + "strconv" + "strings" + "time" +) + +// EnvironmentPrefix defines a string that will be implicitely prefixed to a +// flag name before looking it up in the environment variables. +var EnvironmentPrefix = "" + +// ErrHelp is the error returned if the flag -help is invoked but no such flag is defined. +var ErrHelp = errors.New("flag: help requested") + +// -- bool Value +type boolValue bool + +func newBoolValue(val bool, p *bool) *boolValue { + *p = val + return (*boolValue)(p) +} + +func (b *boolValue) Set(s string) error { + v, err := strconv.ParseBool(s) + *b = boolValue(v) + return err +} + +func (b *boolValue) Get() interface{} { return bool(*b) } + +func (b *boolValue) String() string { return fmt.Sprintf("%v", *b) } + +func (b *boolValue) IsBoolFlag() bool { return true } + +// optional interface to indicate boolean flags that can be +// supplied without "=value" text +type boolFlag interface { + Value + IsBoolFlag() bool +} + +// -- int Value +type intValue int + +func newIntValue(val int, p *int) *intValue { + *p = val + return (*intValue)(p) +} + +func (i *intValue) Set(s string) error { + v, err := strconv.ParseInt(s, 0, 64) + *i = intValue(v) + return err +} + +func (i *intValue) Get() interface{} { return int(*i) } + +func (i *intValue) String() string { return fmt.Sprintf("%v", *i) } + +// -- int64 Value +type int64Value int64 + +func newInt64Value(val int64, p *int64) *int64Value { + *p = val + return (*int64Value)(p) +} + +func (i *int64Value) Set(s string) error { + v, err := strconv.ParseInt(s, 0, 64) + *i = int64Value(v) + return err +} + +func (i *int64Value) Get() interface{} { return int64(*i) } + +func (i *int64Value) String() string { return fmt.Sprintf("%v", *i) } + +// -- uint Value +type uintValue uint + +func newUintValue(val uint, p *uint) *uintValue { + *p = val + return (*uintValue)(p) +} + +func (i *uintValue) Set(s string) error { + v, err := strconv.ParseUint(s, 0, 64) + *i = uintValue(v) + return err +} + +func (i *uintValue) Get() interface{} { return uint(*i) } + +func (i *uintValue) String() string { return fmt.Sprintf("%v", *i) } + +// -- uint64 Value +type uint64Value uint64 + +func newUint64Value(val uint64, p *uint64) *uint64Value { + *p = val + return (*uint64Value)(p) +} + +func (i *uint64Value) Set(s string) error { + v, err := strconv.ParseUint(s, 0, 64) + *i = uint64Value(v) + return err +} + +func (i *uint64Value) Get() interface{} { return uint64(*i) } + +func (i *uint64Value) String() string { return fmt.Sprintf("%v", *i) } + +// -- string Value +type stringValue string + +func newStringValue(val string, p *string) *stringValue { + *p = val + return (*stringValue)(p) +} + +func (s *stringValue) Set(val string) error { + *s = stringValue(val) + return nil +} + +func (s *stringValue) Get() interface{} { return string(*s) } + +func (s *stringValue) String() string { return fmt.Sprintf("%s", *s) } + +// -- float64 Value +type float64Value float64 + +func newFloat64Value(val float64, p *float64) *float64Value { + *p = val + return (*float64Value)(p) +} + +func (f *float64Value) Set(s string) error { + v, err := strconv.ParseFloat(s, 64) + *f = float64Value(v) + return err +} + +func (f *float64Value) Get() interface{} { return float64(*f) } + +func (f *float64Value) String() string { return fmt.Sprintf("%v", *f) } + +// -- time.Duration Value +type durationValue time.Duration + +func newDurationValue(val time.Duration, p *time.Duration) *durationValue { + *p = val + return (*durationValue)(p) +} + +func (d *durationValue) Set(s string) error { + v, err := time.ParseDuration(s) + *d = durationValue(v) + return err +} + +func (d *durationValue) Get() interface{} { return time.Duration(*d) } + +func (d *durationValue) String() string { return (*time.Duration)(d).String() } + +// Value is the interface to the dynamic value stored in a flag. +// (The default value is represented as a string.) +// +// If a Value has an IsBoolFlag() bool method returning true, +// the command-line parser makes -name equivalent to -name=true +// rather than using the next command-line argument. +type Value interface { + String() string + Set(string) error +} + +// Getter is an interface that allows the contents of a Value to be retrieved. +// It wraps the Value interface, rather than being part of it, because it +// appeared after Go 1 and its compatibility rules. All Value types provided +// by this package satisfy the Getter interface. +type Getter interface { + Value + Get() interface{} +} + +// ErrorHandling defines how to handle flag parsing errors. +type ErrorHandling int + +const ( + ContinueOnError ErrorHandling = iota + ExitOnError + PanicOnError +) + +// A FlagSet represents a set of defined flags. The zero value of a FlagSet +// has no name and has ContinueOnError error handling. +type FlagSet struct { + // Usage is the function called when an error occurs while parsing flags. + // The field is a function (not a method) that may be changed to point to + // a custom error handler. + Usage func() + + name string + parsed bool + actual map[string]*Flag + formal map[string]*Flag + envPrefix string // prefix to all env variable names + args []string // arguments after flags + exitOnError bool // does the program exit if there's an error? + errorHandling ErrorHandling + output io.Writer // nil means stderr; use out() accessor +} + +// A Flag represents the state of a flag. +type Flag struct { + Name string // name as it appears on command line + Usage string // help message + Value Value // value as set + DefValue string // default value (as text); for usage message +} + +// sortFlags returns the flags as a slice in lexicographical sorted order. +func sortFlags(flags map[string]*Flag) []*Flag { + list := make(sort.StringSlice, len(flags)) + i := 0 + for _, f := range flags { + list[i] = f.Name + i++ + } + list.Sort() + result := make([]*Flag, len(list)) + for i, name := range list { + result[i] = flags[name] + } + return result +} + +func (f *FlagSet) out() io.Writer { + if f.output == nil { + return os.Stderr + } + return f.output +} + +// SetOutput sets the destination for usage and error messages. +// If output is nil, os.Stderr is used. +func (f *FlagSet) SetOutput(output io.Writer) { + f.output = output +} + +// VisitAll visits the flags in lexicographical order, calling fn for each. +// It visits all flags, even those not set. +func (f *FlagSet) VisitAll(fn func(*Flag)) { + for _, flag := range sortFlags(f.formal) { + fn(flag) + } +} + +// VisitAll visits the command-line flags in lexicographical order, calling +// fn for each. It visits all flags, even those not set. +func VisitAll(fn func(*Flag)) { + CommandLine.VisitAll(fn) +} + +// Visit visits the flags in lexicographical order, calling fn for each. +// It visits only those flags that have been set. +func (f *FlagSet) Visit(fn func(*Flag)) { + for _, flag := range sortFlags(f.actual) { + fn(flag) + } +} + +// Visit visits the command-line flags in lexicographical order, calling fn +// for each. It visits only those flags that have been set. +func Visit(fn func(*Flag)) { + CommandLine.Visit(fn) +} + +// Lookup returns the Flag structure of the named flag, returning nil if none exists. +func (f *FlagSet) Lookup(name string) *Flag { + return f.formal[name] +} + +// Lookup returns the Flag structure of the named command-line flag, +// returning nil if none exists. +func Lookup(name string) *Flag { + return CommandLine.formal[name] +} + +// Set sets the value of the named flag. +func (f *FlagSet) Set(name, value string) error { + flag, ok := f.formal[name] + if !ok { + return fmt.Errorf("no such flag -%v", name) + } + err := flag.Value.Set(value) + if err != nil { + return err + } + if f.actual == nil { + f.actual = make(map[string]*Flag) + } + f.actual[name] = flag + return nil +} + +// Set sets the value of the named command-line flag. +func Set(name, value string) error { + return CommandLine.Set(name, value) +} + +// PrintDefaults prints, to standard error unless configured +// otherwise, the default values of all defined flags in the set. +func (f *FlagSet) PrintDefaults() { + f.VisitAll(func(flag *Flag) { + format := " -%s=%s: %s\n" + if _, ok := flag.Value.(*stringValue); ok { + // put quotes on the value + format = " -%s=%q: %s\n" + } + fmt.Fprintf(f.out(), format, flag.Name, flag.DefValue, flag.Usage) + }) +} + +// PrintDefaults prints to standard error the default values of all defined command-line flags. +func PrintDefaults() { + CommandLine.PrintDefaults() +} + +// defaultUsage is the default function to print a usage message. +func defaultUsage(f *FlagSet) { + if f.name == "" { + fmt.Fprintf(f.out(), "Usage:\n") + } else { + fmt.Fprintf(f.out(), "Usage of %s:\n", f.name) + } + f.PrintDefaults() +} + +// NOTE: Usage is not just defaultUsage(CommandLine) +// because it serves (via godoc flag Usage) as the example +// for how to write your own usage function. + +// Usage prints to standard error a usage message documenting all defined command-line flags. +// The function is a variable that may be changed to point to a custom function. +var Usage = func() { + fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) + PrintDefaults() +} + +// NFlag returns the number of flags that have been set. +func (f *FlagSet) NFlag() int { return len(f.actual) } + +// NFlag returns the number of command-line flags that have been set. +func NFlag() int { return len(CommandLine.actual) } + +// Arg returns the i'th argument. Arg(0) is the first remaining argument +// after flags have been processed. +func (f *FlagSet) Arg(i int) string { + if i < 0 || i >= len(f.args) { + return "" + } + return f.args[i] +} + +// Arg returns the i'th command-line argument. Arg(0) is the first remaining argument +// after flags have been processed. +func Arg(i int) string { + return CommandLine.Arg(i) +} + +// NArg is the number of arguments remaining after flags have been processed. +func (f *FlagSet) NArg() int { return len(f.args) } + +// NArg is the number of arguments remaining after flags have been processed. +func NArg() int { return len(CommandLine.args) } + +// Args returns the non-flag arguments. +func (f *FlagSet) Args() []string { return f.args } + +// Args returns the non-flag command-line arguments. +func Args() []string { return CommandLine.args } + +// BoolVar defines a bool flag with specified name, default value, and usage string. +// The argument p points to a bool variable in which to store the value of the flag. +func (f *FlagSet) BoolVar(p *bool, name string, value bool, usage string) { + f.Var(newBoolValue(value, p), name, usage) +} + +// BoolVar defines a bool flag with specified name, default value, and usage string. +// The argument p points to a bool variable in which to store the value of the flag. +func BoolVar(p *bool, name string, value bool, usage string) { + CommandLine.Var(newBoolValue(value, p), name, usage) +} + +// Bool defines a bool flag with specified name, default value, and usage string. +// The return value is the address of a bool variable that stores the value of the flag. +func (f *FlagSet) Bool(name string, value bool, usage string) *bool { + p := new(bool) + f.BoolVar(p, name, value, usage) + return p +} + +// Bool defines a bool flag with specified name, default value, and usage string. +// The return value is the address of a bool variable that stores the value of the flag. +func Bool(name string, value bool, usage string) *bool { + return CommandLine.Bool(name, value, usage) +} + +// IntVar defines an int flag with specified name, default value, and usage string. +// The argument p points to an int variable in which to store the value of the flag. +func (f *FlagSet) IntVar(p *int, name string, value int, usage string) { + f.Var(newIntValue(value, p), name, usage) +} + +// IntVar defines an int flag with specified name, default value, and usage string. +// The argument p points to an int variable in which to store the value of the flag. +func IntVar(p *int, name string, value int, usage string) { + CommandLine.Var(newIntValue(value, p), name, usage) +} + +// Int defines an int flag with specified name, default value, and usage string. +// The return value is the address of an int variable that stores the value of the flag. +func (f *FlagSet) Int(name string, value int, usage string) *int { + p := new(int) + f.IntVar(p, name, value, usage) + return p +} + +// Int defines an int flag with specified name, default value, and usage string. +// The return value is the address of an int variable that stores the value of the flag. +func Int(name string, value int, usage string) *int { + return CommandLine.Int(name, value, usage) +} + +// Int64Var defines an int64 flag with specified name, default value, and usage string. +// The argument p points to an int64 variable in which to store the value of the flag. +func (f *FlagSet) Int64Var(p *int64, name string, value int64, usage string) { + f.Var(newInt64Value(value, p), name, usage) +} + +// Int64Var defines an int64 flag with specified name, default value, and usage string. +// The argument p points to an int64 variable in which to store the value of the flag. +func Int64Var(p *int64, name string, value int64, usage string) { + CommandLine.Var(newInt64Value(value, p), name, usage) +} + +// Int64 defines an int64 flag with specified name, default value, and usage string. +// The return value is the address of an int64 variable that stores the value of the flag. +func (f *FlagSet) Int64(name string, value int64, usage string) *int64 { + p := new(int64) + f.Int64Var(p, name, value, usage) + return p +} + +// Int64 defines an int64 flag with specified name, default value, and usage string. +// The return value is the address of an int64 variable that stores the value of the flag. +func Int64(name string, value int64, usage string) *int64 { + return CommandLine.Int64(name, value, usage) +} + +// UintVar defines a uint flag with specified name, default value, and usage string. +// The argument p points to a uint variable in which to store the value of the flag. +func (f *FlagSet) UintVar(p *uint, name string, value uint, usage string) { + f.Var(newUintValue(value, p), name, usage) +} + +// UintVar defines a uint flag with specified name, default value, and usage string. +// The argument p points to a uint variable in which to store the value of the flag. +func UintVar(p *uint, name string, value uint, usage string) { + CommandLine.Var(newUintValue(value, p), name, usage) +} + +// Uint defines a uint flag with specified name, default value, and usage string. +// The return value is the address of a uint variable that stores the value of the flag. +func (f *FlagSet) Uint(name string, value uint, usage string) *uint { + p := new(uint) + f.UintVar(p, name, value, usage) + return p +} + +// Uint defines a uint flag with specified name, default value, and usage string. +// The return value is the address of a uint variable that stores the value of the flag. +func Uint(name string, value uint, usage string) *uint { + return CommandLine.Uint(name, value, usage) +} + +// Uint64Var defines a uint64 flag with specified name, default value, and usage string. +// The argument p points to a uint64 variable in which to store the value of the flag. +func (f *FlagSet) Uint64Var(p *uint64, name string, value uint64, usage string) { + f.Var(newUint64Value(value, p), name, usage) +} + +// Uint64Var defines a uint64 flag with specified name, default value, and usage string. +// The argument p points to a uint64 variable in which to store the value of the flag. +func Uint64Var(p *uint64, name string, value uint64, usage string) { + CommandLine.Var(newUint64Value(value, p), name, usage) +} + +// Uint64 defines a uint64 flag with specified name, default value, and usage string. +// The return value is the address of a uint64 variable that stores the value of the flag. +func (f *FlagSet) Uint64(name string, value uint64, usage string) *uint64 { + p := new(uint64) + f.Uint64Var(p, name, value, usage) + return p +} + +// Uint64 defines a uint64 flag with specified name, default value, and usage string. +// The return value is the address of a uint64 variable that stores the value of the flag. +func Uint64(name string, value uint64, usage string) *uint64 { + return CommandLine.Uint64(name, value, usage) +} + +// StringVar defines a string flag with specified name, default value, and usage string. +// The argument p points to a string variable in which to store the value of the flag. +func (f *FlagSet) StringVar(p *string, name string, value string, usage string) { + f.Var(newStringValue(value, p), name, usage) +} + +// StringVar defines a string flag with specified name, default value, and usage string. +// The argument p points to a string variable in which to store the value of the flag. +func StringVar(p *string, name string, value string, usage string) { + CommandLine.Var(newStringValue(value, p), name, usage) +} + +// String defines a string flag with specified name, default value, and usage string. +// The return value is the address of a string variable that stores the value of the flag. +func (f *FlagSet) String(name string, value string, usage string) *string { + p := new(string) + f.StringVar(p, name, value, usage) + return p +} + +// String defines a string flag with specified name, default value, and usage string. +// The return value is the address of a string variable that stores the value of the flag. +func String(name string, value string, usage string) *string { + return CommandLine.String(name, value, usage) +} + +// Float64Var defines a float64 flag with specified name, default value, and usage string. +// The argument p points to a float64 variable in which to store the value of the flag. +func (f *FlagSet) Float64Var(p *float64, name string, value float64, usage string) { + f.Var(newFloat64Value(value, p), name, usage) +} + +// Float64Var defines a float64 flag with specified name, default value, and usage string. +// The argument p points to a float64 variable in which to store the value of the flag. +func Float64Var(p *float64, name string, value float64, usage string) { + CommandLine.Var(newFloat64Value(value, p), name, usage) +} + +// Float64 defines a float64 flag with specified name, default value, and usage string. +// The return value is the address of a float64 variable that stores the value of the flag. +func (f *FlagSet) Float64(name string, value float64, usage string) *float64 { + p := new(float64) + f.Float64Var(p, name, value, usage) + return p +} + +// Float64 defines a float64 flag with specified name, default value, and usage string. +// The return value is the address of a float64 variable that stores the value of the flag. +func Float64(name string, value float64, usage string) *float64 { + return CommandLine.Float64(name, value, usage) +} + +// DurationVar defines a time.Duration flag with specified name, default value, and usage string. +// The argument p points to a time.Duration variable in which to store the value of the flag. +func (f *FlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string) { + f.Var(newDurationValue(value, p), name, usage) +} + +// DurationVar defines a time.Duration flag with specified name, default value, and usage string. +// The argument p points to a time.Duration variable in which to store the value of the flag. +func DurationVar(p *time.Duration, name string, value time.Duration, usage string) { + CommandLine.Var(newDurationValue(value, p), name, usage) +} + +// Duration defines a time.Duration flag with specified name, default value, and usage string. +// The return value is the address of a time.Duration variable that stores the value of the flag. +func (f *FlagSet) Duration(name string, value time.Duration, usage string) *time.Duration { + p := new(time.Duration) + f.DurationVar(p, name, value, usage) + return p +} + +// Duration defines a time.Duration flag with specified name, default value, and usage string. +// The return value is the address of a time.Duration variable that stores the value of the flag. +func Duration(name string, value time.Duration, usage string) *time.Duration { + return CommandLine.Duration(name, value, usage) +} + +// Var defines a flag with the specified name and usage string. The type and +// value of the flag are represented by the first argument, of type Value, which +// typically holds a user-defined implementation of Value. For instance, the +// caller could create a flag that turns a comma-separated string into a slice +// of strings by giving the slice the methods of Value; in particular, Set would +// decompose the comma-separated string into the slice. +func (f *FlagSet) Var(value Value, name string, usage string) { + // Remember the default value as a string; it won't change. + flag := &Flag{name, usage, value, value.String()} + _, alreadythere := f.formal[name] + if alreadythere { + var msg string + if f.name == "" { + msg = fmt.Sprintf("flag redefined: %s", name) + } else { + msg = fmt.Sprintf("%s flag redefined: %s", f.name, name) + } + fmt.Fprintln(f.out(), msg) + panic(msg) // Happens only if flags are declared with identical names + } + if f.formal == nil { + f.formal = make(map[string]*Flag) + } + f.formal[name] = flag +} + +// Var defines a flag with the specified name and usage string. The type and +// value of the flag are represented by the first argument, of type Value, which +// typically holds a user-defined implementation of Value. For instance, the +// caller could create a flag that turns a comma-separated string into a slice +// of strings by giving the slice the methods of Value; in particular, Set would +// decompose the comma-separated string into the slice. +func Var(value Value, name string, usage string) { + CommandLine.Var(value, name, usage) +} + +// failf prints to standard error a formatted error and usage message and +// returns the error. +func (f *FlagSet) failf(format string, a ...interface{}) error { + err := fmt.Errorf(format, a...) + fmt.Fprintln(f.out(), err) + f.usage() + return err +} + +// usage calls the Usage method for the flag set, or the usage function if +// the flag set is CommandLine. +func (f *FlagSet) usage() { + if f == CommandLine { + Usage() + } else if f.Usage == nil { + defaultUsage(f) + } else { + f.Usage() + } +} + +// parseOne parses one flag. It reports whether a flag was seen. +func (f *FlagSet) parseOne() (bool, error) { + if len(f.args) == 0 { + return false, nil + } + s := f.args[0] + if len(s) == 0 || s[0] != '-' || len(s) == 1 { + return false, nil + } + numMinuses := 1 + if s[1] == '-' { + numMinuses++ + if len(s) == 2 { // "--" terminates the flags + f.args = f.args[1:] + return false, nil + } + } + name := s[numMinuses:] + if len(name) == 0 || name[0] == '-' || name[0] == '=' { + return false, f.failf("bad flag syntax: %s", s) + } + + // it's a flag. does it have an argument? + f.args = f.args[1:] + hasValue := false + value := "" + for i := 1; i < len(name); i++ { // equals cannot be first + if name[i] == '=' { + value = name[i+1:] + hasValue = true + name = name[0:i] + break + } + } + m := f.formal + flag, alreadythere := m[name] // BUG + if !alreadythere { + if name == "help" || name == "h" { // special case for nice help message. + f.usage() + return false, ErrHelp + } + return false, f.failf("flag provided but not defined: -%s", name) + } + if fv, ok := flag.Value.(boolFlag); ok && fv.IsBoolFlag() { // special case: doesn't need an arg + if hasValue { + if err := fv.Set(value); err != nil { + return false, f.failf("invalid boolean value %q for -%s: %v", value, name, err) + } + } else { + fv.Set("true") + } + } else { + // It must have a value, which might be the next argument. + if !hasValue && len(f.args) > 0 { + // value is the next arg + hasValue = true + value, f.args = f.args[0], f.args[1:] + } + if !hasValue { + return false, f.failf("flag needs an argument: -%s", name) + } + if err := flag.Value.Set(value); err != nil { + return false, f.failf("invalid value %q for flag -%s: %v", value, name, err) + } + } + if f.actual == nil { + f.actual = make(map[string]*Flag) + } + f.actual[name] = flag + return true, nil +} + +// Parse parses flag definitions from the argument list, which should not +// include the command name. Must be called after all flags in the FlagSet +// are defined and before flags are accessed by the program. +// The return value will be ErrHelp if -help was set but not defined. +func (f *FlagSet) Parse(arguments []string) error { + f.parsed = true + f.args = arguments + for { + seen, err := f.parseOne() + if seen { + continue + } + if err == nil { + break + } + switch f.errorHandling { + case ContinueOnError: + return err + case ExitOnError: + os.Exit(2) + case PanicOnError: + panic(err) + } + } + + // Parse environment variables + f.ParseEnv(os.Environ()) + + // Parse configuration from file + configFlag := f.actual["config"] + if configFlag != nil { + f.ParseFile(configFlag.Value.String()) + } + + return nil +} + +// ParseEnv parses flags from environment variables. +// Flags already set will be ignored. +func (f *FlagSet) ParseEnv(environ []string) error { + + m := f.formal + + env := make(map[string]string) + for _, s := range environ { + i := strings.Index(s, "=") + if i < 1 { + continue + } + env[s[0:i]] = s[i+1 : len(s)] + } + + for _, flag := range m { + name := flag.Name + _, set := f.actual[name] + if set { + continue + } + + flag, alreadythere := m[name] + if !alreadythere { + if name == "help" || name == "h" { // special case for nice help message. + f.usage() + return ErrHelp + } + return f.failf("environment variable provided but not defined: %s", name) + } + + envKey := strings.ToUpper(flag.Name) + if f.envPrefix != "" { + envKey = f.envPrefix + "_" + envKey + } + envKey = strings.Replace(envKey, "-", "_", -1) + + value, isSet := env[envKey] + if !isSet { + continue + } + + hasValue := false + if len(value) > 0 { + hasValue = true + } + + if fv, ok := flag.Value.(boolFlag); ok && fv.IsBoolFlag() { // special case: doesn't need an arg + if hasValue { + if err := fv.Set(value); err != nil { + return f.failf("invalid boolean value %q for environment variable %s: %v", value, name, err) + } + } else { + // flag without value is regarded a bool + fv.Set("true") + } + } else { + if !hasValue { + return f.failf("environment variable needs an value: %s", name) + } + + if err := flag.Value.Set(value); err != nil { + return f.failf("invalid value %q for environment variable %s: %v", value, name, err) + } + } + + // update f.actual + if f.actual == nil { + f.actual = make(map[string]*Flag) + } + f.actual[name] = flag + + } + return nil +} + +// ParseFile parses flags from the file in path. +// Same format as commandline argumens, newlines and lines beginning with a +// "#" charater are ignored. Flags already set will be ignored. +func (f *FlagSet) ParseFile(path string) error { + + // Extract arguments from file + fp, err := os.Open(path) + if err != nil { + return err + } + defer fp.Close() + + scanner := bufio.NewScanner(fp) + for scanner.Scan() { + line := scanner.Text() + + // Ignore empty lines + if len(line) == 0 { + continue + } + + // Ignore comments + if line[:1] == "#" { + continue + } + + // Match `key=value` and `key value` + var name, value string + hasValue := false + for i, v := range line { + if v == '=' || v == ' ' { + hasValue = true + name, value = line[:i], line[i+1:] + break + } + } + + if hasValue == false { + name = line + } + + // Ignore flag when already set; arguments have precedence over file + if f.actual[name] != nil { + continue + } + + m := f.formal + flag, alreadythere := m[name] + if !alreadythere { + if name == "help" || name == "h" { // special case for nice help message. + f.usage() + return ErrHelp + } + return f.failf("configuration variable provided but not defined: %s", name) + } + + if fv, ok := flag.Value.(boolFlag); ok && fv.IsBoolFlag() { // special case: doesn't need an arg + if hasValue { + if err := fv.Set(value); err != nil { + return f.failf("invalid boolean value %q for configuration variable %s: %v", value, name, err) + } + } else { + // flag without value is regarded a bool + fv.Set("true") + } + } else { + if !hasValue { + return f.failf("configuration variable needs an argument: %s", name) + } + + if err := flag.Value.Set(value); err != nil { + return f.failf("invalid value %q for configuration variable %s: %v", value, name, err) + } + } + + // update f.actual + if f.actual == nil { + f.actual = make(map[string]*Flag) + } + f.actual[name] = flag + } + + if err := scanner.Err(); err != nil { + return err + } + + return nil +} + +// Parsed reports whether f.Parse has been called. +func (f *FlagSet) Parsed() bool { + return f.parsed +} + +// Parse parses the command-line flags from os.Args[1:]. Must be called +// after all flags are defined and before flags are accessed by the program. +func Parse() { + // Ignore errors; CommandLine is set for ExitOnError. + CommandLine.Parse(os.Args[1:]) +} + +// Parsed returns true if the command-line flags have been parsed. +func Parsed() bool { + return CommandLine.Parsed() +} + +// CommandLine is the default set of command-line flags, parsed from os.Args. +// The top-level functions such as BoolVar, Arg, and on are wrappers for the +// methods of CommandLine. +var CommandLine = NewFlagSet(os.Args[0], ExitOnError) + +// NewFlagSet returns a new, empty flag set with the specified name and +// error handling property. +func NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet { + f := &FlagSet{ + name: name, + errorHandling: errorHandling, + } + return f +} + +// NewFlagSetWithEnvPrefix returns a new empty flag set with the specified name, +// environment variable prefix, and error handling property. +func NewFlagSetWithEnvPrefix(name string, prefix string, errorHandling ErrorHandling) *FlagSet { + f := NewFlagSet(name, errorHandling) + f.envPrefix = prefix + return f +} + +// Init sets the name, environment name prefix, and error handling property +// for a flag set. +// By default, the zero FlagSet uses an empty name, EnvironmentPrefix, and the +// ContinueOnError error handling policy. +func (f *FlagSet) Init(name string, errorHandling ErrorHandling) { + f.name = name + f.envPrefix = EnvironmentPrefix + f.errorHandling = errorHandling +} diff --git a/Godeps/_workspace/src/github.com/namsral/flag/flag_test.go b/Godeps/_workspace/src/github.com/namsral/flag/flag_test.go new file mode 100644 index 000000000..c0ed7fb15 --- /dev/null +++ b/Godeps/_workspace/src/github.com/namsral/flag/flag_test.go @@ -0,0 +1,475 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package flag + +import ( + "bytes" + "fmt" + "os" + "sort" + "strings" + "syscall" + "testing" + "time" +) + +func boolString(s string) string { + if s == "0" { + return "false" + } + return "true" +} + +func TestEverything(t *testing.T) { + ResetForTesting(nil) + Bool("test_bool", false, "bool value") + Int("test_int", 0, "int value") + Int64("test_int64", 0, "int64 value") + Uint("test_uint", 0, "uint value") + Uint64("test_uint64", 0, "uint64 value") + String("test_string", "0", "string value") + Float64("test_float64", 0, "float64 value") + Duration("test_duration", 0, "time.Duration value") + + m := make(map[string]*Flag) + desired := "0" + visitor := func(f *Flag) { + if len(f.Name) > 5 && f.Name[0:5] == "test_" { + m[f.Name] = f + ok := false + switch { + case f.Value.String() == desired: + ok = true + case f.Name == "test_bool" && f.Value.String() == boolString(desired): + ok = true + case f.Name == "test_duration" && f.Value.String() == desired+"s": + ok = true + } + if !ok { + t.Error("Visit: bad value", f.Value.String(), "for", f.Name) + } + } + } + VisitAll(visitor) + if len(m) != 8 { + t.Error("VisitAll misses some flags") + for k, v := range m { + t.Log(k, *v) + } + } + m = make(map[string]*Flag) + Visit(visitor) + if len(m) != 0 { + t.Errorf("Visit sees unset flags") + for k, v := range m { + t.Log(k, *v) + } + } + // Now set all flags + Set("test_bool", "true") + Set("test_int", "1") + Set("test_int64", "1") + Set("test_uint", "1") + Set("test_uint64", "1") + Set("test_string", "1") + Set("test_float64", "1") + Set("test_duration", "1s") + desired = "1" + Visit(visitor) + if len(m) != 8 { + t.Error("Visit fails after set") + for k, v := range m { + t.Log(k, *v) + } + } + // Now test they're visited in sort order. + var flagNames []string + Visit(func(f *Flag) { flagNames = append(flagNames, f.Name) }) + if !sort.StringsAreSorted(flagNames) { + t.Errorf("flag names not sorted: %v", flagNames) + } +} + +func TestGet(t *testing.T) { + ResetForTesting(nil) + Bool("test_bool", true, "bool value") + Int("test_int", 1, "int value") + Int64("test_int64", 2, "int64 value") + Uint("test_uint", 3, "uint value") + Uint64("test_uint64", 4, "uint64 value") + String("test_string", "5", "string value") + Float64("test_float64", 6, "float64 value") + Duration("test_duration", 7, "time.Duration value") + + visitor := func(f *Flag) { + if len(f.Name) > 5 && f.Name[0:5] == "test_" { + g, ok := f.Value.(Getter) + if !ok { + t.Errorf("Visit: value does not satisfy Getter: %T", f.Value) + return + } + switch f.Name { + case "test_bool": + ok = g.Get() == true + case "test_int": + ok = g.Get() == int(1) + case "test_int64": + ok = g.Get() == int64(2) + case "test_uint": + ok = g.Get() == uint(3) + case "test_uint64": + ok = g.Get() == uint64(4) + case "test_string": + ok = g.Get() == "5" + case "test_float64": + ok = g.Get() == float64(6) + case "test_duration": + ok = g.Get() == time.Duration(7) + } + if !ok { + t.Errorf("Visit: bad value %T(%v) for %s", g.Get(), g.Get(), f.Name) + } + } + } + VisitAll(visitor) +} + +func TestUsage(t *testing.T) { + called := false + ResetForTesting(func() { called = true }) + if CommandLine.Parse([]string{"-x"}) == nil { + t.Error("parse did not fail for unknown flag") + } + if !called { + t.Error("did not call Usage for unknown flag") + } +} + +func testParse(f *FlagSet, t *testing.T) { + if f.Parsed() { + t.Error("f.Parse() = true before Parse") + } + boolFlag := f.Bool("bool", false, "bool value") + bool2Flag := f.Bool("bool2", false, "bool2 value") + intFlag := f.Int("int", 0, "int value") + int64Flag := f.Int64("int64", 0, "int64 value") + uintFlag := f.Uint("uint", 0, "uint value") + uint64Flag := f.Uint64("uint64", 0, "uint64 value") + stringFlag := f.String("string", "0", "string value") + float64Flag := f.Float64("float64", 0, "float64 value") + durationFlag := f.Duration("duration", 5*time.Second, "time.Duration value") + extra := "one-extra-argument" + args := []string{ + "-bool", + "-bool2=true", + "--int", "22", + "--int64", "0x23", + "-uint", "24", + "--uint64", "25", + "-string", "hello", + "-float64", "2718e28", + "-duration", "2m", + extra, + } + if err := f.Parse(args); err != nil { + t.Fatal(err) + } + if !f.Parsed() { + t.Error("f.Parse() = false after Parse") + } + if *boolFlag != true { + t.Error("bool flag should be true, is ", *boolFlag) + } + if *bool2Flag != true { + t.Error("bool2 flag should be true, is ", *bool2Flag) + } + if *intFlag != 22 { + t.Error("int flag should be 22, is ", *intFlag) + } + if *int64Flag != 0x23 { + t.Error("int64 flag should be 0x23, is ", *int64Flag) + } + if *uintFlag != 24 { + t.Error("uint flag should be 24, is ", *uintFlag) + } + if *uint64Flag != 25 { + t.Error("uint64 flag should be 25, is ", *uint64Flag) + } + if *stringFlag != "hello" { + t.Error("string flag should be `hello`, is ", *stringFlag) + } + if *float64Flag != 2718e28 { + t.Error("float64 flag should be 2718e28, is ", *float64Flag) + } + if *durationFlag != 2*time.Minute { + t.Error("duration flag should be 2m, is ", *durationFlag) + } + if len(f.Args()) != 1 { + t.Error("expected one argument, got", len(f.Args())) + } else if f.Args()[0] != extra { + t.Errorf("expected argument %q got %q", extra, f.Args()[0]) + } +} + +func TestParse(t *testing.T) { + ResetForTesting(func() { t.Error("bad parse") }) + testParse(CommandLine, t) +} + +func TestFlagSetParse(t *testing.T) { + testParse(NewFlagSet("test", ContinueOnError), t) +} + +// Declare a user-defined flag type. +type flagVar []string + +func (f *flagVar) String() string { + return fmt.Sprint([]string(*f)) +} + +func (f *flagVar) Set(value string) error { + *f = append(*f, value) + return nil +} + +func TestUserDefined(t *testing.T) { + var flags FlagSet + flags.Init("test", ContinueOnError) + var v flagVar + flags.Var(&v, "v", "usage") + if err := flags.Parse([]string{"-v", "1", "-v", "2", "-v=3"}); err != nil { + t.Error(err) + } + if len(v) != 3 { + t.Fatal("expected 3 args; got ", len(v)) + } + expect := "[1 2 3]" + if v.String() != expect { + t.Errorf("expected value %q got %q", expect, v.String()) + } +} + +// Declare a user-defined boolean flag type. +type boolFlagVar struct { + count int +} + +func (b *boolFlagVar) String() string { + return fmt.Sprintf("%d", b.count) +} + +func (b *boolFlagVar) Set(value string) error { + if value == "true" { + b.count++ + } + return nil +} + +func (b *boolFlagVar) IsBoolFlag() bool { + return b.count < 4 +} + +func TestUserDefinedBool(t *testing.T) { + var flags FlagSet + flags.Init("test", ContinueOnError) + var b boolFlagVar + var err error + flags.Var(&b, "b", "usage") + if err = flags.Parse([]string{"-b", "-b", "-b", "-b=true", "-b=false", "-b", "barg", "-b"}); err != nil { + if b.count < 4 { + t.Error(err) + } + } + + if b.count != 4 { + t.Errorf("want: %d; got: %d", 4, b.count) + } + + if err == nil { + t.Error("expected error; got none") + } +} + +func TestSetOutput(t *testing.T) { + var flags FlagSet + var buf bytes.Buffer + flags.SetOutput(&buf) + flags.Init("test", ContinueOnError) + flags.Parse([]string{"-unknown"}) + if out := buf.String(); !strings.Contains(out, "-unknown") { + t.Logf("expected output mentioning unknown; got %q", out) + } +} + +// This tests that one can reset the flags. This still works but not well, and is +// superseded by FlagSet. +func TestChangingArgs(t *testing.T) { + ResetForTesting(func() { t.Fatal("bad parse") }) + oldArgs := os.Args + defer func() { os.Args = oldArgs }() + os.Args = []string{"cmd", "-before", "subcmd", "-after", "args"} + before := Bool("before", false, "") + if err := CommandLine.Parse(os.Args[1:]); err != nil { + t.Fatal(err) + } + cmd := Arg(0) + os.Args = Args() + after := Bool("after", false, "") + Parse() + args := Args() + + if !*before || cmd != "subcmd" || !*after || len(args) != 1 || args[0] != "args" { + t.Fatalf("expected true subcmd true [args] got %v %v %v %v", *before, cmd, *after, args) + } +} + +// Test that -help invokes the usage message and returns ErrHelp. +func TestHelp(t *testing.T) { + var helpCalled = false + fs := NewFlagSet("help test", ContinueOnError) + fs.Usage = func() { helpCalled = true } + var flag bool + fs.BoolVar(&flag, "flag", false, "regular flag") + // Regular flag invocation should work + err := fs.Parse([]string{"-flag=true"}) + if err != nil { + t.Fatal("expected no error; got ", err) + } + if !flag { + t.Error("flag was not set by -flag") + } + if helpCalled { + t.Error("help called for regular flag") + helpCalled = false // reset for next test + } + // Help flag should work as expected. + err = fs.Parse([]string{"-help"}) + if err == nil { + t.Fatal("error expected") + } + if err != ErrHelp { + t.Fatal("expected ErrHelp; got ", err) + } + if !helpCalled { + t.Fatal("help was not called") + } + // If we define a help flag, that should override. + var help bool + fs.BoolVar(&help, "help", false, "help flag") + helpCalled = false + err = fs.Parse([]string{"-help"}) + if err != nil { + t.Fatal("expected no error for defined -help; got ", err) + } + if helpCalled { + t.Fatal("help was called; should not have been for defined help flag") + } +} + +// Test parsing a environment variables +func TestParseEnv(t *testing.T) { + + syscall.Setenv("BOOL", "") + syscall.Setenv("BOOL2", "true") + syscall.Setenv("INT", "22") + syscall.Setenv("INT64", "0x23") + syscall.Setenv("UINT", "24") + syscall.Setenv("UINT64", "25") + syscall.Setenv("STRING", "hello") + syscall.Setenv("FLOAT64", "2718e28") + syscall.Setenv("DURATION", "2m") + + f := NewFlagSet(os.Args[0], ContinueOnError) + + boolFlag := f.Bool("bool", false, "bool value") + bool2Flag := f.Bool("bool2", false, "bool2 value") + intFlag := f.Int("int", 0, "int value") + int64Flag := f.Int64("int64", 0, "int64 value") + uintFlag := f.Uint("uint", 0, "uint value") + uint64Flag := f.Uint64("uint64", 0, "uint64 value") + stringFlag := f.String("string", "0", "string value") + float64Flag := f.Float64("float64", 0, "float64 value") + durationFlag := f.Duration("duration", 5*time.Second, "time.Duration value") + + err := f.ParseEnv(os.Environ()) + if err != nil { + t.Fatal("expected no error; got ", err) + } + if *boolFlag != true { + t.Error("bool flag should be true, is ", *boolFlag) + } + if *bool2Flag != true { + t.Error("bool2 flag should be true, is ", *bool2Flag) + } + if *intFlag != 22 { + t.Error("int flag should be 22, is ", *intFlag) + } + if *int64Flag != 0x23 { + t.Error("int64 flag should be 0x23, is ", *int64Flag) + } + if *uintFlag != 24 { + t.Error("uint flag should be 24, is ", *uintFlag) + } + if *uint64Flag != 25 { + t.Error("uint64 flag should be 25, is ", *uint64Flag) + } + if *stringFlag != "hello" { + t.Error("string flag should be `hello`, is ", *stringFlag) + } + if *float64Flag != 2718e28 { + t.Error("float64 flag should be 2718e28, is ", *float64Flag) + } + if *durationFlag != 2*time.Minute { + t.Error("duration flag should be 2m, is ", *durationFlag) + } +} + +// Test parsing a configuration file +func TestParseFile(t *testing.T) { + + f := NewFlagSet(os.Args[0], ContinueOnError) + + boolFlag := f.Bool("bool", false, "bool value") + bool2Flag := f.Bool("bool2", false, "bool2 value") + intFlag := f.Int("int", 0, "int value") + int64Flag := f.Int64("int64", 0, "int64 value") + uintFlag := f.Uint("uint", 0, "uint value") + uint64Flag := f.Uint64("uint64", 0, "uint64 value") + stringFlag := f.String("string", "0", "string value") + float64Flag := f.Float64("float64", 0, "float64 value") + durationFlag := f.Duration("duration", 5*time.Second, "time.Duration value") + + err := f.ParseFile("./testdata/test.conf") + if err != nil { + t.Fatal("expected no error; got ", err) + } + if *boolFlag != true { + t.Error("bool flag should be true, is ", *boolFlag) + } + if *bool2Flag != true { + t.Error("bool2 flag should be true, is ", *bool2Flag) + } + if *intFlag != 22 { + t.Error("int flag should be 22, is ", *intFlag) + } + if *int64Flag != 0x23 { + t.Error("int64 flag should be 0x23, is ", *int64Flag) + } + if *uintFlag != 24 { + t.Error("uint flag should be 24, is ", *uintFlag) + } + if *uint64Flag != 25 { + t.Error("uint64 flag should be 25, is ", *uint64Flag) + } + if *stringFlag != "hello" { + t.Error("string flag should be `hello`, is ", *stringFlag) + } + if *float64Flag != 2718e28 { + t.Error("float64 flag should be 2718e28, is ", *float64Flag) + } + if *durationFlag != 2*time.Minute { + t.Error("duration flag should be 2m, is ", *durationFlag) + } +} diff --git a/Godeps/_workspace/src/github.com/namsral/flag/testdata/test.conf b/Godeps/_workspace/src/github.com/namsral/flag/testdata/test.conf new file mode 100644 index 000000000..e06bbba0f --- /dev/null +++ b/Godeps/_workspace/src/github.com/namsral/flag/testdata/test.conf @@ -0,0 +1,11 @@ +# this is a comment followed by an empty line + +bool +bool2=true +int 22 +int64 0x23 +uint 24 +uint64 25 +string hello +float64 2718e28 +duration 2m \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/naoina/go-stringutil/.travis.yml b/Godeps/_workspace/src/github.com/naoina/go-stringutil/.travis.yml deleted file mode 100644 index 926eb992a..000000000 --- a/Godeps/_workspace/src/github.com/naoina/go-stringutil/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: go -go: - - 1.3 - - 1.4 - - tip -install: - - go get -v github.com/naoina/go-stringutil -script: - - go test -v ./... -bench . -benchmem diff --git a/Godeps/_workspace/src/github.com/naoina/go-stringutil/LICENSE b/Godeps/_workspace/src/github.com/naoina/go-stringutil/LICENSE deleted file mode 100644 index 0fff1c58b..000000000 --- a/Godeps/_workspace/src/github.com/naoina/go-stringutil/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015 Naoya Inada - -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/Godeps/_workspace/src/github.com/naoina/go-stringutil/README.md b/Godeps/_workspace/src/github.com/naoina/go-stringutil/README.md deleted file mode 100644 index 87772e88d..000000000 --- a/Godeps/_workspace/src/github.com/naoina/go-stringutil/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# stringutil [![Build Status](https://travis-ci.org/naoina/go-stringutil.png?branch=master)](https://travis-ci.org/naoina/go-stringutil) - -## Installation - - go get -u github.com/naoina/go-stringutil - -## Documentation - -See https://godoc.org/github.com/naoina/go-stringutil - -## License - -MIT diff --git a/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings.go b/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings.go deleted file mode 100644 index c0fdd4cc1..000000000 --- a/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings.go +++ /dev/null @@ -1,120 +0,0 @@ -package stringutil - -import ( - "bytes" - "unicode" -) - -// ToUpperCamelCase returns a copy of the string s with all Unicode letters mapped to their camel case. -// It will convert to upper case previous letter of '_' and first letter, and remove letter of '_'. -func ToUpperCamelCase(s string) string { - if s == "" { - return "" - } - upper := true - var result bytes.Buffer - for _, c := range s { - if c == '_' { - upper = true - continue - } - if upper { - result.WriteRune(unicode.ToUpper(c)) - upper = false - continue - } - result.WriteRune(c) - } - return result.String() -} - -// ToUpperCamelCaseASCII is similar to ToUpperCamelCase, but optimized for -// only the ASCII characters. -// ToUpperCamelCaseASCII is faster than ToUpperCamelCase, but doesn't work if -// contains non-ASCII characters. -func ToUpperCamelCaseASCII(s string) string { - if s == "" { - return "" - } - upper := true - result := make([]byte, 0, len(s)) - for i := 0; i < len(s); i++ { - c := s[i] - if c == '_' { - upper = true - continue - } - if upper { - result = append(result, toUpperASCII(c)) - upper = false - continue - } - result = append(result, c) - } - return string(result) -} - -// ToSnakeCase returns a copy of the string s with all Unicode letters mapped to their snake case. -// It will insert letter of '_' at position of previous letter of uppercase and all -// letters convert to lower case. -func ToSnakeCase(s string) string { - if s == "" { - return "" - } - var result bytes.Buffer - for _, c := range s { - if unicode.IsUpper(c) { - result.WriteByte('_') - } - result.WriteRune(unicode.ToLower(c)) - } - s = result.String() - if s[0] == '_' { - return s[1:] - } - return s -} - -// ToSnakeCaseASCII is similar to ToSnakeCase, but optimized for only the ASCII -// characters. -// ToSnakeCaseASCII is faster than ToSnakeCase, but doesn't work correctly if -// contains non-ASCII characters. -func ToSnakeCaseASCII(s string) string { - if s == "" { - return "" - } - result := make([]byte, 0, len(s)) - for i := 0; i < len(s); i++ { - c := s[i] - if isUpperASCII(c) { - result = append(result, '_') - } - result = append(result, toLowerASCII(c)) - } - if result[0] == '_' { - return string(result[1:]) - } - return string(result) -} - -func isUpperASCII(c byte) bool { - return 'A' <= c && c <= 'Z' -} - -func isLowerASCII(c byte) bool { - return 'a' <= c && c <= 'z' -} - -func toUpperASCII(c byte) byte { - if isLowerASCII(c) { - return c - ('a' - 'A') - } - return c -} - -func toLowerASCII(c byte) byte { - if isUpperASCII(c) { - return c + 'a' - 'A' - } - return c -} diff --git a/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_bench_test.go b/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_bench_test.go deleted file mode 100644 index c6337eb94..000000000 --- a/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_bench_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package stringutil_test - -import ( - "testing" - - "github.com/drone/drone/Godeps/_workspace/src/github.com/naoina/go-stringutil" -) - -var benchcaseForCamelCase = "the_quick_brown_fox_jumps_over_the_lazy_dog" - -func BenchmarkToUpperCamelCase(b *testing.B) { - for i := 0; i < b.N; i++ { - stringutil.ToUpperCamelCase(benchcaseForCamelCase) - } -} - -func BenchmarkToUpperCamelCaseASCII(b *testing.B) { - for i := 0; i < b.N; i++ { - stringutil.ToUpperCamelCaseASCII(benchcaseForCamelCase) - } -} - -var benchcaseForSnakeCase = "TheQuickBrownFoxJumpsOverTheLazyDog" - -func BenchmarkToSnakeCase(b *testing.B) { - for i := 0; i < b.N; i++ { - stringutil.ToSnakeCase(benchcaseForSnakeCase) - } -} - -func BenchmarkToSnakeCaseASCII(b *testing.B) { - for i := 0; i < b.N; i++ { - stringutil.ToSnakeCaseASCII(benchcaseForSnakeCase) - } -} diff --git a/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_test.go b/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_test.go deleted file mode 100644 index 3cf16d93a..000000000 --- a/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package stringutil_test - -import ( - "reflect" - "testing" - - "github.com/drone/drone/Godeps/_workspace/src/github.com/naoina/go-stringutil" -) - -func TestToUpperCamelCase(t *testing.T) { - for _, v := range []struct { - input, expect string - }{ - {"", ""}, - {"thequickbrownfoxoverthelazydog", "Thequickbrownfoxoverthelazydog"}, - {"thequickbrownfoxoverthelazydoG", "ThequickbrownfoxoverthelazydoG"}, - {"thequickbrownfoxoverthelazydo_g", "ThequickbrownfoxoverthelazydoG"}, - {"TheQuickBrownFoxJumpsOverTheLazyDog", "TheQuickBrownFoxJumpsOverTheLazyDog"}, - {"the_quick_brown_fox_jumps_over_the_lazy_dog", "TheQuickBrownFoxJumpsOverTheLazyDog"}, - {"the_Quick_Brown_Fox_Jumps_Over_The_Lazy_Dog", "TheQuickBrownFoxJumpsOverTheLazyDog"}, - {"the_quick_brown_fox_over_the_lazy_dog", "TheQuickBrownFoxOverTheLazyDog"}, - } { - actual := stringutil.ToUpperCamelCase(v.input) - expect := v.expect - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`stringutil.ToUpperCamelCase(%#v) => %#v; want %#v`, v.input, actual, expect) - } - } -} - -func TestToUpperCamelCaseASCII(t *testing.T) { - for _, v := range []struct { - input, expect string - }{ - {"", ""}, - {"thequickbrownfoxoverthelazydog", "Thequickbrownfoxoverthelazydog"}, - {"thequickbrownfoxoverthelazydoG", "ThequickbrownfoxoverthelazydoG"}, - {"thequickbrownfoxoverthelazydo_g", "ThequickbrownfoxoverthelazydoG"}, - {"TheQuickBrownFoxJumpsOverTheLazyDog", "TheQuickBrownFoxJumpsOverTheLazyDog"}, - {"the_quick_brown_fox_jumps_over_the_lazy_dog", "TheQuickBrownFoxJumpsOverTheLazyDog"}, - {"the_Quick_Brown_Fox_Jumps_Over_The_Lazy_Dog", "TheQuickBrownFoxJumpsOverTheLazyDog"}, - } { - actual := stringutil.ToUpperCamelCaseASCII(v.input) - expect := v.expect - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`stringutil.ToUpperCamelCaseASCII(%#v) => %#v; want %#v`, v.input, actual, expect) - } - } -} - -func TestToSnakeCase(t *testing.T) { - for _, v := range []struct { - input, expect string - }{ - {"", ""}, - {"thequickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthelazydog"}, - {"Thequickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthelazydog"}, - {"ThequickbrownfoxjumpsoverthelazydoG", "thequickbrownfoxjumpsoverthelazydo_g"}, - {"TheQuickBrownFoxJumpsOverTheLazyDog", "the_quick_brown_fox_jumps_over_the_lazy_dog"}, - {"the_quick_brown_fox_jumps_over_the_lazy_dog", "the_quick_brown_fox_jumps_over_the_lazy_dog"}, - {"TheQuickBrownFoxOverTheLazyDog", "the_quick_brown_fox_over_the_lazy_dog"}, - } { - actual := stringutil.ToSnakeCase(v.input) - expect := v.expect - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`stringutil.ToSnakeCase(%#v) => %#v; want %#v`, v.input, actual, expect) - } - } -} - -func TestToSnakeCaseASCII(t *testing.T) { - for _, v := range []struct { - input, expect string - }{ - {"", ""}, - {"thequickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthelazydog"}, - {"Thequickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthelazydog"}, - {"ThequickbrownfoxjumpsoverthelazydoG", "thequickbrownfoxjumpsoverthelazydo_g"}, - {"TheQuickBrownFoxJumpsOverTheLazyDog", "the_quick_brown_fox_jumps_over_the_lazy_dog"}, - {"the_quick_brown_fox_jumps_over_the_lazy_dog", "the_quick_brown_fox_jumps_over_the_lazy_dog"}, - } { - actual := stringutil.ToSnakeCaseASCII(v.input) - expect := v.expect - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`stringutil.ToSnakeCaseASCII(%#v) => %#v; want %#v`, v.input, actual, expect) - } - } -} diff --git a/Godeps/_workspace/src/github.com/naoina/toml/.travis.yml b/Godeps/_workspace/src/github.com/naoina/toml/.travis.yml deleted file mode 100644 index 6bd7b6df3..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: go - -go: - - 1.3 - - tip - -install: - - go get -v ./... - -script: - - go test ./... diff --git a/Godeps/_workspace/src/github.com/naoina/toml/LICENSE b/Godeps/_workspace/src/github.com/naoina/toml/LICENSE deleted file mode 100644 index e65039ad8..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2014 Naoya Inada - -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/Godeps/_workspace/src/github.com/naoina/toml/Makefile b/Godeps/_workspace/src/github.com/naoina/toml/Makefile deleted file mode 100644 index 10dc5a553..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -GO = go -PEG = peg - -.SUFFIXES: .peg .peg.go - -.PHONY: all test clean -all: parse.peg.go - -.peg.peg.go: - $(PEG) -switch -inline $< - -test: all - $(GO) test ./... - -clean: - $(RM) *.peg.go diff --git a/Godeps/_workspace/src/github.com/naoina/toml/README.md b/Godeps/_workspace/src/github.com/naoina/toml/README.md deleted file mode 100644 index 7330ce4d0..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/README.md +++ /dev/null @@ -1,364 +0,0 @@ -# TOML parser and encoder library for Golang [![Build Status](https://travis-ci.org/naoina/toml.png?branch=master)](https://travis-ci.org/naoina/toml) - -[TOML](https://github.com/toml-lang/toml) parser and encoder library for [Golang](http://golang.org/). - -This library is compatible with TOML version [v0.4.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md). - -## Installation - - go get -u github.com/naoina/toml - -## Usage - -The following TOML save as `example.toml`. - -```toml -# This is a TOML document. Boom. - -title = "TOML Example" - -[owner] -name = "Lance Uppercut" -dob = 1979-05-27T07:32:00-08:00 # First class dates? Why not? - -[database] -server = "192.168.1.1" -ports = [ 8001, 8001, 8002 ] -connection_max = 5000 -enabled = true - -[servers] - - # You can indent as you please. Tabs or spaces. TOML don't care. - [servers.alpha] - ip = "10.0.0.1" - dc = "eqdc10" - - [servers.beta] - ip = "10.0.0.2" - dc = "eqdc10" - -[clients] -data = [ ["gamma", "delta"], [1, 2] ] - -# Line breaks are OK when inside arrays -hosts = [ - "alpha", - "omega" -] -``` - -Then above TOML will mapping to `tomlConfig` struct using `toml.Unmarshal`. - -```go -package main - -import ( - "io/ioutil" - "os" - "time" - - "github.com/naoina/toml" -) - -type tomlConfig struct { - Title string - Owner struct { - Name string - Dob time.Time - } - Database struct { - Server string - Ports []int - ConnectionMax uint - Enabled bool - } - Servers map[string]Server - Clients struct { - Data [][]interface{} - Hosts []string - } -} - -type Server struct { - IP string - DC string -} - -func main() { - f, err := os.Open("example.toml") - if err != nil { - panic(err) - } - defer f.Close() - buf, err := ioutil.ReadAll(f) - if err != nil { - panic(err) - } - var config tomlConfig - if err := toml.Unmarshal(buf, &config); err != nil { - panic(err) - } - // then to use the unmarshaled config... -} -``` - -## Mappings - -A key and value of TOML will map to the corresponding field. -The fields of struct for mapping must be exported. - -The rules of the mapping of key are following: - -#### Exact matching - -```toml -timeout_seconds = 256 -``` - -```go -type Config struct { - Timeout_seconds int -} -``` - -#### Camelcase matching - -```toml -server_name = "srv1" -``` - -```go -type Config struct { - ServerName string -} -``` - -#### Uppercase matching - -```toml -ip = "10.0.0.1" -``` - -```go -type Config struct { - IP string -} -``` - -See the following examples for the value mappings. - -### String - -```toml -val = "string" -``` - -```go -type Config struct { - Val string -} -``` - -### Integer - -```toml -val = 100 -``` - -```go -type Config struct { - Val int -} -``` - -All types that can be used are following: - -* int8 (from `-128` to `127`) -* int16 (from `-32768` to `32767`) -* int32 (from `-2147483648` to `2147483647`) -* int64 (from `-9223372036854775808` to `9223372036854775807`) -* int (same as `int32` on 32bit environment, or `int64` on 64bit environment) -* uint8 (from `0` to `255`) -* uint16 (from `0` to `65535`) -* uint32 (from `0` to `4294967295`) -* uint64 (from `0` to `18446744073709551615`) -* uint (same as `uint` on 32bit environment, or `uint64` on 64bit environment) - -### Float - -```toml -val = 3.1415 -``` - -```go -type Config struct { - Val float32 -} -``` - -All types that can be used are following: - -* float32 -* float64 - -### Boolean - -```toml -val = true -``` - -```go -type Config struct { - Val bool -} -``` - -### Datetime - -```toml -val = 2014-09-28T21:27:39Z -``` - -```go -type Config struct { - Val time.Time -} -``` - -### Array - -```toml -val = ["a", "b", "c"] -``` - -```go -type Config struct { - Val []string -} -``` - -Also following examples all can be mapped: - -```toml -val1 = [1, 2, 3] -val2 = [["a", "b"], ["c", "d"]] -val3 = [[1, 2, 3], ["a", "b", "c"]] -val4 = [[1, 2, 3], [["a", "b"], [true, false]]] -``` - -```go -type Config struct { - Val1 []int - Val2 [][]string - Val3 [][]interface{} - Val4 [][]interface{} -} -``` - -### Table - -```toml -[server] -type = "app" - - [server.development] - ip = "10.0.0.1" - - [server.production] - ip = "10.0.0.2" -``` - -```go -type Config struct { - Server map[string]Server -} - -type Server struct { - IP string -} -``` - -You can also use the following struct instead of map of struct. - -```go -type Config struct { - Server struct { - Development Server - Production Server - } -} - -type Server struct { - IP string -} -``` - -### Array of Tables - -```toml -[[fruit]] - name = "apple" - - [fruit.physical] - color = "red" - shape = "round" - - [[fruit.variety]] - name = "red delicious" - - [[fruit.variety]] - name = "granny smith" - -[[fruit]] - name = "banana" - - [[fruit.variety]] - name = "plantain" -``` - -```go -type Config struct { - Fruit []struct { - Name string - Physical struct { - Color string - Shape string - } - Variety []struct { - Name string - } - } -} -``` - -### Using `toml.UnmarshalTOML` interface - -```toml -duration = "10s" -``` - -```go -import time - -type Config struct { - Duration Duration -} - -type Duration struct { - time.Duration -} - -func (d *Duration) UnmarshalTOML(data []byte) error { - d.Duration, err := time.ParseDuration(string(data)) - return err -} -``` - -## API documentation - -See [Godoc](http://godoc.org/github.com/naoina/toml). - -## License - -MIT diff --git a/Godeps/_workspace/src/github.com/naoina/toml/ast/ast.go b/Godeps/_workspace/src/github.com/naoina/toml/ast/ast.go deleted file mode 100644 index 68bb0ee15..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/ast/ast.go +++ /dev/null @@ -1,184 +0,0 @@ -package ast - -import ( - "strconv" - "time" -) - -type Position struct { - Begin int - End int -} - -type Value interface { - Pos() int - End() int - Source() string -} - -type String struct { - Position Position - Value string - Data []rune -} - -func (s *String) Pos() int { - return s.Position.Begin -} - -func (s *String) End() int { - return s.Position.End -} - -func (s *String) Source() string { - return string(s.Data) -} - -type Integer struct { - Position Position - Value string - Data []rune -} - -func (i *Integer) Pos() int { - return i.Position.Begin -} - -func (i *Integer) End() int { - return i.Position.End -} - -func (i *Integer) Source() string { - return string(i.Data) -} - -func (i *Integer) Int() (int64, error) { - return strconv.ParseInt(i.Value, 10, 64) -} - -type Float struct { - Position Position - Value string - Data []rune -} - -func (f *Float) Pos() int { - return f.Position.Begin -} - -func (f *Float) End() int { - return f.Position.End -} - -func (f *Float) Source() string { - return string(f.Data) -} - -func (f *Float) Float() (float64, error) { - return strconv.ParseFloat(f.Value, 64) -} - -type Boolean struct { - Position Position - Value string - Data []rune -} - -func (b *Boolean) Pos() int { - return b.Position.Begin -} - -func (b *Boolean) End() int { - return b.Position.End -} - -func (b *Boolean) Source() string { - return string(b.Data) -} - -func (b *Boolean) Boolean() (bool, error) { - return strconv.ParseBool(b.Value) -} - -type Datetime struct { - Position Position - Value string - Data []rune -} - -func (d *Datetime) Pos() int { - return d.Position.Begin -} - -func (d *Datetime) End() int { - return d.Position.End -} - -func (d *Datetime) Source() string { - return string(d.Data) -} - -func (d *Datetime) Time() (time.Time, error) { - return time.Parse(time.RFC3339Nano, d.Value) -} - -type Array struct { - Position Position - Value []Value - Data []rune -} - -func (a *Array) Pos() int { - return a.Position.Begin -} - -func (a *Array) End() int { - return a.Position.End -} - -func (a *Array) Source() string { - return string(a.Data) -} - -type TableType uint8 - -const ( - TableTypeNormal TableType = iota - TableTypeArray -) - -var tableTypes = [...]string{ - "normal", - "array", -} - -func (t TableType) String() string { - return tableTypes[t] -} - -type Table struct { - Position Position - Line int - Name string - Fields map[string]interface{} - Type TableType - Data []rune -} - -func (t *Table) Pos() int { - return t.Position.Begin -} - -func (t *Table) End() int { - return t.Position.End -} - -func (t *Table) Source() string { - return string(t.Data) -} - -type KeyValue struct { - Key string - Value Value - Line int -} diff --git a/Godeps/_workspace/src/github.com/naoina/toml/decode.go b/Godeps/_workspace/src/github.com/naoina/toml/decode.go deleted file mode 100644 index 64d3f2198..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/decode.go +++ /dev/null @@ -1,649 +0,0 @@ -package toml - -import ( - "fmt" - "reflect" - "strconv" - "strings" - - "github.com/drone/drone/Godeps/_workspace/src/github.com/naoina/toml/ast" -) - -const ( - tableSeparator = '.' -) - -var ( - escapeReplacer = strings.NewReplacer( - "\b", "\\n", - "\f", "\\f", - "\n", "\\n", - "\r", "\\r", - "\t", "\\t", - ) - underscoreReplacer = strings.NewReplacer( - "_", "", - ) -) - -// Unmarshal parses the TOML data and stores the result in the value pointed to by v. -// -// Unmarshal will mapped to v that according to following rules: -// -// TOML strings to string -// TOML integers to any int type -// TOML floats to float32 or float64 -// TOML booleans to bool -// TOML datetimes to time.Time -// TOML arrays to any type of slice or []interface{} -// TOML tables to struct -// TOML array of tables to slice of struct -func Unmarshal(data []byte, v interface{}) error { - table, err := Parse(data) - if err != nil { - return err - } - if err := UnmarshalTable(table, v); err != nil { - return fmt.Errorf("toml: unmarshal: %v", err) - } - return nil -} - -// Unmarshaler is the interface implemented by objects that can unmarshal a -// TOML description of themselves. -// The input can be assumed to be a valid encoding of a TOML value. -// UnmarshalJSON must copy the TOML data if it wishes to retain the data after -// returning. -type Unmarshaler interface { - UnmarshalTOML([]byte) error -} - -// UnmarshalTable applies the contents of an ast.Table to the value pointed at by v. -// -// UnmarshalTable will mapped to v that according to following rules: -// -// TOML strings to string -// TOML integers to any int type -// TOML floats to float32 or float64 -// TOML booleans to bool -// TOML datetimes to time.Time -// TOML arrays to any type of slice or []interface{} -// TOML tables to struct -// TOML array of tables to slice of struct -func UnmarshalTable(t *ast.Table, v interface{}) (err error) { - if v == nil { - return fmt.Errorf("v must not be nil") - } - rv := reflect.ValueOf(v) - if kind := rv.Kind(); kind != reflect.Ptr && kind != reflect.Map { - return fmt.Errorf("v must be a pointer or map") - } - for rv.Kind() == reflect.Ptr { - rv = rv.Elem() - } - for key, val := range t.Fields { - switch av := val.(type) { - case *ast.KeyValue: - fv, fieldName, found := findField(rv, key) - if !found { - return fmt.Errorf("line %d: field corresponding to `%s' is not defined in `%T'", av.Line, key, v) - } - switch fv.Kind() { - case reflect.Map: - mv := reflect.New(fv.Type().Elem()).Elem() - if err := UnmarshalTable(t, mv.Addr().Interface()); err != nil { - return err - } - fv.SetMapIndex(reflect.ValueOf(fieldName), mv) - default: - if err := setValue(fv, av.Value); err != nil { - return fmt.Errorf("line %d: %v.%s: %v", av.Line, rv.Type(), fieldName, err) - } - if rv.Kind() == reflect.Map { - rv.SetMapIndex(reflect.ValueOf(fieldName), fv) - } - } - case *ast.Table: - fv, fieldName, found := findField(rv, key) - if !found { - return fmt.Errorf("line %d: field corresponding to `%s' is not defined in `%T'", av.Line, key, v) - } - if err, ok := setUnmarshaler(fv, string(av.Data)); ok { - if err != nil { - return err - } - continue - } - for fv.Kind() == reflect.Ptr { - fv.Set(reflect.New(fv.Type().Elem())) - fv = fv.Elem() - } - switch fv.Kind() { - case reflect.Struct: - vv := reflect.New(fv.Type()).Elem() - if err := UnmarshalTable(av, vv.Addr().Interface()); err != nil { - return err - } - fv.Set(vv) - if rv.Kind() == reflect.Map { - rv.SetMapIndex(reflect.ValueOf(fieldName), fv) - } - case reflect.Map: - mv := reflect.MakeMap(fv.Type()) - if err := UnmarshalTable(av, mv.Interface()); err != nil { - return err - } - fv.Set(mv) - default: - return fmt.Errorf("line %d: `%v.%s' must be struct or map, but %v given", av.Line, rv.Type(), fieldName, fv.Kind()) - } - case []*ast.Table: - fv, fieldName, found := findField(rv, key) - if !found { - return fmt.Errorf("line %d: field corresponding to `%s' is not defined in `%T'", av[0].Line, key, v) - } - data := make([]string, 0, len(av)) - for _, tbl := range av { - data = append(data, string(tbl.Data)) - } - if err, ok := setUnmarshaler(fv, strings.Join(data, "\n")); ok { - if err != nil { - return err - } - continue - } - t := fv.Type().Elem() - pc := 0 - for ; t.Kind() == reflect.Ptr; pc++ { - t = t.Elem() - } - if fv.Kind() != reflect.Slice { - return fmt.Errorf("line %d: `%v.%s' must be slice type, but %v given", av[0].Line, rv.Type(), fieldName, fv.Kind()) - } - for _, tbl := range av { - var vv reflect.Value - switch t.Kind() { - case reflect.Map: - vv = reflect.MakeMap(t) - if err := UnmarshalTable(tbl, vv.Interface()); err != nil { - return err - } - default: - vv = reflect.New(t).Elem() - if err := UnmarshalTable(tbl, vv.Addr().Interface()); err != nil { - return err - } - } - for i := 0; i < pc; i++ { - vv = vv.Addr() - pv := reflect.New(vv.Type()).Elem() - pv.Set(vv) - vv = pv - } - fv.Set(reflect.Append(fv, vv)) - } - if rv.Kind() == reflect.Map { - rv.SetMapIndex(reflect.ValueOf(fieldName), fv) - } - default: - return fmt.Errorf("BUG: unknown type `%T'", t) - } - } - return nil -} - -func setUnmarshaler(lhs reflect.Value, data string) (error, bool) { - for lhs.Kind() == reflect.Ptr { - lhs.Set(reflect.New(lhs.Type().Elem())) - lhs = lhs.Elem() - } - if lhs.CanAddr() { - if u, ok := lhs.Addr().Interface().(Unmarshaler); ok { - return u.UnmarshalTOML([]byte(data)), true - } - } - return nil, false -} - -func setValue(lhs reflect.Value, val ast.Value) error { - for lhs.Kind() == reflect.Ptr { - lhs.Set(reflect.New(lhs.Type().Elem())) - lhs = lhs.Elem() - } - if err, ok := setUnmarshaler(lhs, val.Source()); ok { - return err - } - switch v := val.(type) { - case *ast.Integer: - if err := setInt(lhs, v); err != nil { - return err - } - case *ast.Float: - if err := setFloat(lhs, v); err != nil { - return err - } - case *ast.String: - if err := setString(lhs, v); err != nil { - return err - } - case *ast.Boolean: - if err := setBoolean(lhs, v); err != nil { - return err - } - case *ast.Datetime: - if err := setDatetime(lhs, v); err != nil { - return err - } - case *ast.Array: - if err := setArray(lhs, v); err != nil { - return err - } - } - return nil -} - -func setInt(fv reflect.Value, v *ast.Integer) error { - i, err := v.Int() - if err != nil { - return err - } - switch fv.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - if fv.OverflowInt(i) { - return &errorOutOfRange{fv.Kind(), i} - } - fv.SetInt(i) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - fv.SetUint(uint64(i)) - case reflect.Interface: - fv.Set(reflect.ValueOf(i)) - default: - return fmt.Errorf("`%v' is not any types of int", fv.Type()) - } - return nil -} - -func setFloat(fv reflect.Value, v *ast.Float) error { - f, err := v.Float() - if err != nil { - return err - } - switch fv.Kind() { - case reflect.Float32, reflect.Float64: - if fv.OverflowFloat(f) { - return &errorOutOfRange{fv.Kind(), f} - } - fv.SetFloat(f) - case reflect.Interface: - fv.Set(reflect.ValueOf(f)) - default: - return fmt.Errorf("`%v' is not float32 or float64", fv.Type()) - } - return nil -} - -func setString(fv reflect.Value, v *ast.String) error { - return set(fv, v.Value) -} - -func setBoolean(fv reflect.Value, v *ast.Boolean) error { - b, err := v.Boolean() - if err != nil { - return err - } - return set(fv, b) -} - -func setDatetime(fv reflect.Value, v *ast.Datetime) error { - tm, err := v.Time() - if err != nil { - return err - } - return set(fv, tm) -} - -func setArray(fv reflect.Value, v *ast.Array) error { - if len(v.Value) == 0 { - return nil - } - typ := reflect.TypeOf(v.Value[0]) - for _, vv := range v.Value[1:] { - if typ != reflect.TypeOf(vv) { - return fmt.Errorf("array cannot contain multiple types") - } - } - sliceType := fv.Type() - if fv.Kind() == reflect.Interface { - sliceType = reflect.SliceOf(sliceType) - } - slice := reflect.MakeSlice(sliceType, 0, len(v.Value)) - t := sliceType.Elem() - for _, vv := range v.Value { - tmp := reflect.New(t).Elem() - if err := setValue(tmp, vv); err != nil { - return err - } - slice = reflect.Append(slice, tmp) - } - fv.Set(slice) - return nil -} - -func set(fv reflect.Value, v interface{}) error { - rhs := reflect.ValueOf(v) - if !rhs.Type().AssignableTo(fv.Type()) { - return fmt.Errorf("`%v' type is not assignable to `%v' type", rhs.Type(), fv.Type()) - } - fv.Set(rhs) - return nil -} - -type stack struct { - key string - table *ast.Table -} - -type toml struct { - table *ast.Table - line int - currentTable *ast.Table - s string - key string - val ast.Value - arr *array - tableMap map[string]*ast.Table - stack []*stack - skip bool -} - -func (p *toml) init() { - p.line = 1 - p.table = &ast.Table{ - Line: p.line, - Type: ast.TableTypeNormal, - } - p.tableMap = map[string]*ast.Table{ - "": p.table, - } - p.currentTable = p.table -} - -func (p *toml) Error(err error) { - panic(convertError{fmt.Errorf("toml: line %d: %v", p.line, err)}) -} - -func (p *tomlParser) SetTime(begin, end int) { - p.val = &ast.Datetime{ - Position: ast.Position{Begin: begin, End: end}, - Data: p.buffer[begin:end], - Value: string(p.buffer[begin:end]), - } -} - -func (p *tomlParser) SetFloat64(begin, end int) { - p.val = &ast.Float{ - Position: ast.Position{Begin: begin, End: end}, - Data: p.buffer[begin:end], - Value: underscoreReplacer.Replace(string(p.buffer[begin:end])), - } -} - -func (p *tomlParser) SetInt64(begin, end int) { - p.val = &ast.Integer{ - Position: ast.Position{Begin: begin, End: end}, - Data: p.buffer[begin:end], - Value: underscoreReplacer.Replace(string(p.buffer[begin:end])), - } -} - -func (p *tomlParser) SetString(begin, end int) { - p.val = &ast.String{ - Position: ast.Position{Begin: begin, End: end}, - Data: p.buffer[begin:end], - Value: p.s, - } - p.s = "" -} - -func (p *tomlParser) SetBool(begin, end int) { - p.val = &ast.Boolean{ - Position: ast.Position{Begin: begin, End: end}, - Data: p.buffer[begin:end], - Value: string(p.buffer[begin:end]), - } -} - -func (p *tomlParser) StartArray() { - if p.arr == nil { - p.arr = &array{line: p.line, current: &ast.Array{}} - return - } - p.arr.child = &array{parent: p.arr, line: p.line, current: &ast.Array{}} - p.arr = p.arr.child -} - -func (p *tomlParser) AddArrayVal() { - if p.arr.current == nil { - p.arr.current = &ast.Array{} - } - p.arr.current.Value = append(p.arr.current.Value, p.val) -} - -func (p *tomlParser) SetArray(begin, end int) { - p.arr.current.Position = ast.Position{Begin: begin, End: end} - p.arr.current.Data = p.buffer[begin:end] - p.val = p.arr.current - p.arr = p.arr.parent -} - -func (p *toml) SetTable(buf []rune, begin, end int) { - p.setTable(p.table, buf, begin, end) -} - -func (p *toml) setTable(t *ast.Table, buf []rune, begin, end int) { - name := string(buf[begin:end]) - names := splitTableKey(name) - if t, exists := p.tableMap[name]; exists { - if lt := p.tableMap[names[len(names)-1]]; t.Type == ast.TableTypeArray || lt != nil && lt.Type == ast.TableTypeNormal { - p.Error(fmt.Errorf("table `%s' is in conflict with %v table in line %d", name, t.Type, t.Line)) - } - } - t, err := p.lookupTable(t, names) - if err != nil { - p.Error(err) - } - p.currentTable = t - p.tableMap[name] = p.currentTable -} - -func (p *tomlParser) SetTableString(begin, end int) { - p.currentTable.Data = p.buffer[begin:end] - - p.currentTable.Position.Begin = begin - p.currentTable.Position.End = end -} - -func (p *toml) SetArrayTable(buf []rune, begin, end int) { - p.setArrayTable(p.table, buf, begin, end) -} - -func (p *toml) setArrayTable(t *ast.Table, buf []rune, begin, end int) { - name := string(buf[begin:end]) - if t, exists := p.tableMap[name]; exists && t.Type == ast.TableTypeNormal { - p.Error(fmt.Errorf("table `%s' is in conflict with %v table in line %d", name, t.Type, t.Line)) - } - names := splitTableKey(name) - t, err := p.lookupTable(t, names[:len(names)-1]) - if err != nil { - p.Error(err) - } - last := names[len(names)-1] - tbl := &ast.Table{ - Position: ast.Position{begin, end}, - Line: p.line, - Name: last, - Type: ast.TableTypeArray, - } - switch v := t.Fields[last].(type) { - case nil: - if t.Fields == nil { - t.Fields = make(map[string]interface{}) - } - t.Fields[last] = []*ast.Table{tbl} - case []*ast.Table: - t.Fields[last] = append(v, tbl) - case *ast.KeyValue: - p.Error(fmt.Errorf("key `%s' is in conflict with line %d", last, v.Line)) - default: - p.Error(fmt.Errorf("BUG: key `%s' is in conflict but it's unknown type `%T'", last, v)) - } - p.currentTable = tbl - p.tableMap[name] = p.currentTable -} - -func (p *toml) StartInlineTable() { - p.skip = false - p.stack = append(p.stack, &stack{p.key, p.currentTable}) - buf := []rune(p.key) - if p.arr == nil { - p.setTable(p.currentTable, buf, 0, len(buf)) - } else { - p.setArrayTable(p.currentTable, buf, 0, len(buf)) - } -} - -func (p *toml) EndInlineTable() { - st := p.stack[len(p.stack)-1] - p.key, p.currentTable = st.key, st.table - p.stack[len(p.stack)-1] = nil - p.stack = p.stack[:len(p.stack)-1] - p.skip = true -} - -func (p *toml) AddLineCount(i int) { - p.line += i -} - -func (p *toml) SetKey(buf []rune, begin, end int) { - p.key = string(buf[begin:end]) -} - -func (p *toml) AddKeyValue() { - if p.skip { - p.skip = false - return - } - if val, exists := p.currentTable.Fields[p.key]; exists { - switch v := val.(type) { - case *ast.Table: - p.Error(fmt.Errorf("key `%s' is in conflict with %v table in line %d", p.key, v.Type, v.Line)) - case *ast.KeyValue: - p.Error(fmt.Errorf("key `%s' is in conflict with line %d", p.key, v.Line)) - default: - p.Error(fmt.Errorf("BUG: key `%s' is in conflict but it's unknown type `%T'", p.key, v)) - } - } - if p.currentTable.Fields == nil { - p.currentTable.Fields = make(map[string]interface{}) - } - p.currentTable.Fields[p.key] = &ast.KeyValue{ - Key: p.key, - Value: p.val, - Line: p.line, - } -} - -func (p *toml) SetBasicString(buf []rune, begin, end int) { - p.s = p.unquote(string(buf[begin:end])) -} - -func (p *toml) SetMultilineString() { - p.s = p.unquote(`"` + escapeReplacer.Replace(strings.TrimLeft(p.s, "\r\n")) + `"`) -} - -func (p *toml) AddMultilineBasicBody(buf []rune, begin, end int) { - p.s += string(buf[begin:end]) -} - -func (p *toml) SetLiteralString(buf []rune, begin, end int) { - p.s = string(buf[begin:end]) -} - -func (p *toml) SetMultilineLiteralString(buf []rune, begin, end int) { - p.s = strings.TrimLeft(string(buf[begin:end]), "\r\n") -} - -func (p *toml) unquote(s string) string { - s, err := strconv.Unquote(s) - if err != nil { - p.Error(err) - } - return s -} - -func (p *toml) lookupTable(t *ast.Table, keys []string) (*ast.Table, error) { - for _, s := range keys { - val, exists := t.Fields[s] - if !exists { - tbl := &ast.Table{ - Line: p.line, - Name: s, - Type: ast.TableTypeNormal, - } - if t.Fields == nil { - t.Fields = make(map[string]interface{}) - } - t.Fields[s] = tbl - t = tbl - continue - } - switch v := val.(type) { - case *ast.Table: - t = v - case []*ast.Table: - t = v[len(v)-1] - case *ast.KeyValue: - return nil, fmt.Errorf("key `%s' is in conflict with line %d", s, v.Line) - default: - return nil, fmt.Errorf("BUG: key `%s' is in conflict but it's unknown type `%T'", s, v) - } - } - return t, nil -} - -func splitTableKey(tk string) []string { - key := make([]byte, 0, 1) - keys := make([]string, 0, 1) - inQuote := false - for i := 0; i < len(tk); i++ { - k := tk[i] - switch { - case k == tableSeparator && !inQuote: - keys = append(keys, string(key)) - key = key[:0] // reuse buffer. - case k == '"': - inQuote = !inQuote - case (k == ' ' || k == '\t') && !inQuote: - // skip. - default: - key = append(key, k) - } - } - keys = append(keys, string(key)) - return keys -} - -type convertError struct { - err error -} - -func (e convertError) Error() string { - return e.err.Error() -} - -type array struct { - parent *array - child *array - current *ast.Array - line int -} diff --git a/Godeps/_workspace/src/github.com/naoina/toml/decode_bench_test.go b/Godeps/_workspace/src/github.com/naoina/toml/decode_bench_test.go deleted file mode 100644 index e9f4a32d0..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/decode_bench_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package toml_test - -import ( - "testing" - "time" - - "github.com/drone/drone/Godeps/_workspace/src/github.com/naoina/toml" -) - -func BenchmarkUnmarshal(b *testing.B) { - var v struct { - Title string - Owner struct { - Name string - Organization string - Bio string - Dob time.Time - } - Database struct { - Server string - Ports []int - ConnectionMax int - Enabled bool - } - Servers struct { - Alpha struct { - IP string - DC string - } - Beta struct { - IP string - DC string - } - } - Clients struct { - Data []interface{} - Hosts []string - } - } - data, err := loadTestData() - if err != nil { - b.Fatal(err) - } - for i := 0; i < b.N; i++ { - if err := toml.Unmarshal(data, &v); err != nil { - b.Fatal(err) - } - } -} diff --git a/Godeps/_workspace/src/github.com/naoina/toml/decode_test.go b/Godeps/_workspace/src/github.com/naoina/toml/decode_test.go deleted file mode 100644 index 548c9d8a8..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/decode_test.go +++ /dev/null @@ -1,1083 +0,0 @@ -package toml_test - -import ( - "fmt" - "io/ioutil" - "path/filepath" - "reflect" - "testing" - "time" - - "github.com/drone/drone/Godeps/_workspace/src/github.com/naoina/toml" -) - -const ( - dataDir = "testdata" -) - -func loadTestData() ([]byte, error) { - f := filepath.Join(dataDir, "test.toml") - data, err := ioutil.ReadFile(f) - if err != nil { - return nil, err - } - return data, nil -} - -func mustTime(tm time.Time, err error) time.Time { - if err != nil { - panic(err) - } - return tm -} - -type Name struct { - First string - Last string -} -type Point struct { - X int - Y int -} -type Inline struct { - Name Name - Point Point -} -type Subtable struct { - Key string -} -type Table struct { - Key string - Subtable Subtable - Inline Inline -} -type W struct { -} -type Z struct { - W W -} -type Y struct { - Z Z -} -type X struct { - Y Y -} -type Basic struct { - Basic string -} -type Continued struct { - Key1 string - Key2 string - Key3 string -} -type Multiline struct { - Key1 string - Key2 string - Key3 string - Continued Continued -} -type LiteralMultiline struct { - Regex2 string - Lines string -} -type Literal struct { - Winpath string - Winpath2 string - Quoted string - Regex string - Multiline LiteralMultiline -} -type String struct { - Basic Basic - Multiline Multiline - Literal Literal -} -type IntegerUnderscores struct { - Key1 int - Key2 int - Key3 int -} -type Integer struct { - Key1 int - Key2 int - Key3 int - Key4 int - Underscores IntegerUnderscores -} -type Fractional struct { - Key1 float64 - Key2 float64 - Key3 float64 -} -type Exponent struct { - Key1 float64 - Key2 float64 - Key3 float64 -} -type Both struct { - Key float64 -} -type FloatUnderscores struct { - Key1 float64 - Key2 float64 -} -type Float struct { - Fractional Fractional - Exponent Exponent - Both Both - Underscores FloatUnderscores -} -type Boolean struct { - True bool - False bool -} -type Datetime struct { - Key1 time.Time - Key2 time.Time - Key3 time.Time -} -type Array struct { - Key1 []int - Key2 []string - Key3 [][]int - Key4 [][]interface{} - Key5 []int - Key6 []int -} -type Product struct { - Name string - Sku int64 - Color string -} -type Physical struct { - Color string - Shape string -} -type Variety struct { - Name string -} -type Fruit struct { - Name string - Physical Physical - Variety []Variety -} -type testStruct struct { - Table Table - X X - String String - Integer Integer - Float Float - Boolean Boolean - Datetime Datetime - Array Array - Products []Product - Fruit []Fruit -} - -func TestUnmarshal(t *testing.T) { - data, err := loadTestData() - if err != nil { - t.Fatal(err) - } - var v testStruct - var actual interface{} = toml.Unmarshal(data, &v) - var expect interface{} = nil - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`toml.Unmarshal(data, &testStruct{}) => %#v; want %#v`, actual, expect) - } - - actual = v - expect = testStruct{ - Table: Table{ - Key: "value", - Subtable: Subtable{ - Key: "another value", - }, - Inline: Inline{ - Name: Name{ - First: "Tom", - Last: "Preston-Werner", - }, - Point: Point{ - X: 1, - Y: 2, - }, - }, - }, - X: X{}, - String: String{ - Basic: Basic{ - Basic: "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF.", - }, - Multiline: Multiline{ - Key1: "One\nTwo", - Key2: "One\nTwo", - Key3: "One\nTwo", - Continued: Continued{ - Key1: "The quick brown fox jumps over the lazy dog.", - Key2: "The quick brown fox jumps over the lazy dog.", - Key3: "The quick brown fox jumps over the lazy dog.", - }, - }, - Literal: Literal{ - Winpath: `C:\Users\nodejs\templates`, - Winpath2: `\\ServerX\admin$\system32\`, - Quoted: `Tom "Dubs" Preston-Werner`, - Regex: `<\i\c*\s*>`, - Multiline: LiteralMultiline{ - Regex2: `I [dw]on't need \d{2} apples`, - Lines: "The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n", - }, - }, - }, - Integer: Integer{ - Key1: 99, - Key2: 42, - Key3: 0, - Key4: -17, - Underscores: IntegerUnderscores{ - Key1: 1000, - Key2: 5349221, - Key3: 12345, - }, - }, - Float: Float{ - Fractional: Fractional{ - Key1: 1.0, - Key2: 3.1415, - Key3: -0.01, - }, - Exponent: Exponent{ - Key1: 5e22, - Key2: 1e6, - Key3: -2e-2, - }, - Both: Both{ - Key: 6.626e-34, - }, - Underscores: FloatUnderscores{ - Key1: 9224617.445991228313, - Key2: 1e100, - }, - }, - Boolean: Boolean{ - True: true, - False: false, - }, - Datetime: Datetime{ - Key1: mustTime(time.Parse(time.RFC3339Nano, "1979-05-27T07:32:00Z")), - Key2: mustTime(time.Parse(time.RFC3339Nano, "1979-05-27T00:32:00-07:00")), - Key3: mustTime(time.Parse(time.RFC3339Nano, "1979-05-27T00:32:00.999999-07:00")), - }, - Array: Array{ - Key1: []int{1, 2, 3}, - Key2: []string{"red", "yellow", "green"}, - Key3: [][]int{{1, 2}, {3, 4, 5}}, - Key4: [][]interface{}{{int64(1), int64(2)}, {"a", "b", "c"}}, - Key5: []int{1, 2, 3}, - Key6: []int{1, 2}, - }, - Products: []Product{ - {Name: "Hammer", Sku: 738594937}, - {}, - {Name: "Nail", Sku: 284758393, Color: "gray"}, - }, - Fruit: []Fruit{ - { - Name: "apple", - Physical: Physical{ - Color: "red", - Shape: "round", - }, - Variety: []Variety{ - {Name: "red delicious"}, - {Name: "granny smith"}, - }, - }, - { - Name: "banana", - Variety: []Variety{ - {Name: "plantain"}, - }, - }, - }, - } - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`toml.Unmarshal(data, v); v => %#v; want %#v`, actual, expect) - } -} - -type testcase struct { - data string - err error - actual interface{} - expect interface{} -} - -func testUnmarshal(t *testing.T, testcases []testcase) { - for _, v := range testcases { - var actual error = toml.Unmarshal([]byte(v.data), v.actual) - var expect error = v.err - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`toml.Unmarshal([]byte(%#v), %#v) => %#v; want %#v`, v.data, nil, actual, expect) - } - if !reflect.DeepEqual(v.actual, v.expect) { - t.Errorf(`toml.Unmarshal([]byte(%#v), v); v => %#v; want %#v`, v.data, v.actual, v.expect) - } - } -} - -func TestUnmarshal_WithString(t *testing.T) { - type testStruct struct { - Str string - Key1 string - Key2 string - Key3 string - Winpath string - Winpath2 string - Quoted string - Regex string - Regex2 string - Lines string - } - testUnmarshal(t, []testcase{ - {`str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."`, nil, &testStruct{}, &testStruct{ - Str: "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF.", - }}, - {`key1 = "One\nTwo" -key2 = """One\nTwo""" -key3 = """ -One -Two""" -`, nil, &testStruct{}, &testStruct{ - Key1: "One\nTwo", - Key2: "One\nTwo", - Key3: "One\nTwo", - }}, - {`# The following strings are byte-for-byte equivalent: -key1 = "The quick brown fox jumps over the lazy dog." - -key2 = """ -The quick brown \ - - - fox jumps over \ - the lazy dog.""" - -key3 = """\ - The quick brown \ - fox jumps over \ - the lazy dog.\ - """`, nil, &testStruct{}, &testStruct{ - Key1: "The quick brown fox jumps over the lazy dog.", - Key2: "The quick brown fox jumps over the lazy dog.", - Key3: "The quick brown fox jumps over the lazy dog.", - }}, - {`# What you see is what you get. -winpath = 'C:\Users\nodejs\templates' -winpath2 = '\\ServerX\admin$\system32\' -quoted = 'Tom "Dubs" Preston-Werner' -regex = '<\i\c*\s*>'`, nil, &testStruct{}, &testStruct{ - Winpath: `C:\Users\nodejs\templates`, - Winpath2: `\\ServerX\admin$\system32\`, - Quoted: `Tom "Dubs" Preston-Werner`, - Regex: `<\i\c*\s*>`, - }}, - {`regex2 = '''I [dw]on't need \d{2} apples''' -lines = ''' -The first newline is -trimmed in raw strings. - All other whitespace - is preserved. -'''`, nil, &testStruct{}, &testStruct{ - Regex2: `I [dw]on't need \d{2} apples`, - Lines: "The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n", - }}, - }) -} - -func TestUnmarshal_WithInteger(t *testing.T) { - type testStruct struct { - Intval int64 - } - testUnmarshal(t, []testcase{ - {`intval = 0`, nil, &testStruct{}, &testStruct{0}}, - {`intval = +0`, nil, &testStruct{}, &testStruct{0}}, - {`intval = -0`, nil, &testStruct{}, &testStruct{-0}}, - {`intval = 1`, nil, &testStruct{}, &testStruct{1}}, - {`intval = +1`, nil, &testStruct{}, &testStruct{1}}, - {`intval = -1`, nil, &testStruct{}, &testStruct{-1}}, - {`intval = 10`, nil, &testStruct{}, &testStruct{10}}, - {`intval = 777`, nil, &testStruct{}, &testStruct{777}}, - {`intval = 2147483647`, nil, &testStruct{}, &testStruct{2147483647}}, - {`intval = 2147483648`, nil, &testStruct{}, &testStruct{2147483648}}, - {`intval = +2147483648`, nil, &testStruct{}, &testStruct{2147483648}}, - {`intval = -2147483648`, nil, &testStruct{}, &testStruct{-2147483648}}, - {`intval = -2147483649`, nil, &testStruct{}, &testStruct{-2147483649}}, - {`intval = 9223372036854775807`, nil, &testStruct{}, &testStruct{9223372036854775807}}, - {`intval = +9223372036854775807`, nil, &testStruct{}, &testStruct{9223372036854775807}}, - {`intval = 9223372036854775808`, fmt.Errorf(`toml: unmarshal: line 1: toml_test.testStruct.Intval: strconv.ParseInt: parsing "9223372036854775808": value out of range`), &testStruct{}, &testStruct{}}, - {`intval = +9223372036854775808`, fmt.Errorf(`toml: unmarshal: line 1: toml_test.testStruct.Intval: strconv.ParseInt: parsing "+9223372036854775808": value out of range`), &testStruct{}, &testStruct{}}, - {`intval = -9223372036854775808`, nil, &testStruct{}, &testStruct{-9223372036854775808}}, - {`intval = -9223372036854775809`, fmt.Errorf(`toml: unmarshal: line 1: toml_test.testStruct.Intval: strconv.ParseInt: parsing "-9223372036854775809": value out of range`), &testStruct{}, &testStruct{}}, - {`intval = 1_000`, nil, &testStruct{}, &testStruct{1000}}, - {`intval = 5_349_221`, nil, &testStruct{}, &testStruct{5349221}}, - {`intval = 1_2_3_4_5`, nil, &testStruct{}, &testStruct{12345}}, - {`intval = _1_000`, fmt.Errorf("toml: line 1: parse error"), &testStruct{}, &testStruct{}}, - {`intval = 1_000_`, fmt.Errorf("toml: line 1: parse error"), &testStruct{}, &testStruct{}}, - }) -} - -func TestUnmarshal_WithFloat(t *testing.T) { - type testStruct struct { - Floatval float64 - } - testUnmarshal(t, []testcase{ - {`floatval = 0.0`, nil, &testStruct{}, &testStruct{0.0}}, - {`floatval = +0.0`, nil, &testStruct{}, &testStruct{0.0}}, - {`floatval = -0.0`, nil, &testStruct{}, &testStruct{-0.0}}, - {`floatval = 0.1`, nil, &testStruct{}, &testStruct{0.1}}, - {`floatval = +0.1`, nil, &testStruct{}, &testStruct{0.1}}, - {`floatval = -0.1`, nil, &testStruct{}, &testStruct{-0.1}}, - {`floatval = 0.2`, nil, &testStruct{}, &testStruct{0.2}}, - {`floatval = +0.2`, nil, &testStruct{}, &testStruct{0.2}}, - {`floatval = -0.2`, nil, &testStruct{}, &testStruct{-0.2}}, - {`floatval = 1.0`, nil, &testStruct{}, &testStruct{1.0}}, - {`floatval = +1.0`, nil, &testStruct{}, &testStruct{1.0}}, - {`floatval = -1.0`, nil, &testStruct{}, &testStruct{-1.0}}, - {`floatval = 1.1`, nil, &testStruct{}, &testStruct{1.1}}, - {`floatval = +1.1`, nil, &testStruct{}, &testStruct{1.1}}, - {`floatval = -1.1`, nil, &testStruct{}, &testStruct{-1.1}}, - {`floatval = 3.1415`, nil, &testStruct{}, &testStruct{3.1415}}, - {`floatval = +3.1415`, nil, &testStruct{}, &testStruct{3.1415}}, - {`floatval = -3.1415`, nil, &testStruct{}, &testStruct{-3.1415}}, - {`floatval = 10.2e5`, nil, &testStruct{}, &testStruct{10.2e5}}, - {`floatval = +10.2e5`, nil, &testStruct{}, &testStruct{10.2e5}}, - {`floatval = -10.2e5`, nil, &testStruct{}, &testStruct{-10.2e5}}, - {`floatval = 10.2E5`, nil, &testStruct{}, &testStruct{10.2e5}}, - {`floatval = +10.2E5`, nil, &testStruct{}, &testStruct{10.2e5}}, - {`floatval = -10.2E5`, nil, &testStruct{}, &testStruct{-10.2e5}}, - {`floatval = 5e+22`, nil, &testStruct{}, &testStruct{5e+22}}, - {`floatval = 1e6`, nil, &testStruct{}, &testStruct{1e6}}, - {`floatval = -2E-2`, nil, &testStruct{}, &testStruct{-2E-2}}, - {`floatval = 6.626e-34`, nil, &testStruct{}, &testStruct{6.626e-34}}, - {`floatval = 9_224_617.445_991_228_313`, nil, &testStruct{}, &testStruct{9224617.445991228313}}, - {`floatval = 1e1_00`, nil, &testStruct{}, &testStruct{1e100}}, - {`floatval = 1e02`, nil, &testStruct{}, &testStruct{1e2}}, - {`floatval = _1e1_00`, fmt.Errorf("toml: line 1: parse error"), &testStruct{}, &testStruct{}}, - {`floatval = 1e1_00_`, fmt.Errorf("toml: line 1: parse error"), &testStruct{}, &testStruct{}}, - }) -} - -func TestUnmarshal_WithBoolean(t *testing.T) { - type testStruct struct { - Boolval bool - } - testUnmarshal(t, []testcase{ - {`boolval = true`, nil, &testStruct{}, &testStruct{true}}, - {`boolval = false`, nil, &testStruct{}, &testStruct{false}}, - }) -} - -func TestUnmarshal_WithDatetime(t *testing.T) { - type testStruct struct { - Datetimeval time.Time - } - testUnmarshal(t, []testcase{ - {`datetimeval = 1979-05-27T07:32:00Z`, nil, &testStruct{}, &testStruct{ - mustTime(time.Parse(time.RFC3339Nano, "1979-05-27T07:32:00Z")), - }}, - {`datetimeval = 2014-09-13T12:37:39Z`, nil, &testStruct{}, &testStruct{ - mustTime(time.Parse(time.RFC3339Nano, "2014-09-13T12:37:39Z")), - }}, - {`datetimeval = 1979-05-27T00:32:00-07:00`, nil, &testStruct{}, &testStruct{ - mustTime(time.Parse(time.RFC3339Nano, "1979-05-27T00:32:00-07:00")), - }}, - {`datetimeval = 1979-05-27T00:32:00.999999-07:00`, nil, &testStruct{}, &testStruct{ - mustTime(time.Parse(time.RFC3339Nano, "1979-05-27T00:32:00.999999-07:00")), - }}, - }) -} - -func TestUnmarshal_WithArray(t *testing.T) { - testUnmarshal(t, []testcase{ - {`arrayval = []`, nil, &struct{ Arrayval []interface{} }{}, &struct{ Arrayval []interface{} }{}}, - {`arrayval = [ 1 ]`, nil, &struct{ Arrayval []int }{}, - &struct { - Arrayval []int - }{ - []int{1}, - }}, - {`arrayval = [ 1, 2, 3 ]`, nil, &struct{ Arrayval []int }{}, - &struct { - Arrayval []int - }{ - []int{1, 2, 3}, - }}, - {`arrayval = [ 1, 2, 3, ]`, nil, &struct{ Arrayval []int }{}, - &struct { - Arrayval []int - }{ - []int{1, 2, 3}, - }}, - {`arrayval = ["red", "yellow", "green"]`, nil, &struct{ Arrayval []string }{}, - &struct{ Arrayval []string }{ - []string{"red", "yellow", "green"}, - }}, - {`arrayval = [ "all", 'strings', """are the same""", '''type''']`, nil, &struct{ Arrayval []string }{}, - &struct{ Arrayval []string }{ - []string{"all", "strings", "are the same", "type"}, - }}, - {`arrayval = [[1,2],[3,4,5]]`, nil, &struct{ Arrayval [][]int }{}, - &struct{ Arrayval [][]int }{ - [][]int{ - []int{1, 2}, - []int{3, 4, 5}, - }, - }}, - {`arrayval = [ [ 1, 2 ], ["a", "b", "c"] ] # this is ok`, nil, &struct{ Arrayval [][]interface{} }{}, - &struct{ Arrayval [][]interface{} }{ - [][]interface{}{ - []interface{}{int64(1), int64(2)}, - []interface{}{"a", "b", "c"}, - }, - }}, - {`arrayval = [ [ 1, 2 ], [ [3, 4], [5, 6] ] ] # this is ok`, nil, &struct{ Arrayval [][]interface{} }{}, - &struct{ Arrayval [][]interface{} }{ - [][]interface{}{ - []interface{}{int64(1), int64(2)}, - []interface{}{ - []interface{}{int64(3), int64(4)}, - []interface{}{int64(5), int64(6)}, - }, - }, - }}, - {`arrayval = [ [ 1, 2 ], [ [3, 4], [5, 6], [7, 8] ] ] # this is ok`, nil, &struct{ Arrayval [][]interface{} }{}, - &struct{ Arrayval [][]interface{} }{ - [][]interface{}{ - []interface{}{int64(1), int64(2)}, - []interface{}{ - []interface{}{int64(3), int64(4)}, - []interface{}{int64(5), int64(6)}, - []interface{}{int64(7), int64(8)}, - }, - }, - }}, - {`arrayval = [ [[ 1, 2 ]], [3, 4], [5, 6] ] # this is ok`, nil, &struct{ Arrayval [][]interface{} }{}, - &struct{ Arrayval [][]interface{} }{ - [][]interface{}{ - []interface{}{ - []interface{}{int64(1), int64(2)}, - }, - []interface{}{int64(3), int64(4)}, - []interface{}{int64(5), int64(6)}, - }, - }}, - {`arrayval = [ 1, 2.0 ] # note: this is NOT ok`, fmt.Errorf("toml: unmarshal: line 1: struct { Arrayval []interface {} }.Arrayval: array cannot contain multiple types"), &struct{ Arrayval []interface{} }{}, &struct{ Arrayval []interface{} }{}}, - {`key = [ - 1, 2, 3 -]`, nil, &struct{ Key []int }{}, - &struct{ Key []int }{ - []int{1, 2, 3}, - }}, - {`key = [ - 1, - 2, # this is ok -]`, nil, &struct{ Key []int }{}, - &struct{ Key []int }{ - []int{1, 2}, - }}, - }) -} - -func TestUnmarshal_WithTable(t *testing.T) { - type W struct{} - type Z struct { - W W - } - type Y struct { - Z Z - } - type X struct { - Y Y - } - type testStruct struct { - Table struct { - Key string - } - Dog struct { - Tater struct{} - } - X X - A struct { - D int - B struct { - C int - } - } - } - type testQuotedKeyStruct struct { - Dog struct { - TaterMan struct { - Type string - } `toml:"tater.man"` - } - } - type testQuotedKeyWithWhitespaceStruct struct { - Dog struct { - TaterMan struct { - Type string - } `toml:"tater . man"` - } - } - type testStructWithMap struct { - Servers map[string]struct { - IP string - DC string - } - } - testUnmarshal(t, []testcase{ - {`[table]`, nil, &testStruct{}, &testStruct{}}, - {`[table] -key = "value"`, nil, &testStruct{}, - &testStruct{ - Table: struct { - Key string - }{ - Key: "value", - }, - }}, - {`[dog.tater]`, nil, &testStruct{}, - &testStruct{ - Dog: struct { - Tater struct{} - }{ - Tater: struct{}{}, - }, - }}, - {`[dog."tater.man"] -type = "pug"`, nil, &testQuotedKeyStruct{}, - &testQuotedKeyStruct{ - Dog: struct { - TaterMan struct { - Type string - } `toml:"tater.man"` - }{ - TaterMan: struct { - Type string - }{ - Type: "pug", - }, - }, - }}, - {`[dog."tater . man"] -type = "pug"`, nil, &testQuotedKeyWithWhitespaceStruct{}, - &testQuotedKeyWithWhitespaceStruct{ - Dog: struct { - TaterMan struct { - Type string - } `toml:"tater . man"` - }{ - TaterMan: struct { - Type string - }{ - Type: "pug", - }, - }, - }}, - {`[x.y.z.w] # for this to work`, nil, &testStruct{}, - &testStruct{ - X: X{}, - }}, - {`[ x . y . z . w ]`, nil, &testStruct{}, - &testStruct{ - X: X{}, - }}, - {`[ x . "y" . z . "w" ]`, nil, &testStruct{}, - &testStruct{ - X: X{}, - }}, - {`table = {}`, nil, &testStruct{}, &testStruct{}}, - {`table = { key = "value" }`, nil, &testStruct{}, &testStruct{ - Table: struct { - Key string - }{ - Key: "value", - }, - }}, - {`x = { y = { "z" = { w = {} } } }`, nil, &testStruct{}, &testStruct{X: X{}}}, - {`[a.b] -c = 1 - -[a] -d = 2`, nil, &testStruct{}, - &testStruct{ - A: struct { - D int - B struct { - C int - } - }{ - D: 2, - B: struct { - C int - }{ - C: 1, - }, - }, - }}, - {`# DO NOT DO THIS - -[a] -b = 1 - -[a] -c = 2`, fmt.Errorf("toml: line 6: table `a' is in conflict with normal table in line 3"), &testStruct{}, &testStruct{}}, - {`# DO NOT DO THIS EITHER - -[a] -b = 1 - -[a.b] -c = 2`, fmt.Errorf("toml: line 6: key `b' is in conflict with line 4"), &testStruct{}, &testStruct{}}, - {`# DO NOT DO THIS EITHER - -[a.b] -c = 2 - -[a] -b = 1`, fmt.Errorf("toml: line 7: key `b' is in conflict with normal table in line 3"), &testStruct{}, &testStruct{}}, - {`[]`, fmt.Errorf("toml: line 1: parse error"), &testStruct{}, &testStruct{}}, - {`[a.]`, fmt.Errorf("toml: line 1: parse error"), &testStruct{}, &testStruct{}}, - {`[a..b]`, fmt.Errorf("toml: line 1: parse error"), &testStruct{}, &testStruct{}}, - {`[.b]`, fmt.Errorf("toml: line 1: parse error"), &testStruct{}, &testStruct{}}, - {`[.]`, fmt.Errorf("toml: line 1: parse error"), &testStruct{}, &testStruct{}}, - {` = "no key name" # not allowed`, fmt.Errorf("toml: line 1: parse error"), &testStruct{}, &testStruct{}}, - {`[servers] -[servers.alpha] -ip = "10.0.0.1" -dc = "eqdc10" -[servers.beta] -ip = "10.0.0.2" -dc = "eqdc10" -`, nil, &testStructWithMap{}, - &testStructWithMap{ - Servers: map[string]struct { - IP string - DC string - }{ - "alpha": { - IP: "10.0.0.1", - DC: "eqdc10", - }, - "beta": { - IP: "10.0.0.2", - DC: "eqdc10", - }, - }, - }}, - }) -} - -func TestUnmarshal_WithArrayTable(t *testing.T) { - type Product struct { - Name string - SKU int64 - Color string - } - type Physical struct { - Color string - Shape string - } - type Variety struct { - Name string - } - type Fruit struct { - Name string - Physical Physical - Variety []Variety - } - type testStruct struct { - Products []Product - Fruit []Fruit - } - type testStructWithMap struct { - Fruit []map[string][]struct { - Name string - } - } - testUnmarshal(t, []testcase{ - {`[[products]] - name = "Hammer" - sku = 738594937 - - [[products]] - - [[products]] - name = "Nail" - sku = 284758393 - color = "gray"`, nil, &testStruct{}, - &testStruct{ - Products: []Product{ - {Name: "Hammer", SKU: 738594937}, - {}, - {Name: "Nail", SKU: 284758393, Color: "gray"}, - }, - }}, - {`products = [{name = "Hammer", sku = 738594937}, {}, -{name = "Nail", sku = 284758393, color = "gray"}]`, nil, &testStruct{}, &testStruct{ - Products: []Product{ - {Name: "Hammer", SKU: 738594937}, - {}, - {Name: "Nail", SKU: 284758393, Color: "gray"}, - }, - }}, - {`[[fruit]] - name = "apple" - - [fruit.physical] - color = "red" - shape = "round" - - [[fruit.variety]] - name = "red delicious" - - [[fruit.variety]] - name = "granny smith" - - [[fruit]] - name = "banana" - - [fruit.physical] - color = "yellow" - shape = "lune" - - [[fruit.variety]] - name = "plantain"`, nil, &testStruct{}, - &testStruct{ - Fruit: []Fruit{ - { - Name: "apple", - Physical: Physical{ - Color: "red", - Shape: "round", - }, - Variety: []Variety{ - {Name: "red delicious"}, - {Name: "granny smith"}, - }, - }, - { - Name: "banana", - Physical: Physical{ - Color: "yellow", - Shape: "lune", - }, - Variety: []Variety{ - {Name: "plantain"}, - }, - }, - }, - }}, - {`[[fruit]] - - [[fruit.variety]] - name = "red delicious" - - [[fruit.variety]] - name = "granny smith" - - [[fruit]] - - [[fruit.variety]] - name = "plantain" - - [[fruit.area]] - name = "phillippines"`, nil, &testStructWithMap{}, - &testStructWithMap{ - Fruit: []map[string][]struct { - Name string - }{ - { - "variety": { - {Name: "red delicious"}, - {Name: "granny smith"}, - }, - }, - { - "variety": { - {Name: "plantain"}, - }, - "area": { - {Name: "phillippines"}, - }, - }, - }, - }}, - {`# INVALID TOML DOC - [[fruit]] - name = "apple" - - [[fruit.variety]] - name = "red delicious" - - # This table conflicts with the previous table - [fruit.variety] - name = "granny smith"`, fmt.Errorf("toml: line 9: table `fruit.variety' is in conflict with array table in line 5"), &testStruct{}, &testStruct{}}, - {`# INVALID TOML DOC - [[fruit]] - name = "apple" - - [fruit.variety] - name = "granny smith" - - # This table conflicts with the previous table - [[fruit.variety]] - name = "red delicious"`, fmt.Errorf("toml: line 9: table `fruit.variety' is in conflict with normal table in line 5"), &testStruct{}, &testStruct{}}, - }) -} - -type UnmarshalString string - -func (u *UnmarshalString) UnmarshalTOML(data []byte) error { - *u = UnmarshalString("UnmarshalString: " + string(data)) - return nil -} - -func TestUnmarshal_WithUnmarshaler(t *testing.T) { - type testStruct struct { - Title UnmarshalString - MaxConn UnmarshalString - Ports UnmarshalString - Servers UnmarshalString - Table UnmarshalString - Arraytable UnmarshalString - } - data := `title = "testtitle" -max_conn = 777 -ports = [8080, 8081, 8082] -servers = [1, 2, 3] -[table] -name = "alice" -[[arraytable]] -name = "alice" -[[arraytable]] -name = "bob" -` - var v testStruct - if err := toml.Unmarshal([]byte(data), &v); err != nil { - t.Fatal(err) - } - actual := v - expect := testStruct{ - Title: `UnmarshalString: "testtitle"`, - MaxConn: `UnmarshalString: 777`, - Ports: `UnmarshalString: [8080, 8081, 8082]`, - Servers: `UnmarshalString: [1, 2, 3]`, - Table: "UnmarshalString: [table]\nname = \"alice\"", - Arraytable: "UnmarshalString: [[arraytable]]\nname = \"alice\"\n[[arraytable]]\nname = \"bob\"", - } - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`toml.Unmarshal(data, &v); v => %#v; want %#v`, actual, expect) - } -} - -func TestUnmarshal_WithMultibyteString(t *testing.T) { - type testStruct struct { - Name string - Numbers []string - } - v := testStruct{} - data := `name = "七一〇七" -numbers = ["壱", "弐", "参"] -` - if err := toml.Unmarshal([]byte(data), &v); err != nil { - t.Fatal(err) - } - actual := v - expect := testStruct{ - Name: "七一〇七", - Numbers: []string{"壱", "弐", "参"}, - } - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`toml.Unmarshal([]byte(data), &v); v => %#v; want %#v`, actual, expect) - } -} - -func TestUnmarshal_WithPointers(t *testing.T) { - type Inline struct { - Key1 string - Key2 *string - Key3 **string - } - type Table struct { - Key1 *string - Key2 **string - Key3 ***string - } - type testStruct struct { - Inline *Inline - Tables []*Table - } - type testStruct2 struct { - Inline **Inline - Tables []**Table - } - type testStruct3 struct { - Inline ***Inline - Tables []***Table - } - data := ` -inline = { key1 = "test", key2 = "a", key3 = "b" } -[[tables]] -key1 = "a" -key2 = "a" -key3 = "a" -[[tables]] -key1 = "b" -key2 = "b" -key3 = "b" -` - s1 := "a" - s2 := &s1 - s3 := &s2 - s4 := &s3 - s5 := "b" - s6 := &s5 - s7 := &s6 - s8 := &s7 - i1 := &Inline{"test", s2, s7} - i2 := &i1 - i3 := &i2 - t1 := &Table{s2, s3, s4} - t2 := &Table{s6, s7, s8} - t3 := &t1 - t4 := &t2 - sc := &testStruct{ - Inline: i1, Tables: []*Table{t1, t2}, - } - ac := &testStruct{} - testUnmarshal(t, []testcase{ - {data, nil, ac, sc}, - {data, nil, &testStruct2{}, &testStruct2{ - Inline: i2, - Tables: []**Table{&t1, &t2}, - }}, - {data, nil, &testStruct3{}, &testStruct3{ - Inline: i3, - Tables: []***Table{&t3, &t4}, - }}, - }) -} - -func TestUnmarshalMap(t *testing.T) { - testUnmarshal(t, []testcase{ - {` -name = "evan" -foo = 1 -`, nil, map[string]interface{}{}, map[string]interface{}{ - "name": "evan", - "foo": int64(1), - }}, - }) -} diff --git a/Godeps/_workspace/src/github.com/naoina/toml/encode.go b/Godeps/_workspace/src/github.com/naoina/toml/encode.go deleted file mode 100644 index eb16c3eb8..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/encode.go +++ /dev/null @@ -1,211 +0,0 @@ -package toml - -import ( - "fmt" - "reflect" - "strconv" - "time" - - "go/ast" - - "github.com/drone/drone/Godeps/_workspace/src/github.com/naoina/go-stringutil" -) - -const ( - tagOmitempty = "omitempty" - tagSkip = "-" -) - -// Marshal returns the TOML encoding of v. -// -// Struct values encode as TOML. Each exported struct field becomes a field of -// the TOML structure unless -// - the field's tag is "-", or -// - the field is empty and its tag specifies the "omitempty" option. -// The "toml" key in the struct field's tag value is the key name, followed by -// an optional comma and options. Examples: -// -// // Field is ignored by this package. -// Field int `toml:"-"` -// -// // Field appears in TOML as key "myName". -// Field int `toml:"myName"` -// -// // Field appears in TOML as key "myName" and the field is omitted from the -// // result of encoding if its value is empty. -// Field int `toml:"myName,omitempty"` -// -// // Field appears in TOML as key "field", but the field is skipped if -// // empty. -// // Note the leading comma. -// Field int `toml:",omitempty"` -func Marshal(v interface{}) ([]byte, error) { - return marshal(nil, "", reflect.ValueOf(v), false, false) -} - -// Marshaler is the interface implemented by objects that can marshal themshelves into valid TOML. -type Marshaler interface { - MarshalTOML() ([]byte, error) -} - -func marshal(buf []byte, prefix string, rv reflect.Value, inArray, arrayTable bool) ([]byte, error) { - rt := rv.Type() - for i := 0; i < rv.NumField(); i++ { - ft := rt.Field(i) - if !ast.IsExported(ft.Name) { - continue - } - colName, rest := extractTag(rt.Field(i).Tag.Get(fieldTagName)) - if colName == tagSkip { - continue - } - if colName == "" { - colName = stringutil.ToSnakeCase(ft.Name) - } - fv := rv.Field(i) - switch rest { - case tagOmitempty: - if fv.Interface() == reflect.Zero(ft.Type).Interface() { - continue - } - } - var err error - if buf, err = encodeValue(buf, prefix, colName, fv, inArray, arrayTable); err != nil { - return nil, err - } - } - return buf, nil -} - -func encodeValue(buf []byte, prefix, name string, fv reflect.Value, inArray, arrayTable bool) ([]byte, error) { - switch t := fv.Interface().(type) { - case Marshaler: - b, err := t.MarshalTOML() - if err != nil { - return nil, err - } - return appendNewline(append(appendKey(buf, name, inArray, arrayTable), b...), inArray, arrayTable), nil - case time.Time: - return appendNewline(encodeTime(appendKey(buf, name, inArray, arrayTable), t), inArray, arrayTable), nil - } - switch fv.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return appendNewline(encodeInt(appendKey(buf, name, inArray, arrayTable), fv.Int()), inArray, arrayTable), nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return appendNewline(encodeUint(appendKey(buf, name, inArray, arrayTable), fv.Uint()), inArray, arrayTable), nil - case reflect.Float32, reflect.Float64: - return appendNewline(encodeFloat(appendKey(buf, name, inArray, arrayTable), fv.Float()), inArray, arrayTable), nil - case reflect.Bool: - return appendNewline(encodeBool(appendKey(buf, name, inArray, arrayTable), fv.Bool()), inArray, arrayTable), nil - case reflect.String: - return appendNewline(encodeString(appendKey(buf, name, inArray, arrayTable), fv.String()), inArray, arrayTable), nil - case reflect.Slice, reflect.Array: - ft := fv.Type().Elem() - for ft.Kind() == reflect.Ptr { - ft = ft.Elem() - } - if ft.Kind() == reflect.Struct { - name := tableName(prefix, name) - var err error - for i := 0; i < fv.Len(); i++ { - if buf, err = marshal(append(append(append(buf, '[', '['), name...), ']', ']', '\n'), name, fv.Index(i), false, true); err != nil { - return nil, err - } - } - return buf, nil - } - buf = append(appendKey(buf, name, inArray, arrayTable), '[') - var err error - for i := 0; i < fv.Len(); i++ { - if i != 0 { - buf = append(buf, ',') - } - if buf, err = encodeValue(buf, prefix, name, fv.Index(i), true, false); err != nil { - return nil, err - } - } - return appendNewline(append(buf, ']'), inArray, arrayTable), nil - case reflect.Struct: - name := tableName(prefix, name) - return marshal(append(append(append(buf, '['), name...), ']', '\n'), name, fv, inArray, arrayTable) - case reflect.Interface: - var err error - if buf, err = encodeInterface(appendKey(buf, name, inArray, arrayTable), fv.Interface()); err != nil { - return nil, err - } - return appendNewline(buf, inArray, arrayTable), nil - } - return nil, fmt.Errorf("toml: marshal: unsupported type %v", fv.Kind()) -} - -func appendKey(buf []byte, key string, inArray, arrayTable bool) []byte { - if !inArray { - return append(append(buf, key...), '=') - } - return buf -} - -func appendNewline(buf []byte, inArray, arrayTable bool) []byte { - if !inArray { - return append(buf, '\n') - } - return buf -} - -func encodeInterface(buf []byte, v interface{}) ([]byte, error) { - switch v := v.(type) { - case int: - return encodeInt(buf, int64(v)), nil - case int8: - return encodeInt(buf, int64(v)), nil - case int16: - return encodeInt(buf, int64(v)), nil - case int32: - return encodeInt(buf, int64(v)), nil - case int64: - return encodeInt(buf, v), nil - case uint: - return encodeUint(buf, uint64(v)), nil - case uint8: - return encodeUint(buf, uint64(v)), nil - case uint16: - return encodeUint(buf, uint64(v)), nil - case uint32: - return encodeUint(buf, uint64(v)), nil - case uint64: - return encodeUint(buf, v), nil - case float32: - return encodeFloat(buf, float64(v)), nil - case float64: - return encodeFloat(buf, v), nil - case bool: - return encodeBool(buf, v), nil - case string: - return encodeString(buf, v), nil - } - return nil, fmt.Errorf("toml: marshal: unable to detect a type of value `%v'", v) -} - -func encodeInt(buf []byte, i int64) []byte { - return strconv.AppendInt(buf, i, 10) -} - -func encodeUint(buf []byte, u uint64) []byte { - return strconv.AppendUint(buf, u, 10) -} - -func encodeFloat(buf []byte, f float64) []byte { - return strconv.AppendFloat(buf, f, 'e', -1, 64) -} - -func encodeBool(buf []byte, b bool) []byte { - return strconv.AppendBool(buf, b) -} - -func encodeString(buf []byte, s string) []byte { - return strconv.AppendQuote(buf, s) -} - -func encodeTime(buf []byte, t time.Time) []byte { - return append(buf, t.Format(time.RFC3339Nano)...) -} diff --git a/Godeps/_workspace/src/github.com/naoina/toml/encode_test.go b/Godeps/_workspace/src/github.com/naoina/toml/encode_test.go deleted file mode 100644 index 5d2fe02d2..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/encode_test.go +++ /dev/null @@ -1,298 +0,0 @@ -package toml_test - -import ( - "reflect" - "testing" - "time" - - "github.com/drone/drone/Godeps/_workspace/src/github.com/naoina/toml" -) - -func TestMarshal(t *testing.T) { - for _, v := range []struct { - v interface{} - expect string - }{ - {struct{ Name string }{"alice"}, "name=\"alice\"\n"}, - {struct{ Age int }{7}, "age=7\n"}, - {struct { - Name string - Age int - }{"alice", 7}, "name=\"alice\"\nage=7\n"}, - {struct { - Name string `toml:"-"` - Age int - }{"alice", 7}, "age=7\n"}, - {struct { - Name string `toml:"my_name"` - }{"bob"}, "my_name=\"bob\"\n"}, - {struct { - Name string `toml:"my_name,omitempty"` - }{"bob"}, "my_name=\"bob\"\n"}, - {struct { - Name string `toml:",omitempty"` - }{"bob"}, "name=\"bob\"\n"}, - {struct { - Name string `toml:",omitempty"` - }{""}, ""}, - } { - b, err := toml.Marshal(v.v) - var actual interface{} = err - var expect interface{} = nil - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`Marshal(%#v) => %#v; want %#v`, v.v, actual, expect) - } - - actual = string(b) - expect = v.expect - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`Marshal(%#v); v => %#v; want %#v`, v, actual, expect) - } - } -} - -func TestMarshalWhole(t *testing.T) { - for _, v := range []struct { - v interface{} - expect string - }{ - { - testStruct{ - Table: Table{ - Key: "value", - Subtable: Subtable{ - Key: "another value", - }, - Inline: Inline{ - Name: Name{ - First: "Tom", - Last: "Preston-Werner", - }, - Point: Point{ - X: 1, - Y: 2, - }, - }, - }, - X: X{}, - String: String{ - Basic: Basic{ - Basic: "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF.", - }, - Multiline: Multiline{ - Key1: "One\nTwo", - Continued: Continued{ - Key1: "The quick brown fox jumps over the lazy dog.", - }, - }, - Literal: Literal{ - Winpath: `C:\Users\nodejs\templates`, - Winpath2: `\\ServerX\admin$\system32\`, - Quoted: `Tom "Dubs" Preston-Werner`, - Regex: `<\i\c*\s*>`, - Multiline: LiteralMultiline{ - Regex2: `I [dw]on't need \d{2} apples`, - Lines: "The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n", - }, - }, - }, - Integer: Integer{ - Key1: 99, - Key2: 42, - Key3: 0, - Key4: -17, - Underscores: IntegerUnderscores{ - Key1: 1000, - Key2: 5349221, - Key3: 12345, - }, - }, - Float: Float{ - Fractional: Fractional{ - Key1: 1.0, - Key2: 3.1415, - Key3: -0.01, - }, - Exponent: Exponent{ - Key1: 5e22, - Key2: 1e6, - Key3: -2e-2, - }, - Both: Both{ - Key: 6.626e-34, - }, - Underscores: FloatUnderscores{ - Key1: 9224617.445991228313, - Key2: 1e100, - }, - }, - Boolean: Boolean{ - True: true, - False: false, - }, - Datetime: Datetime{ - Key1: mustTime(time.Parse(time.RFC3339Nano, "1979-05-27T07:32:00Z")), - Key2: mustTime(time.Parse(time.RFC3339Nano, "1979-05-27T00:32:00-07:00")), - Key3: mustTime(time.Parse(time.RFC3339Nano, "1979-05-27T00:32:00.999999-07:00")), - }, - Array: Array{ - Key1: []int{1, 2, 3}, - Key2: []string{"red", "yellow", "green"}, - Key3: [][]int{{1, 2}, {3, 4, 5}}, - Key4: [][]interface{}{{int64(1), int64(2)}, {"a", "b", "c"}}, - Key5: []int{1, 2, 3}, - Key6: []int{1, 2}, - }, - Products: []Product{ - {Name: "Hammer", Sku: 738594937}, - {}, - {Name: "Nail", Sku: 284758393, Color: "gray"}, - }, - Fruit: []Fruit{ - { - Name: "apple", - Physical: Physical{ - Color: "red", - Shape: "round", - }, - Variety: []Variety{ - {Name: "red delicious"}, - {Name: "granny smith"}, - }, - }, - { - Name: "banana", - Variety: []Variety{ - {Name: "plantain"}, - }, - }, - }, - }, - `[table] -key="value" -[table.subtable] -key="another value" -[table.inline] -[table.inline.name] -first="Tom" -last="Preston-Werner" -[table.inline.point] -x=1 -y=2 -[x] -[x.y] -[x.y.z] -[x.y.z.w] -[string] -[string.basic] -basic="I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF." -[string.multiline] -key1="One\nTwo" -key2="" -key3="" -[string.multiline.continued] -key1="The quick brown fox jumps over the lazy dog." -key2="" -key3="" -[string.literal] -winpath="C:\\Users\\nodejs\\templates" -winpath2="\\\\ServerX\\admin$\\system32\\" -quoted="Tom \"Dubs\" Preston-Werner" -regex="<\\i\\c*\\s*>" -[string.literal.multiline] -regex2="I [dw]on't need \\d{2} apples" -lines="The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n" -[integer] -key1=99 -key2=42 -key3=0 -key4=-17 -[integer.underscores] -key1=1000 -key2=5349221 -key3=12345 -[float] -[float.fractional] -key1=1e+00 -key2=3.1415e+00 -key3=-1e-02 -[float.exponent] -key1=5e+22 -key2=1e+06 -key3=-2e-02 -[float.both] -key=6.626e-34 -[float.underscores] -key1=9.224617445991227e+06 -key2=1e+100 -[boolean] -true=true -false=false -[datetime] -key1=1979-05-27T07:32:00Z -key2=1979-05-27T00:32:00-07:00 -key3=1979-05-27T00:32:00.999999-07:00 -[array] -key1=[1,2,3] -key2=["red","yellow","green"] -key3=[[1,2],[3,4,5]] -key4=[[1,2],["a","b","c"]] -key5=[1,2,3] -key6=[1,2] -[[products]] -name="Hammer" -sku=738594937 -color="" -[[products]] -name="" -sku=0 -color="" -[[products]] -name="Nail" -sku=284758393 -color="gray" -[[fruit]] -name="apple" -[fruit.physical] -color="red" -shape="round" -[[fruit.variety]] -name="red delicious" -[[fruit.variety]] -name="granny smith" -[[fruit]] -name="banana" -[fruit.physical] -color="" -shape="" -[[fruit.variety]] -name="plantain" -`, - }, - } { - b, err := toml.Marshal(v.v) - var actual interface{} = err - var expect interface{} = nil - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`Marshal(%#v) => %#v; want %#v`, v.v, actual, expect) - } - actual = string(b) - expect = v.expect - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`Marshal(%#v); v => %#v; want %#v`, v.v, actual, expect) - } - - // test for reversible. - dest := testStruct{} - actual = toml.Unmarshal(b, &dest) - expect = nil - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`Unmarshal after Marshal => %#v; want %#v`, actual, expect) - } - actual = dest - expect = v.v - if !reflect.DeepEqual(actual, expect) { - t.Errorf(`Unmarshal after Marshal => %#v; want %#v`, v, actual, expect) - } - } -} diff --git a/Godeps/_workspace/src/github.com/naoina/toml/error.go b/Godeps/_workspace/src/github.com/naoina/toml/error.go deleted file mode 100644 index 0261b3c2b..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/error.go +++ /dev/null @@ -1,31 +0,0 @@ -package toml - -import ( - "fmt" - "reflect" -) - -func (e *parseError) Line() int { - tokens := e.p.tokenTree.Error() - positions := make([]int, len(tokens)*2) - p := 0 - for _, token := range tokens { - positions[p], p = int(token.begin), p+1 - positions[p], p = int(token.end), p+1 - } - for _, t := range translatePositions(e.p.Buffer, positions) { - if e.p.line < t.line { - e.p.line = t.line - } - } - return e.p.line -} - -type errorOutOfRange struct { - kind reflect.Kind - v interface{} -} - -func (err *errorOutOfRange) Error() string { - return fmt.Sprintf("value %d is out of range for `%v` type", err.v, err.kind) -} diff --git a/Godeps/_workspace/src/github.com/naoina/toml/parse.go b/Godeps/_workspace/src/github.com/naoina/toml/parse.go deleted file mode 100644 index 00986a2c2..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/parse.go +++ /dev/null @@ -1,54 +0,0 @@ -package toml - -import ( - "fmt" - - "github.com/drone/drone/Godeps/_workspace/src/github.com/naoina/toml/ast" -) - -// Parse returns an AST representation of TOML. -// The toplevel is represented by a table. -func Parse(data []byte) (*ast.Table, error) { - d := &parseState{p: &tomlParser{Buffer: string(data)}} - d.init() - - if err := d.parse(); err != nil { - return nil, err - } - - return d.p.toml.table, nil -} - -type parseState struct { - p *tomlParser -} - -func (d *parseState) init() { - d.p.Init() - d.p.toml.init() -} - -func (d *parseState) parse() error { - if err := d.p.Parse(); err != nil { - if err, ok := err.(*parseError); ok { - return fmt.Errorf("toml: line %d: parse error", err.Line()) - } - return err - } - return d.execute() -} - -func (d *parseState) execute() (err error) { - defer func() { - e := recover() - if e != nil { - cerr, ok := e.(convertError) - if !ok { - panic(e) - } - err = cerr.err - } - }() - d.p.Execute() - return nil -} diff --git a/Godeps/_workspace/src/github.com/naoina/toml/parse.peg b/Godeps/_workspace/src/github.com/naoina/toml/parse.peg deleted file mode 100644 index 0380a201d..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/parse.peg +++ /dev/null @@ -1,138 +0,0 @@ -package toml - -type tomlParser Peg { - toml -} - -TOML <- Expression (newline Expression)* newline? !. { _ = buffer } - -Expression <- ( - { p.SetTableString(begin, end) } - / ws keyval ws comment? - / ws comment? - / ws -) - -newline <- <[\r\n]+> { p.AddLineCount(end - begin) } - -ws <- [ \t]* -wsnl <- ( - [ \t] - / <[\r\n]> { p.AddLineCount(end - begin) } -)* - -comment <- '#' <[\t -\0x10FFFF]*> - -keyval <- key ws '=' ws val { p.AddKeyValue() } - -key <- bareKey / quotedKey - -bareKey <- <[0-9A-Za-z\-_]+> { p.SetKey(p.buffer, begin, end) } - -quotedKey <- '"' '"' { p.SetKey(p.buffer, begin, end) } - -val <- ( - { p.SetTime(begin, end) } - / { p.SetFloat64(begin, end) } - / { p.SetInt64(begin, end) } - / { p.SetString(begin, end) } - / { p.SetBool(begin, end) } - / { p.SetArray(begin, end) } - / inlineTable -) - -table <- stdTable / arrayTable - -stdTable <- '[' ws ws ']' { p.SetTable(p.buffer, begin, end) } - -arrayTable <- '[[' ws ws ']]' { p.SetArrayTable(p.buffer, begin, end) } - -inlineTable <- ( - '{' { p.StartInlineTable() } - ws inlineTableKeyValues ws - '}' { p.EndInlineTable() } -) - -inlineTableKeyValues <- (keyval inlineTableValSep?)* - -tableKey <- key (tableKeySep key)* - -tableKeySep <- ws '.' ws - -inlineTableValSep <- ws ',' ws - -integer <- [\-+]? int -int <- [1-9] (digit / '_' digit)+ / digit - -float <- integer (frac exp? / frac? exp) -frac <- '.' digit (digit / '_' digit)* -exp <- [eE] [\-+]? digit (digit / '_' digit)* - -string <- ( - mlLiteralString - / literalString - / mlBasicString - / basicString -) - -basicString <- <'"' basicChar* '"'> { p.SetBasicString(p.buffer, begin, end) } - -basicChar <- basicUnescaped / escaped -escaped <- escape ([btnfr"/\\] / 'u' hexQuad / 'U' hexQuad hexQuad) - -basicUnescaped <- [ -!#-\[\]-\0x10FFFF] - -escape <- '\\' - -mlBasicString <- '"""' mlBasicBody '"""' { p.SetMultilineString() } - -mlBasicBody <- ( - { p.AddMultilineBasicBody(p.buffer, begin, end) } - / escape newline wsnl -)* - -literalString <- "'" "'" { p.SetLiteralString(p.buffer, begin, end) } - -literalChar <- [\t -&(-\0x10FFFF] - -mlLiteralString <- "'''" "'''" { p.SetMultilineLiteralString(p.buffer, begin, end) } - -mlLiteralBody <- (!"'''" (mlLiteralChar / newline))* - -mlLiteralChar <- [\t -\0x10FFFF] - -hexdigit <- [0-9A-Fa-f] -hexQuad <- hexdigit hexdigit hexdigit hexdigit - -boolean <- 'true' / 'false' - -dateFullYear <- digitQuad -dateMonth <- digitDual -dateMDay <- digitDual -timeHour <- digitDual -timeMinute <- digitDual -timeSecond <- digitDual -timeSecfrac <- '.' digit+ -timeNumoffset <- [\-+] timeHour ':' timeMinute -timeOffset <- 'Z' / timeNumoffset -partialTime <- timeHour ':' timeMinute ':' timeSecond timeSecfrac? -fullDate <- dateFullYear '-' dateMonth '-' dateMDay -fullTime <- partialTime timeOffset -datetime <- fullDate 'T' fullTime - -digit <- [0-9] -digitDual <- digit digit -digitQuad <- digitDual digitDual - -array <- ( - '[' { p.StartArray() } - wsnl arrayValues wsnl - ']' -) - -arrayValues <- ( - val { p.AddArrayVal() } - arraySep? (comment? newline)? -)* - -arraySep <- ws ',' wsnl diff --git a/Godeps/_workspace/src/github.com/naoina/toml/parse.peg.go b/Godeps/_workspace/src/github.com/naoina/toml/parse.peg.go deleted file mode 100644 index ce967e968..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/parse.peg.go +++ /dev/null @@ -1,3065 +0,0 @@ -package toml - -import ( - "fmt" - "math" - "sort" - "strconv" -) - -const end_symbol rune = 4 - -/* The rule types inferred from the grammar are below. */ -type pegRule uint8 - -const ( - ruleUnknown pegRule = iota - ruleTOML - ruleExpression - rulenewline - rulews - rulewsnl - rulecomment - rulekeyval - rulekey - rulebareKey - rulequotedKey - ruleval - ruletable - rulestdTable - rulearrayTable - ruleinlineTable - ruleinlineTableKeyValues - ruletableKey - ruletableKeySep - ruleinlineTableValSep - ruleinteger - ruleint - rulefloat - rulefrac - ruleexp - rulestring - rulebasicString - rulebasicChar - ruleescaped - rulebasicUnescaped - ruleescape - rulemlBasicString - rulemlBasicBody - ruleliteralString - ruleliteralChar - rulemlLiteralString - rulemlLiteralBody - rulemlLiteralChar - rulehexdigit - rulehexQuad - ruleboolean - ruledateFullYear - ruledateMonth - ruledateMDay - ruletimeHour - ruletimeMinute - ruletimeSecond - ruletimeSecfrac - ruletimeNumoffset - ruletimeOffset - rulepartialTime - rulefullDate - rulefullTime - ruledatetime - ruledigit - ruledigitDual - ruledigitQuad - rulearray - rulearrayValues - rulearraySep - ruleAction0 - rulePegText - ruleAction1 - ruleAction2 - ruleAction3 - ruleAction4 - ruleAction5 - ruleAction6 - ruleAction7 - ruleAction8 - ruleAction9 - ruleAction10 - ruleAction11 - ruleAction12 - ruleAction13 - ruleAction14 - ruleAction15 - ruleAction16 - ruleAction17 - ruleAction18 - ruleAction19 - ruleAction20 - ruleAction21 - ruleAction22 - ruleAction23 - - rulePre_ - rule_In_ - rule_Suf -) - -var rul3s = [...]string{ - "Unknown", - "TOML", - "Expression", - "newline", - "ws", - "wsnl", - "comment", - "keyval", - "key", - "bareKey", - "quotedKey", - "val", - "table", - "stdTable", - "arrayTable", - "inlineTable", - "inlineTableKeyValues", - "tableKey", - "tableKeySep", - "inlineTableValSep", - "integer", - "int", - "float", - "frac", - "exp", - "string", - "basicString", - "basicChar", - "escaped", - "basicUnescaped", - "escape", - "mlBasicString", - "mlBasicBody", - "literalString", - "literalChar", - "mlLiteralString", - "mlLiteralBody", - "mlLiteralChar", - "hexdigit", - "hexQuad", - "boolean", - "dateFullYear", - "dateMonth", - "dateMDay", - "timeHour", - "timeMinute", - "timeSecond", - "timeSecfrac", - "timeNumoffset", - "timeOffset", - "partialTime", - "fullDate", - "fullTime", - "datetime", - "digit", - "digitDual", - "digitQuad", - "array", - "arrayValues", - "arraySep", - "Action0", - "PegText", - "Action1", - "Action2", - "Action3", - "Action4", - "Action5", - "Action6", - "Action7", - "Action8", - "Action9", - "Action10", - "Action11", - "Action12", - "Action13", - "Action14", - "Action15", - "Action16", - "Action17", - "Action18", - "Action19", - "Action20", - "Action21", - "Action22", - "Action23", - - "Pre_", - "_In_", - "_Suf", -} - -type tokenTree interface { - Print() - PrintSyntax() - PrintSyntaxTree(buffer string) - Add(rule pegRule, begin, end, next, depth int) - Expand(index int) tokenTree - Tokens() <-chan token32 - AST() *node32 - Error() []token32 - trim(length int) -} - -type node32 struct { - token32 - up, next *node32 -} - -func (node *node32) print(depth int, buffer string) { - for node != nil { - for c := 0; c < depth; c++ { - fmt.Printf(" ") - } - fmt.Printf("\x1B[34m%v\x1B[m %v\n", rul3s[node.pegRule], strconv.Quote(string(([]rune(buffer)[node.begin:node.end])))) - if node.up != nil { - node.up.print(depth+1, buffer) - } - node = node.next - } -} - -func (ast *node32) Print(buffer string) { - ast.print(0, buffer) -} - -type element struct { - node *node32 - down *element -} - -/* ${@} bit structure for abstract syntax tree */ -type token16 struct { - pegRule - begin, end, next int16 -} - -func (t *token16) isZero() bool { - return t.pegRule == ruleUnknown && t.begin == 0 && t.end == 0 && t.next == 0 -} - -func (t *token16) isParentOf(u token16) bool { - return t.begin <= u.begin && t.end >= u.end && t.next > u.next -} - -func (t *token16) getToken32() token32 { - return token32{pegRule: t.pegRule, begin: int32(t.begin), end: int32(t.end), next: int32(t.next)} -} - -func (t *token16) String() string { - return fmt.Sprintf("\x1B[34m%v\x1B[m %v %v %v", rul3s[t.pegRule], t.begin, t.end, t.next) -} - -type tokens16 struct { - tree []token16 - ordered [][]token16 -} - -func (t *tokens16) trim(length int) { - t.tree = t.tree[0:length] -} - -func (t *tokens16) Print() { - for _, token := range t.tree { - fmt.Println(token.String()) - } -} - -func (t *tokens16) Order() [][]token16 { - if t.ordered != nil { - return t.ordered - } - - depths := make([]int16, 1, math.MaxInt16) - for i, token := range t.tree { - if token.pegRule == ruleUnknown { - t.tree = t.tree[:i] - break - } - depth := int(token.next) - if length := len(depths); depth >= length { - depths = depths[:depth+1] - } - depths[depth]++ - } - depths = append(depths, 0) - - ordered, pool := make([][]token16, len(depths)), make([]token16, len(t.tree)+len(depths)) - for i, depth := range depths { - depth++ - ordered[i], pool, depths[i] = pool[:depth], pool[depth:], 0 - } - - for i, token := range t.tree { - depth := token.next - token.next = int16(i) - ordered[depth][depths[depth]] = token - depths[depth]++ - } - t.ordered = ordered - return ordered -} - -type state16 struct { - token16 - depths []int16 - leaf bool -} - -func (t *tokens16) AST() *node32 { - tokens := t.Tokens() - stack := &element{node: &node32{token32: <-tokens}} - for token := range tokens { - if token.begin == token.end { - continue - } - node := &node32{token32: token} - for stack != nil && stack.node.begin >= token.begin && stack.node.end <= token.end { - stack.node.next = node.up - node.up = stack.node - stack = stack.down - } - stack = &element{node: node, down: stack} - } - return stack.node -} - -func (t *tokens16) PreOrder() (<-chan state16, [][]token16) { - s, ordered := make(chan state16, 6), t.Order() - go func() { - var states [8]state16 - for i, _ := range states { - states[i].depths = make([]int16, len(ordered)) - } - depths, state, depth := make([]int16, len(ordered)), 0, 1 - write := func(t token16, leaf bool) { - S := states[state] - state, S.pegRule, S.begin, S.end, S.next, S.leaf = (state+1)%8, t.pegRule, t.begin, t.end, int16(depth), leaf - copy(S.depths, depths) - s <- S - } - - states[state].token16 = ordered[0][0] - depths[0]++ - state++ - a, b := ordered[depth-1][depths[depth-1]-1], ordered[depth][depths[depth]] - depthFirstSearch: - for { - for { - if i := depths[depth]; i > 0 { - if c, j := ordered[depth][i-1], depths[depth-1]; a.isParentOf(c) && - (j < 2 || !ordered[depth-1][j-2].isParentOf(c)) { - if c.end != b.begin { - write(token16{pegRule: rule_In_, begin: c.end, end: b.begin}, true) - } - break - } - } - - if a.begin < b.begin { - write(token16{pegRule: rulePre_, begin: a.begin, end: b.begin}, true) - } - break - } - - next := depth + 1 - if c := ordered[next][depths[next]]; c.pegRule != ruleUnknown && b.isParentOf(c) { - write(b, false) - depths[depth]++ - depth, a, b = next, b, c - continue - } - - write(b, true) - depths[depth]++ - c, parent := ordered[depth][depths[depth]], true - for { - if c.pegRule != ruleUnknown && a.isParentOf(c) { - b = c - continue depthFirstSearch - } else if parent && b.end != a.end { - write(token16{pegRule: rule_Suf, begin: b.end, end: a.end}, true) - } - - depth-- - if depth > 0 { - a, b, c = ordered[depth-1][depths[depth-1]-1], a, ordered[depth][depths[depth]] - parent = a.isParentOf(b) - continue - } - - break depthFirstSearch - } - } - - close(s) - }() - return s, ordered -} - -func (t *tokens16) PrintSyntax() { - tokens, ordered := t.PreOrder() - max := -1 - for token := range tokens { - if !token.leaf { - fmt.Printf("%v", token.begin) - for i, leaf, depths := 0, int(token.next), token.depths; i < leaf; i++ { - fmt.Printf(" \x1B[36m%v\x1B[m", rul3s[ordered[i][depths[i]-1].pegRule]) - } - fmt.Printf(" \x1B[36m%v\x1B[m\n", rul3s[token.pegRule]) - } else if token.begin == token.end { - fmt.Printf("%v", token.begin) - for i, leaf, depths := 0, int(token.next), token.depths; i < leaf; i++ { - fmt.Printf(" \x1B[31m%v\x1B[m", rul3s[ordered[i][depths[i]-1].pegRule]) - } - fmt.Printf(" \x1B[31m%v\x1B[m\n", rul3s[token.pegRule]) - } else { - for c, end := token.begin, token.end; c < end; c++ { - if i := int(c); max+1 < i { - for j := max; j < i; j++ { - fmt.Printf("skip %v %v\n", j, token.String()) - } - max = i - } else if i := int(c); i <= max { - for j := i; j <= max; j++ { - fmt.Printf("dupe %v %v\n", j, token.String()) - } - } else { - max = int(c) - } - fmt.Printf("%v", c) - for i, leaf, depths := 0, int(token.next), token.depths; i < leaf; i++ { - fmt.Printf(" \x1B[34m%v\x1B[m", rul3s[ordered[i][depths[i]-1].pegRule]) - } - fmt.Printf(" \x1B[34m%v\x1B[m\n", rul3s[token.pegRule]) - } - fmt.Printf("\n") - } - } -} - -func (t *tokens16) PrintSyntaxTree(buffer string) { - tokens, _ := t.PreOrder() - for token := range tokens { - for c := 0; c < int(token.next); c++ { - fmt.Printf(" ") - } - fmt.Printf("\x1B[34m%v\x1B[m %v\n", rul3s[token.pegRule], strconv.Quote(string(([]rune(buffer)[token.begin:token.end])))) - } -} - -func (t *tokens16) Add(rule pegRule, begin, end, depth, index int) { - t.tree[index] = token16{pegRule: rule, begin: int16(begin), end: int16(end), next: int16(depth)} -} - -func (t *tokens16) Tokens() <-chan token32 { - s := make(chan token32, 16) - go func() { - for _, v := range t.tree { - s <- v.getToken32() - } - close(s) - }() - return s -} - -func (t *tokens16) Error() []token32 { - ordered := t.Order() - length := len(ordered) - tokens, length := make([]token32, length), length-1 - for i, _ := range tokens { - o := ordered[length-i] - if len(o) > 1 { - tokens[i] = o[len(o)-2].getToken32() - } - } - return tokens -} - -/* ${@} bit structure for abstract syntax tree */ -type token32 struct { - pegRule - begin, end, next int32 -} - -func (t *token32) isZero() bool { - return t.pegRule == ruleUnknown && t.begin == 0 && t.end == 0 && t.next == 0 -} - -func (t *token32) isParentOf(u token32) bool { - return t.begin <= u.begin && t.end >= u.end && t.next > u.next -} - -func (t *token32) getToken32() token32 { - return token32{pegRule: t.pegRule, begin: int32(t.begin), end: int32(t.end), next: int32(t.next)} -} - -func (t *token32) String() string { - return fmt.Sprintf("\x1B[34m%v\x1B[m %v %v %v", rul3s[t.pegRule], t.begin, t.end, t.next) -} - -type tokens32 struct { - tree []token32 - ordered [][]token32 -} - -func (t *tokens32) trim(length int) { - t.tree = t.tree[0:length] -} - -func (t *tokens32) Print() { - for _, token := range t.tree { - fmt.Println(token.String()) - } -} - -func (t *tokens32) Order() [][]token32 { - if t.ordered != nil { - return t.ordered - } - - depths := make([]int32, 1, math.MaxInt16) - for i, token := range t.tree { - if token.pegRule == ruleUnknown { - t.tree = t.tree[:i] - break - } - depth := int(token.next) - if length := len(depths); depth >= length { - depths = depths[:depth+1] - } - depths[depth]++ - } - depths = append(depths, 0) - - ordered, pool := make([][]token32, len(depths)), make([]token32, len(t.tree)+len(depths)) - for i, depth := range depths { - depth++ - ordered[i], pool, depths[i] = pool[:depth], pool[depth:], 0 - } - - for i, token := range t.tree { - depth := token.next - token.next = int32(i) - ordered[depth][depths[depth]] = token - depths[depth]++ - } - t.ordered = ordered - return ordered -} - -type state32 struct { - token32 - depths []int32 - leaf bool -} - -func (t *tokens32) AST() *node32 { - tokens := t.Tokens() - stack := &element{node: &node32{token32: <-tokens}} - for token := range tokens { - if token.begin == token.end { - continue - } - node := &node32{token32: token} - for stack != nil && stack.node.begin >= token.begin && stack.node.end <= token.end { - stack.node.next = node.up - node.up = stack.node - stack = stack.down - } - stack = &element{node: node, down: stack} - } - return stack.node -} - -func (t *tokens32) PreOrder() (<-chan state32, [][]token32) { - s, ordered := make(chan state32, 6), t.Order() - go func() { - var states [8]state32 - for i, _ := range states { - states[i].depths = make([]int32, len(ordered)) - } - depths, state, depth := make([]int32, len(ordered)), 0, 1 - write := func(t token32, leaf bool) { - S := states[state] - state, S.pegRule, S.begin, S.end, S.next, S.leaf = (state+1)%8, t.pegRule, t.begin, t.end, int32(depth), leaf - copy(S.depths, depths) - s <- S - } - - states[state].token32 = ordered[0][0] - depths[0]++ - state++ - a, b := ordered[depth-1][depths[depth-1]-1], ordered[depth][depths[depth]] - depthFirstSearch: - for { - for { - if i := depths[depth]; i > 0 { - if c, j := ordered[depth][i-1], depths[depth-1]; a.isParentOf(c) && - (j < 2 || !ordered[depth-1][j-2].isParentOf(c)) { - if c.end != b.begin { - write(token32{pegRule: rule_In_, begin: c.end, end: b.begin}, true) - } - break - } - } - - if a.begin < b.begin { - write(token32{pegRule: rulePre_, begin: a.begin, end: b.begin}, true) - } - break - } - - next := depth + 1 - if c := ordered[next][depths[next]]; c.pegRule != ruleUnknown && b.isParentOf(c) { - write(b, false) - depths[depth]++ - depth, a, b = next, b, c - continue - } - - write(b, true) - depths[depth]++ - c, parent := ordered[depth][depths[depth]], true - for { - if c.pegRule != ruleUnknown && a.isParentOf(c) { - b = c - continue depthFirstSearch - } else if parent && b.end != a.end { - write(token32{pegRule: rule_Suf, begin: b.end, end: a.end}, true) - } - - depth-- - if depth > 0 { - a, b, c = ordered[depth-1][depths[depth-1]-1], a, ordered[depth][depths[depth]] - parent = a.isParentOf(b) - continue - } - - break depthFirstSearch - } - } - - close(s) - }() - return s, ordered -} - -func (t *tokens32) PrintSyntax() { - tokens, ordered := t.PreOrder() - max := -1 - for token := range tokens { - if !token.leaf { - fmt.Printf("%v", token.begin) - for i, leaf, depths := 0, int(token.next), token.depths; i < leaf; i++ { - fmt.Printf(" \x1B[36m%v\x1B[m", rul3s[ordered[i][depths[i]-1].pegRule]) - } - fmt.Printf(" \x1B[36m%v\x1B[m\n", rul3s[token.pegRule]) - } else if token.begin == token.end { - fmt.Printf("%v", token.begin) - for i, leaf, depths := 0, int(token.next), token.depths; i < leaf; i++ { - fmt.Printf(" \x1B[31m%v\x1B[m", rul3s[ordered[i][depths[i]-1].pegRule]) - } - fmt.Printf(" \x1B[31m%v\x1B[m\n", rul3s[token.pegRule]) - } else { - for c, end := token.begin, token.end; c < end; c++ { - if i := int(c); max+1 < i { - for j := max; j < i; j++ { - fmt.Printf("skip %v %v\n", j, token.String()) - } - max = i - } else if i := int(c); i <= max { - for j := i; j <= max; j++ { - fmt.Printf("dupe %v %v\n", j, token.String()) - } - } else { - max = int(c) - } - fmt.Printf("%v", c) - for i, leaf, depths := 0, int(token.next), token.depths; i < leaf; i++ { - fmt.Printf(" \x1B[34m%v\x1B[m", rul3s[ordered[i][depths[i]-1].pegRule]) - } - fmt.Printf(" \x1B[34m%v\x1B[m\n", rul3s[token.pegRule]) - } - fmt.Printf("\n") - } - } -} - -func (t *tokens32) PrintSyntaxTree(buffer string) { - tokens, _ := t.PreOrder() - for token := range tokens { - for c := 0; c < int(token.next); c++ { - fmt.Printf(" ") - } - fmt.Printf("\x1B[34m%v\x1B[m %v\n", rul3s[token.pegRule], strconv.Quote(string(([]rune(buffer)[token.begin:token.end])))) - } -} - -func (t *tokens32) Add(rule pegRule, begin, end, depth, index int) { - t.tree[index] = token32{pegRule: rule, begin: int32(begin), end: int32(end), next: int32(depth)} -} - -func (t *tokens32) Tokens() <-chan token32 { - s := make(chan token32, 16) - go func() { - for _, v := range t.tree { - s <- v.getToken32() - } - close(s) - }() - return s -} - -func (t *tokens32) Error() []token32 { - ordered := t.Order() - length := len(ordered) - tokens, length := make([]token32, length), length-1 - for i, _ := range tokens { - o := ordered[length-i] - if len(o) > 1 { - tokens[i] = o[len(o)-2].getToken32() - } - } - return tokens -} - -func (t *tokens16) Expand(index int) tokenTree { - tree := t.tree - if index >= len(tree) { - expanded := make([]token32, 2*len(tree)) - for i, v := range tree { - expanded[i] = v.getToken32() - } - return &tokens32{tree: expanded} - } - return nil -} - -func (t *tokens32) Expand(index int) tokenTree { - tree := t.tree - if index >= len(tree) { - expanded := make([]token32, 2*len(tree)) - copy(expanded, tree) - t.tree = expanded - } - return nil -} - -type tomlParser struct { - toml - - Buffer string - buffer []rune - rules [85]func() bool - Parse func(rule ...int) error - Reset func() - tokenTree -} - -type textPosition struct { - line, symbol int -} - -type textPositionMap map[int]textPosition - -func translatePositions(buffer string, positions []int) textPositionMap { - length, translations, j, line, symbol := len(positions), make(textPositionMap, len(positions)), 0, 1, 0 - sort.Ints(positions) - -search: - for i, c := range buffer[0:] { - if c == '\n' { - line, symbol = line+1, 0 - } else { - symbol++ - } - if i == positions[j] { - translations[positions[j]] = textPosition{line, symbol} - for j++; j < length; j++ { - if i != positions[j] { - continue search - } - } - break search - } - } - - return translations -} - -type parseError struct { - p *tomlParser -} - -func (e *parseError) Error() string { - tokens, error := e.p.tokenTree.Error(), "\n" - positions, p := make([]int, 2*len(tokens)), 0 - for _, token := range tokens { - positions[p], p = int(token.begin), p+1 - positions[p], p = int(token.end), p+1 - } - translations := translatePositions(e.p.Buffer, positions) - for _, token := range tokens { - begin, end := int(token.begin), int(token.end) - error += fmt.Sprintf("parse error near \x1B[34m%v\x1B[m (line %v symbol %v - line %v symbol %v):\n%v\n", - rul3s[token.pegRule], - translations[begin].line, translations[begin].symbol, - translations[end].line, translations[end].symbol, - /*strconv.Quote(*/ e.p.Buffer[begin:end] /*)*/) - } - - return error -} - -func (p *tomlParser) PrintSyntaxTree() { - p.tokenTree.PrintSyntaxTree(p.Buffer) -} - -func (p *tomlParser) Highlighter() { - p.tokenTree.PrintSyntax() -} - -func (p *tomlParser) Execute() { - buffer, begin, end := p.Buffer, 0, 0 - for token := range p.tokenTree.Tokens() { - switch token.pegRule { - - case rulePegText: - begin, end = int(token.begin), int(token.end) - - case ruleAction0: - _ = buffer - case ruleAction1: - p.SetTableString(begin, end) - case ruleAction2: - p.AddLineCount(end - begin) - case ruleAction3: - p.AddLineCount(end - begin) - case ruleAction4: - p.AddKeyValue() - case ruleAction5: - p.SetKey(p.buffer, begin, end) - case ruleAction6: - p.SetKey(p.buffer, begin, end) - case ruleAction7: - p.SetTime(begin, end) - case ruleAction8: - p.SetFloat64(begin, end) - case ruleAction9: - p.SetInt64(begin, end) - case ruleAction10: - p.SetString(begin, end) - case ruleAction11: - p.SetBool(begin, end) - case ruleAction12: - p.SetArray(begin, end) - case ruleAction13: - p.SetTable(p.buffer, begin, end) - case ruleAction14: - p.SetArrayTable(p.buffer, begin, end) - case ruleAction15: - p.StartInlineTable() - case ruleAction16: - p.EndInlineTable() - case ruleAction17: - p.SetBasicString(p.buffer, begin, end) - case ruleAction18: - p.SetMultilineString() - case ruleAction19: - p.AddMultilineBasicBody(p.buffer, begin, end) - case ruleAction20: - p.SetLiteralString(p.buffer, begin, end) - case ruleAction21: - p.SetMultilineLiteralString(p.buffer, begin, end) - case ruleAction22: - p.StartArray() - case ruleAction23: - p.AddArrayVal() - - } - } - _, _, _ = buffer, begin, end -} - -func (p *tomlParser) Init() { - p.buffer = []rune(p.Buffer) - if len(p.buffer) == 0 || p.buffer[len(p.buffer)-1] != end_symbol { - p.buffer = append(p.buffer, end_symbol) - } - - var tree tokenTree = &tokens16{tree: make([]token16, math.MaxInt16)} - position, depth, tokenIndex, buffer, _rules := 0, 0, 0, p.buffer, p.rules - - p.Parse = func(rule ...int) error { - r := 1 - if len(rule) > 0 { - r = rule[0] - } - matches := p.rules[r]() - p.tokenTree = tree - if matches { - p.tokenTree.trim(tokenIndex) - return nil - } - return &parseError{p} - } - - p.Reset = func() { - position, tokenIndex, depth = 0, 0, 0 - } - - add := func(rule pegRule, begin int) { - if t := tree.Expand(tokenIndex); t != nil { - tree = t - } - tree.Add(rule, begin, position, depth, tokenIndex) - tokenIndex++ - } - - matchDot := func() bool { - if buffer[position] != end_symbol { - position++ - return true - } - return false - } - - /*matchChar := func(c byte) bool { - if buffer[position] == c { - position++ - return true - } - return false - }*/ - - /*matchRange := func(lower byte, upper byte) bool { - if c := buffer[position]; c >= lower && c <= upper { - position++ - return true - } - return false - }*/ - - _rules = [...]func() bool{ - nil, - /* 0 TOML <- <(Expression (newline Expression)* newline? !. Action0)> */ - func() bool { - position0, tokenIndex0, depth0 := position, tokenIndex, depth - { - position1 := position - depth++ - if !_rules[ruleExpression]() { - goto l0 - } - l2: - { - position3, tokenIndex3, depth3 := position, tokenIndex, depth - if !_rules[rulenewline]() { - goto l3 - } - if !_rules[ruleExpression]() { - goto l3 - } - goto l2 - l3: - position, tokenIndex, depth = position3, tokenIndex3, depth3 - } - { - position4, tokenIndex4, depth4 := position, tokenIndex, depth - if !_rules[rulenewline]() { - goto l4 - } - goto l5 - l4: - position, tokenIndex, depth = position4, tokenIndex4, depth4 - } - l5: - { - position6, tokenIndex6, depth6 := position, tokenIndex, depth - if !matchDot() { - goto l6 - } - goto l0 - l6: - position, tokenIndex, depth = position6, tokenIndex6, depth6 - } - { - add(ruleAction0, position) - } - depth-- - add(ruleTOML, position1) - } - return true - l0: - position, tokenIndex, depth = position0, tokenIndex0, depth0 - return false - }, - /* 1 Expression <- <((<(ws table ws comment? (wsnl keyval ws comment?)*)> Action1) / (ws keyval ws comment?) / (ws comment?) / ws)> */ - func() bool { - position8, tokenIndex8, depth8 := position, tokenIndex, depth - { - position9 := position - depth++ - { - position10, tokenIndex10, depth10 := position, tokenIndex, depth - { - position12 := position - depth++ - if !_rules[rulews]() { - goto l11 - } - { - position13 := position - depth++ - { - position14, tokenIndex14, depth14 := position, tokenIndex, depth - { - position16 := position - depth++ - if buffer[position] != rune('[') { - goto l15 - } - position++ - if !_rules[rulews]() { - goto l15 - } - { - position17 := position - depth++ - if !_rules[ruletableKey]() { - goto l15 - } - depth-- - add(rulePegText, position17) - } - if !_rules[rulews]() { - goto l15 - } - if buffer[position] != rune(']') { - goto l15 - } - position++ - { - add(ruleAction13, position) - } - depth-- - add(rulestdTable, position16) - } - goto l14 - l15: - position, tokenIndex, depth = position14, tokenIndex14, depth14 - { - position19 := position - depth++ - if buffer[position] != rune('[') { - goto l11 - } - position++ - if buffer[position] != rune('[') { - goto l11 - } - position++ - if !_rules[rulews]() { - goto l11 - } - { - position20 := position - depth++ - if !_rules[ruletableKey]() { - goto l11 - } - depth-- - add(rulePegText, position20) - } - if !_rules[rulews]() { - goto l11 - } - if buffer[position] != rune(']') { - goto l11 - } - position++ - if buffer[position] != rune(']') { - goto l11 - } - position++ - { - add(ruleAction14, position) - } - depth-- - add(rulearrayTable, position19) - } - } - l14: - depth-- - add(ruletable, position13) - } - if !_rules[rulews]() { - goto l11 - } - { - position22, tokenIndex22, depth22 := position, tokenIndex, depth - if !_rules[rulecomment]() { - goto l22 - } - goto l23 - l22: - position, tokenIndex, depth = position22, tokenIndex22, depth22 - } - l23: - l24: - { - position25, tokenIndex25, depth25 := position, tokenIndex, depth - if !_rules[rulewsnl]() { - goto l25 - } - if !_rules[rulekeyval]() { - goto l25 - } - if !_rules[rulews]() { - goto l25 - } - { - position26, tokenIndex26, depth26 := position, tokenIndex, depth - if !_rules[rulecomment]() { - goto l26 - } - goto l27 - l26: - position, tokenIndex, depth = position26, tokenIndex26, depth26 - } - l27: - goto l24 - l25: - position, tokenIndex, depth = position25, tokenIndex25, depth25 - } - depth-- - add(rulePegText, position12) - } - { - add(ruleAction1, position) - } - goto l10 - l11: - position, tokenIndex, depth = position10, tokenIndex10, depth10 - if !_rules[rulews]() { - goto l29 - } - if !_rules[rulekeyval]() { - goto l29 - } - if !_rules[rulews]() { - goto l29 - } - { - position30, tokenIndex30, depth30 := position, tokenIndex, depth - if !_rules[rulecomment]() { - goto l30 - } - goto l31 - l30: - position, tokenIndex, depth = position30, tokenIndex30, depth30 - } - l31: - goto l10 - l29: - position, tokenIndex, depth = position10, tokenIndex10, depth10 - if !_rules[rulews]() { - goto l32 - } - { - position33, tokenIndex33, depth33 := position, tokenIndex, depth - if !_rules[rulecomment]() { - goto l33 - } - goto l34 - l33: - position, tokenIndex, depth = position33, tokenIndex33, depth33 - } - l34: - goto l10 - l32: - position, tokenIndex, depth = position10, tokenIndex10, depth10 - if !_rules[rulews]() { - goto l8 - } - } - l10: - depth-- - add(ruleExpression, position9) - } - return true - l8: - position, tokenIndex, depth = position8, tokenIndex8, depth8 - return false - }, - /* 2 newline <- <(<('\r' / '\n')+> Action2)> */ - func() bool { - position35, tokenIndex35, depth35 := position, tokenIndex, depth - { - position36 := position - depth++ - { - position37 := position - depth++ - { - position40, tokenIndex40, depth40 := position, tokenIndex, depth - if buffer[position] != rune('\r') { - goto l41 - } - position++ - goto l40 - l41: - position, tokenIndex, depth = position40, tokenIndex40, depth40 - if buffer[position] != rune('\n') { - goto l35 - } - position++ - } - l40: - l38: - { - position39, tokenIndex39, depth39 := position, tokenIndex, depth - { - position42, tokenIndex42, depth42 := position, tokenIndex, depth - if buffer[position] != rune('\r') { - goto l43 - } - position++ - goto l42 - l43: - position, tokenIndex, depth = position42, tokenIndex42, depth42 - if buffer[position] != rune('\n') { - goto l39 - } - position++ - } - l42: - goto l38 - l39: - position, tokenIndex, depth = position39, tokenIndex39, depth39 - } - depth-- - add(rulePegText, position37) - } - { - add(ruleAction2, position) - } - depth-- - add(rulenewline, position36) - } - return true - l35: - position, tokenIndex, depth = position35, tokenIndex35, depth35 - return false - }, - /* 3 ws <- <(' ' / '\t')*> */ - func() bool { - { - position46 := position - depth++ - l47: - { - position48, tokenIndex48, depth48 := position, tokenIndex, depth - { - position49, tokenIndex49, depth49 := position, tokenIndex, depth - if buffer[position] != rune(' ') { - goto l50 - } - position++ - goto l49 - l50: - position, tokenIndex, depth = position49, tokenIndex49, depth49 - if buffer[position] != rune('\t') { - goto l48 - } - position++ - } - l49: - goto l47 - l48: - position, tokenIndex, depth = position48, tokenIndex48, depth48 - } - depth-- - add(rulews, position46) - } - return true - }, - /* 4 wsnl <- <((&('\t') '\t') | (&(' ') ' ') | (&('\n' | '\r') (<('\r' / '\n')> Action3)))*> */ - func() bool { - { - position52 := position - depth++ - l53: - { - position54, tokenIndex54, depth54 := position, tokenIndex, depth - { - switch buffer[position] { - case '\t': - if buffer[position] != rune('\t') { - goto l54 - } - position++ - break - case ' ': - if buffer[position] != rune(' ') { - goto l54 - } - position++ - break - default: - { - position56 := position - depth++ - { - position57, tokenIndex57, depth57 := position, tokenIndex, depth - if buffer[position] != rune('\r') { - goto l58 - } - position++ - goto l57 - l58: - position, tokenIndex, depth = position57, tokenIndex57, depth57 - if buffer[position] != rune('\n') { - goto l54 - } - position++ - } - l57: - depth-- - add(rulePegText, position56) - } - { - add(ruleAction3, position) - } - break - } - } - - goto l53 - l54: - position, tokenIndex, depth = position54, tokenIndex54, depth54 - } - depth-- - add(rulewsnl, position52) - } - return true - }, - /* 5 comment <- <('#' <('\t' / [ -􏿿])*>)> */ - func() bool { - position60, tokenIndex60, depth60 := position, tokenIndex, depth - { - position61 := position - depth++ - if buffer[position] != rune('#') { - goto l60 - } - position++ - { - position62 := position - depth++ - l63: - { - position64, tokenIndex64, depth64 := position, tokenIndex, depth - { - position65, tokenIndex65, depth65 := position, tokenIndex, depth - if buffer[position] != rune('\t') { - goto l66 - } - position++ - goto l65 - l66: - position, tokenIndex, depth = position65, tokenIndex65, depth65 - if c := buffer[position]; c < rune(' ') || c > rune('\U0010ffff') { - goto l64 - } - position++ - } - l65: - goto l63 - l64: - position, tokenIndex, depth = position64, tokenIndex64, depth64 - } - depth-- - add(rulePegText, position62) - } - depth-- - add(rulecomment, position61) - } - return true - l60: - position, tokenIndex, depth = position60, tokenIndex60, depth60 - return false - }, - /* 6 keyval <- <(key ws '=' ws val Action4)> */ - func() bool { - position67, tokenIndex67, depth67 := position, tokenIndex, depth - { - position68 := position - depth++ - if !_rules[rulekey]() { - goto l67 - } - if !_rules[rulews]() { - goto l67 - } - if buffer[position] != rune('=') { - goto l67 - } - position++ - if !_rules[rulews]() { - goto l67 - } - if !_rules[ruleval]() { - goto l67 - } - { - add(ruleAction4, position) - } - depth-- - add(rulekeyval, position68) - } - return true - l67: - position, tokenIndex, depth = position67, tokenIndex67, depth67 - return false - }, - /* 7 key <- <(bareKey / quotedKey)> */ - func() bool { - position70, tokenIndex70, depth70 := position, tokenIndex, depth - { - position71 := position - depth++ - { - position72, tokenIndex72, depth72 := position, tokenIndex, depth - { - position74 := position - depth++ - { - position75 := position - depth++ - { - switch buffer[position] { - case '_': - if buffer[position] != rune('_') { - goto l73 - } - position++ - break - case '-': - if buffer[position] != rune('-') { - goto l73 - } - position++ - break - case 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z': - if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l73 - } - position++ - break - case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l73 - } - position++ - break - default: - if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l73 - } - position++ - break - } - } - - l76: - { - position77, tokenIndex77, depth77 := position, tokenIndex, depth - { - switch buffer[position] { - case '_': - if buffer[position] != rune('_') { - goto l77 - } - position++ - break - case '-': - if buffer[position] != rune('-') { - goto l77 - } - position++ - break - case 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z': - if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l77 - } - position++ - break - case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l77 - } - position++ - break - default: - if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l77 - } - position++ - break - } - } - - goto l76 - l77: - position, tokenIndex, depth = position77, tokenIndex77, depth77 - } - depth-- - add(rulePegText, position75) - } - { - add(ruleAction5, position) - } - depth-- - add(rulebareKey, position74) - } - goto l72 - l73: - position, tokenIndex, depth = position72, tokenIndex72, depth72 - { - position81 := position - depth++ - if buffer[position] != rune('"') { - goto l70 - } - position++ - { - position82 := position - depth++ - if !_rules[rulebasicChar]() { - goto l70 - } - l83: - { - position84, tokenIndex84, depth84 := position, tokenIndex, depth - if !_rules[rulebasicChar]() { - goto l84 - } - goto l83 - l84: - position, tokenIndex, depth = position84, tokenIndex84, depth84 - } - depth-- - add(rulePegText, position82) - } - if buffer[position] != rune('"') { - goto l70 - } - position++ - { - add(ruleAction6, position) - } - depth-- - add(rulequotedKey, position81) - } - } - l72: - depth-- - add(rulekey, position71) - } - return true - l70: - position, tokenIndex, depth = position70, tokenIndex70, depth70 - return false - }, - /* 8 bareKey <- <(<((&('_') '_') | (&('-') '-') | (&('a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z') [a-z]) | (&('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') [0-9]) | (&('A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z') [A-Z]))+> Action5)> */ - nil, - /* 9 quotedKey <- <('"' '"' Action6)> */ - nil, - /* 10 val <- <(( Action7) / ( Action8) / ((&('{') inlineTable) | (&('[') ( Action12)) | (&('f' | 't') ( Action11)) | (&('"' | '\'') ( Action10)) | (&('+' | '-' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') ( Action9))))> */ - func() bool { - position88, tokenIndex88, depth88 := position, tokenIndex, depth - { - position89 := position - depth++ - { - position90, tokenIndex90, depth90 := position, tokenIndex, depth - { - position92 := position - depth++ - { - position93 := position - depth++ - { - position94 := position - depth++ - { - position95 := position - depth++ - { - position96 := position - depth++ - if !_rules[ruledigitDual]() { - goto l91 - } - if !_rules[ruledigitDual]() { - goto l91 - } - depth-- - add(ruledigitQuad, position96) - } - depth-- - add(ruledateFullYear, position95) - } - if buffer[position] != rune('-') { - goto l91 - } - position++ - { - position97 := position - depth++ - if !_rules[ruledigitDual]() { - goto l91 - } - depth-- - add(ruledateMonth, position97) - } - if buffer[position] != rune('-') { - goto l91 - } - position++ - { - position98 := position - depth++ - if !_rules[ruledigitDual]() { - goto l91 - } - depth-- - add(ruledateMDay, position98) - } - depth-- - add(rulefullDate, position94) - } - if buffer[position] != rune('T') { - goto l91 - } - position++ - { - position99 := position - depth++ - { - position100 := position - depth++ - if !_rules[ruletimeHour]() { - goto l91 - } - if buffer[position] != rune(':') { - goto l91 - } - position++ - if !_rules[ruletimeMinute]() { - goto l91 - } - if buffer[position] != rune(':') { - goto l91 - } - position++ - { - position101 := position - depth++ - if !_rules[ruledigitDual]() { - goto l91 - } - depth-- - add(ruletimeSecond, position101) - } - { - position102, tokenIndex102, depth102 := position, tokenIndex, depth - { - position104 := position - depth++ - if buffer[position] != rune('.') { - goto l102 - } - position++ - if !_rules[ruledigit]() { - goto l102 - } - l105: - { - position106, tokenIndex106, depth106 := position, tokenIndex, depth - if !_rules[ruledigit]() { - goto l106 - } - goto l105 - l106: - position, tokenIndex, depth = position106, tokenIndex106, depth106 - } - depth-- - add(ruletimeSecfrac, position104) - } - goto l103 - l102: - position, tokenIndex, depth = position102, tokenIndex102, depth102 - } - l103: - depth-- - add(rulepartialTime, position100) - } - { - position107 := position - depth++ - { - position108, tokenIndex108, depth108 := position, tokenIndex, depth - if buffer[position] != rune('Z') { - goto l109 - } - position++ - goto l108 - l109: - position, tokenIndex, depth = position108, tokenIndex108, depth108 - { - position110 := position - depth++ - { - position111, tokenIndex111, depth111 := position, tokenIndex, depth - if buffer[position] != rune('-') { - goto l112 - } - position++ - goto l111 - l112: - position, tokenIndex, depth = position111, tokenIndex111, depth111 - if buffer[position] != rune('+') { - goto l91 - } - position++ - } - l111: - if !_rules[ruletimeHour]() { - goto l91 - } - if buffer[position] != rune(':') { - goto l91 - } - position++ - if !_rules[ruletimeMinute]() { - goto l91 - } - depth-- - add(ruletimeNumoffset, position110) - } - } - l108: - depth-- - add(ruletimeOffset, position107) - } - depth-- - add(rulefullTime, position99) - } - depth-- - add(ruledatetime, position93) - } - depth-- - add(rulePegText, position92) - } - { - add(ruleAction7, position) - } - goto l90 - l91: - position, tokenIndex, depth = position90, tokenIndex90, depth90 - { - position115 := position - depth++ - { - position116 := position - depth++ - if !_rules[ruleinteger]() { - goto l114 - } - { - position117, tokenIndex117, depth117 := position, tokenIndex, depth - if !_rules[rulefrac]() { - goto l118 - } - { - position119, tokenIndex119, depth119 := position, tokenIndex, depth - if !_rules[ruleexp]() { - goto l119 - } - goto l120 - l119: - position, tokenIndex, depth = position119, tokenIndex119, depth119 - } - l120: - goto l117 - l118: - position, tokenIndex, depth = position117, tokenIndex117, depth117 - { - position121, tokenIndex121, depth121 := position, tokenIndex, depth - if !_rules[rulefrac]() { - goto l121 - } - goto l122 - l121: - position, tokenIndex, depth = position121, tokenIndex121, depth121 - } - l122: - if !_rules[ruleexp]() { - goto l114 - } - } - l117: - depth-- - add(rulefloat, position116) - } - depth-- - add(rulePegText, position115) - } - { - add(ruleAction8, position) - } - goto l90 - l114: - position, tokenIndex, depth = position90, tokenIndex90, depth90 - { - switch buffer[position] { - case '{': - { - position125 := position - depth++ - if buffer[position] != rune('{') { - goto l88 - } - position++ - { - add(ruleAction15, position) - } - if !_rules[rulews]() { - goto l88 - } - { - position127 := position - depth++ - l128: - { - position129, tokenIndex129, depth129 := position, tokenIndex, depth - if !_rules[rulekeyval]() { - goto l129 - } - { - position130, tokenIndex130, depth130 := position, tokenIndex, depth - { - position132 := position - depth++ - if !_rules[rulews]() { - goto l130 - } - if buffer[position] != rune(',') { - goto l130 - } - position++ - if !_rules[rulews]() { - goto l130 - } - depth-- - add(ruleinlineTableValSep, position132) - } - goto l131 - l130: - position, tokenIndex, depth = position130, tokenIndex130, depth130 - } - l131: - goto l128 - l129: - position, tokenIndex, depth = position129, tokenIndex129, depth129 - } - depth-- - add(ruleinlineTableKeyValues, position127) - } - if !_rules[rulews]() { - goto l88 - } - if buffer[position] != rune('}') { - goto l88 - } - position++ - { - add(ruleAction16, position) - } - depth-- - add(ruleinlineTable, position125) - } - break - case '[': - { - position134 := position - depth++ - { - position135 := position - depth++ - if buffer[position] != rune('[') { - goto l88 - } - position++ - { - add(ruleAction22, position) - } - if !_rules[rulewsnl]() { - goto l88 - } - { - position137 := position - depth++ - l138: - { - position139, tokenIndex139, depth139 := position, tokenIndex, depth - if !_rules[ruleval]() { - goto l139 - } - { - add(ruleAction23, position) - } - { - position141, tokenIndex141, depth141 := position, tokenIndex, depth - { - position143 := position - depth++ - if !_rules[rulews]() { - goto l141 - } - if buffer[position] != rune(',') { - goto l141 - } - position++ - if !_rules[rulewsnl]() { - goto l141 - } - depth-- - add(rulearraySep, position143) - } - goto l142 - l141: - position, tokenIndex, depth = position141, tokenIndex141, depth141 - } - l142: - { - position144, tokenIndex144, depth144 := position, tokenIndex, depth - { - position146, tokenIndex146, depth146 := position, tokenIndex, depth - if !_rules[rulecomment]() { - goto l146 - } - goto l147 - l146: - position, tokenIndex, depth = position146, tokenIndex146, depth146 - } - l147: - if !_rules[rulenewline]() { - goto l144 - } - goto l145 - l144: - position, tokenIndex, depth = position144, tokenIndex144, depth144 - } - l145: - goto l138 - l139: - position, tokenIndex, depth = position139, tokenIndex139, depth139 - } - depth-- - add(rulearrayValues, position137) - } - if !_rules[rulewsnl]() { - goto l88 - } - if buffer[position] != rune(']') { - goto l88 - } - position++ - depth-- - add(rulearray, position135) - } - depth-- - add(rulePegText, position134) - } - { - add(ruleAction12, position) - } - break - case 'f', 't': - { - position149 := position - depth++ - { - position150 := position - depth++ - { - position151, tokenIndex151, depth151 := position, tokenIndex, depth - if buffer[position] != rune('t') { - goto l152 - } - position++ - if buffer[position] != rune('r') { - goto l152 - } - position++ - if buffer[position] != rune('u') { - goto l152 - } - position++ - if buffer[position] != rune('e') { - goto l152 - } - position++ - goto l151 - l152: - position, tokenIndex, depth = position151, tokenIndex151, depth151 - if buffer[position] != rune('f') { - goto l88 - } - position++ - if buffer[position] != rune('a') { - goto l88 - } - position++ - if buffer[position] != rune('l') { - goto l88 - } - position++ - if buffer[position] != rune('s') { - goto l88 - } - position++ - if buffer[position] != rune('e') { - goto l88 - } - position++ - } - l151: - depth-- - add(ruleboolean, position150) - } - depth-- - add(rulePegText, position149) - } - { - add(ruleAction11, position) - } - break - case '"', '\'': - { - position154 := position - depth++ - { - position155 := position - depth++ - { - position156, tokenIndex156, depth156 := position, tokenIndex, depth - { - position158 := position - depth++ - if buffer[position] != rune('\'') { - goto l157 - } - position++ - if buffer[position] != rune('\'') { - goto l157 - } - position++ - if buffer[position] != rune('\'') { - goto l157 - } - position++ - { - position159 := position - depth++ - { - position160 := position - depth++ - l161: - { - position162, tokenIndex162, depth162 := position, tokenIndex, depth - { - position163, tokenIndex163, depth163 := position, tokenIndex, depth - if buffer[position] != rune('\'') { - goto l163 - } - position++ - if buffer[position] != rune('\'') { - goto l163 - } - position++ - if buffer[position] != rune('\'') { - goto l163 - } - position++ - goto l162 - l163: - position, tokenIndex, depth = position163, tokenIndex163, depth163 - } - { - position164, tokenIndex164, depth164 := position, tokenIndex, depth - { - position166 := position - depth++ - { - position167, tokenIndex167, depth167 := position, tokenIndex, depth - if buffer[position] != rune('\t') { - goto l168 - } - position++ - goto l167 - l168: - position, tokenIndex, depth = position167, tokenIndex167, depth167 - if c := buffer[position]; c < rune(' ') || c > rune('\U0010ffff') { - goto l165 - } - position++ - } - l167: - depth-- - add(rulemlLiteralChar, position166) - } - goto l164 - l165: - position, tokenIndex, depth = position164, tokenIndex164, depth164 - if !_rules[rulenewline]() { - goto l162 - } - } - l164: - goto l161 - l162: - position, tokenIndex, depth = position162, tokenIndex162, depth162 - } - depth-- - add(rulemlLiteralBody, position160) - } - depth-- - add(rulePegText, position159) - } - if buffer[position] != rune('\'') { - goto l157 - } - position++ - if buffer[position] != rune('\'') { - goto l157 - } - position++ - if buffer[position] != rune('\'') { - goto l157 - } - position++ - { - add(ruleAction21, position) - } - depth-- - add(rulemlLiteralString, position158) - } - goto l156 - l157: - position, tokenIndex, depth = position156, tokenIndex156, depth156 - { - position171 := position - depth++ - if buffer[position] != rune('\'') { - goto l170 - } - position++ - { - position172 := position - depth++ - l173: - { - position174, tokenIndex174, depth174 := position, tokenIndex, depth - { - position175 := position - depth++ - { - switch buffer[position] { - case '\t': - if buffer[position] != rune('\t') { - goto l174 - } - position++ - break - case ' ', '!', '"', '#', '$', '%', '&': - if c := buffer[position]; c < rune(' ') || c > rune('&') { - goto l174 - } - position++ - break - default: - if c := buffer[position]; c < rune('(') || c > rune('\U0010ffff') { - goto l174 - } - position++ - break - } - } - - depth-- - add(ruleliteralChar, position175) - } - goto l173 - l174: - position, tokenIndex, depth = position174, tokenIndex174, depth174 - } - depth-- - add(rulePegText, position172) - } - if buffer[position] != rune('\'') { - goto l170 - } - position++ - { - add(ruleAction20, position) - } - depth-- - add(ruleliteralString, position171) - } - goto l156 - l170: - position, tokenIndex, depth = position156, tokenIndex156, depth156 - { - position179 := position - depth++ - if buffer[position] != rune('"') { - goto l178 - } - position++ - if buffer[position] != rune('"') { - goto l178 - } - position++ - if buffer[position] != rune('"') { - goto l178 - } - position++ - { - position180 := position - depth++ - l181: - { - position182, tokenIndex182, depth182 := position, tokenIndex, depth - { - position183, tokenIndex183, depth183 := position, tokenIndex, depth - { - position185 := position - depth++ - { - position186, tokenIndex186, depth186 := position, tokenIndex, depth - if !_rules[rulebasicChar]() { - goto l187 - } - goto l186 - l187: - position, tokenIndex, depth = position186, tokenIndex186, depth186 - if !_rules[rulenewline]() { - goto l184 - } - } - l186: - depth-- - add(rulePegText, position185) - } - { - add(ruleAction19, position) - } - goto l183 - l184: - position, tokenIndex, depth = position183, tokenIndex183, depth183 - if !_rules[ruleescape]() { - goto l182 - } - if !_rules[rulenewline]() { - goto l182 - } - if !_rules[rulewsnl]() { - goto l182 - } - } - l183: - goto l181 - l182: - position, tokenIndex, depth = position182, tokenIndex182, depth182 - } - depth-- - add(rulemlBasicBody, position180) - } - if buffer[position] != rune('"') { - goto l178 - } - position++ - if buffer[position] != rune('"') { - goto l178 - } - position++ - if buffer[position] != rune('"') { - goto l178 - } - position++ - { - add(ruleAction18, position) - } - depth-- - add(rulemlBasicString, position179) - } - goto l156 - l178: - position, tokenIndex, depth = position156, tokenIndex156, depth156 - { - position190 := position - depth++ - { - position191 := position - depth++ - if buffer[position] != rune('"') { - goto l88 - } - position++ - l192: - { - position193, tokenIndex193, depth193 := position, tokenIndex, depth - if !_rules[rulebasicChar]() { - goto l193 - } - goto l192 - l193: - position, tokenIndex, depth = position193, tokenIndex193, depth193 - } - if buffer[position] != rune('"') { - goto l88 - } - position++ - depth-- - add(rulePegText, position191) - } - { - add(ruleAction17, position) - } - depth-- - add(rulebasicString, position190) - } - } - l156: - depth-- - add(rulestring, position155) - } - depth-- - add(rulePegText, position154) - } - { - add(ruleAction10, position) - } - break - default: - { - position196 := position - depth++ - if !_rules[ruleinteger]() { - goto l88 - } - depth-- - add(rulePegText, position196) - } - { - add(ruleAction9, position) - } - break - } - } - - } - l90: - depth-- - add(ruleval, position89) - } - return true - l88: - position, tokenIndex, depth = position88, tokenIndex88, depth88 - return false - }, - /* 11 table <- <(stdTable / arrayTable)> */ - nil, - /* 12 stdTable <- <('[' ws ws ']' Action13)> */ - nil, - /* 13 arrayTable <- <('[' '[' ws ws (']' ']') Action14)> */ - nil, - /* 14 inlineTable <- <('{' Action15 ws inlineTableKeyValues ws '}' Action16)> */ - nil, - /* 15 inlineTableKeyValues <- <(keyval inlineTableValSep?)*> */ - nil, - /* 16 tableKey <- <(key (tableKeySep key)*)> */ - func() bool { - position203, tokenIndex203, depth203 := position, tokenIndex, depth - { - position204 := position - depth++ - if !_rules[rulekey]() { - goto l203 - } - l205: - { - position206, tokenIndex206, depth206 := position, tokenIndex, depth - { - position207 := position - depth++ - if !_rules[rulews]() { - goto l206 - } - if buffer[position] != rune('.') { - goto l206 - } - position++ - if !_rules[rulews]() { - goto l206 - } - depth-- - add(ruletableKeySep, position207) - } - if !_rules[rulekey]() { - goto l206 - } - goto l205 - l206: - position, tokenIndex, depth = position206, tokenIndex206, depth206 - } - depth-- - add(ruletableKey, position204) - } - return true - l203: - position, tokenIndex, depth = position203, tokenIndex203, depth203 - return false - }, - /* 17 tableKeySep <- <(ws '.' ws)> */ - nil, - /* 18 inlineTableValSep <- <(ws ',' ws)> */ - nil, - /* 19 integer <- <(('-' / '+')? int)> */ - func() bool { - position210, tokenIndex210, depth210 := position, tokenIndex, depth - { - position211 := position - depth++ - { - position212, tokenIndex212, depth212 := position, tokenIndex, depth - { - position214, tokenIndex214, depth214 := position, tokenIndex, depth - if buffer[position] != rune('-') { - goto l215 - } - position++ - goto l214 - l215: - position, tokenIndex, depth = position214, tokenIndex214, depth214 - if buffer[position] != rune('+') { - goto l212 - } - position++ - } - l214: - goto l213 - l212: - position, tokenIndex, depth = position212, tokenIndex212, depth212 - } - l213: - { - position216 := position - depth++ - { - position217, tokenIndex217, depth217 := position, tokenIndex, depth - if c := buffer[position]; c < rune('1') || c > rune('9') { - goto l218 - } - position++ - { - position221, tokenIndex221, depth221 := position, tokenIndex, depth - if !_rules[ruledigit]() { - goto l222 - } - goto l221 - l222: - position, tokenIndex, depth = position221, tokenIndex221, depth221 - if buffer[position] != rune('_') { - goto l218 - } - position++ - if !_rules[ruledigit]() { - goto l218 - } - } - l221: - l219: - { - position220, tokenIndex220, depth220 := position, tokenIndex, depth - { - position223, tokenIndex223, depth223 := position, tokenIndex, depth - if !_rules[ruledigit]() { - goto l224 - } - goto l223 - l224: - position, tokenIndex, depth = position223, tokenIndex223, depth223 - if buffer[position] != rune('_') { - goto l220 - } - position++ - if !_rules[ruledigit]() { - goto l220 - } - } - l223: - goto l219 - l220: - position, tokenIndex, depth = position220, tokenIndex220, depth220 - } - goto l217 - l218: - position, tokenIndex, depth = position217, tokenIndex217, depth217 - if !_rules[ruledigit]() { - goto l210 - } - } - l217: - depth-- - add(ruleint, position216) - } - depth-- - add(ruleinteger, position211) - } - return true - l210: - position, tokenIndex, depth = position210, tokenIndex210, depth210 - return false - }, - /* 20 int <- <(([1-9] (digit / ('_' digit))+) / digit)> */ - nil, - /* 21 float <- <(integer ((frac exp?) / (frac? exp)))> */ - nil, - /* 22 frac <- <('.' digit (digit / ('_' digit))*)> */ - func() bool { - position227, tokenIndex227, depth227 := position, tokenIndex, depth - { - position228 := position - depth++ - if buffer[position] != rune('.') { - goto l227 - } - position++ - if !_rules[ruledigit]() { - goto l227 - } - l229: - { - position230, tokenIndex230, depth230 := position, tokenIndex, depth - { - position231, tokenIndex231, depth231 := position, tokenIndex, depth - if !_rules[ruledigit]() { - goto l232 - } - goto l231 - l232: - position, tokenIndex, depth = position231, tokenIndex231, depth231 - if buffer[position] != rune('_') { - goto l230 - } - position++ - if !_rules[ruledigit]() { - goto l230 - } - } - l231: - goto l229 - l230: - position, tokenIndex, depth = position230, tokenIndex230, depth230 - } - depth-- - add(rulefrac, position228) - } - return true - l227: - position, tokenIndex, depth = position227, tokenIndex227, depth227 - return false - }, - /* 23 exp <- <(('e' / 'E') ('-' / '+')? digit (digit / ('_' digit))*)> */ - func() bool { - position233, tokenIndex233, depth233 := position, tokenIndex, depth - { - position234 := position - depth++ - { - position235, tokenIndex235, depth235 := position, tokenIndex, depth - if buffer[position] != rune('e') { - goto l236 - } - position++ - goto l235 - l236: - position, tokenIndex, depth = position235, tokenIndex235, depth235 - if buffer[position] != rune('E') { - goto l233 - } - position++ - } - l235: - { - position237, tokenIndex237, depth237 := position, tokenIndex, depth - { - position239, tokenIndex239, depth239 := position, tokenIndex, depth - if buffer[position] != rune('-') { - goto l240 - } - position++ - goto l239 - l240: - position, tokenIndex, depth = position239, tokenIndex239, depth239 - if buffer[position] != rune('+') { - goto l237 - } - position++ - } - l239: - goto l238 - l237: - position, tokenIndex, depth = position237, tokenIndex237, depth237 - } - l238: - if !_rules[ruledigit]() { - goto l233 - } - l241: - { - position242, tokenIndex242, depth242 := position, tokenIndex, depth - { - position243, tokenIndex243, depth243 := position, tokenIndex, depth - if !_rules[ruledigit]() { - goto l244 - } - goto l243 - l244: - position, tokenIndex, depth = position243, tokenIndex243, depth243 - if buffer[position] != rune('_') { - goto l242 - } - position++ - if !_rules[ruledigit]() { - goto l242 - } - } - l243: - goto l241 - l242: - position, tokenIndex, depth = position242, tokenIndex242, depth242 - } - depth-- - add(ruleexp, position234) - } - return true - l233: - position, tokenIndex, depth = position233, tokenIndex233, depth233 - return false - }, - /* 24 string <- <(mlLiteralString / literalString / mlBasicString / basicString)> */ - nil, - /* 25 basicString <- <(<('"' basicChar* '"')> Action17)> */ - nil, - /* 26 basicChar <- <(basicUnescaped / escaped)> */ - func() bool { - position247, tokenIndex247, depth247 := position, tokenIndex, depth - { - position248 := position - depth++ - { - position249, tokenIndex249, depth249 := position, tokenIndex, depth - { - position251 := position - depth++ - { - switch buffer[position] { - case ' ', '!': - if c := buffer[position]; c < rune(' ') || c > rune('!') { - goto l250 - } - position++ - break - case '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[': - if c := buffer[position]; c < rune('#') || c > rune('[') { - goto l250 - } - position++ - break - default: - if c := buffer[position]; c < rune(']') || c > rune('\U0010ffff') { - goto l250 - } - position++ - break - } - } - - depth-- - add(rulebasicUnescaped, position251) - } - goto l249 - l250: - position, tokenIndex, depth = position249, tokenIndex249, depth249 - { - position253 := position - depth++ - if !_rules[ruleescape]() { - goto l247 - } - { - switch buffer[position] { - case 'U': - if buffer[position] != rune('U') { - goto l247 - } - position++ - if !_rules[rulehexQuad]() { - goto l247 - } - if !_rules[rulehexQuad]() { - goto l247 - } - break - case 'u': - if buffer[position] != rune('u') { - goto l247 - } - position++ - if !_rules[rulehexQuad]() { - goto l247 - } - break - case '\\': - if buffer[position] != rune('\\') { - goto l247 - } - position++ - break - case '/': - if buffer[position] != rune('/') { - goto l247 - } - position++ - break - case '"': - if buffer[position] != rune('"') { - goto l247 - } - position++ - break - case 'r': - if buffer[position] != rune('r') { - goto l247 - } - position++ - break - case 'f': - if buffer[position] != rune('f') { - goto l247 - } - position++ - break - case 'n': - if buffer[position] != rune('n') { - goto l247 - } - position++ - break - case 't': - if buffer[position] != rune('t') { - goto l247 - } - position++ - break - default: - if buffer[position] != rune('b') { - goto l247 - } - position++ - break - } - } - - depth-- - add(ruleescaped, position253) - } - } - l249: - depth-- - add(rulebasicChar, position248) - } - return true - l247: - position, tokenIndex, depth = position247, tokenIndex247, depth247 - return false - }, - /* 27 escaped <- <(escape ((&('U') ('U' hexQuad hexQuad)) | (&('u') ('u' hexQuad)) | (&('\\') '\\') | (&('/') '/') | (&('"') '"') | (&('r') 'r') | (&('f') 'f') | (&('n') 'n') | (&('t') 't') | (&('b') 'b')))> */ - nil, - /* 28 basicUnescaped <- <((&(' ' | '!') [ -!]) | (&('#' | '$' | '%' | '&' | '\'' | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '[') [#-[]) | (&(']' | '^' | '_' | '`' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | '{' | '|' | '}' | '~' | '\u007f' | '\u0080' | '\u0081' | '\u0082' | '\u0083' | '\u0084' | '\u0085' | '\u0086' | '\u0087' | '\u0088' | '\u0089' | '\u008a' | '\u008b' | '\u008c' | '\u008d' | '\u008e' | '\u008f' | '\u0090' | '\u0091' | '\u0092' | '\u0093' | '\u0094' | '\u0095' | '\u0096' | '\u0097' | '\u0098' | '\u0099' | '\u009a' | '\u009b' | '\u009c' | '\u009d' | '\u009e' | '\u009f' | '\u00a0' | '¡' | '¢' | '£' | '¤' | '¥' | '¦' | '§' | '¨' | '©' | 'ª' | '«' | '¬' | '\u00ad' | '®' | '¯' | '°' | '±' | '²' | '³' | '´' | 'µ' | '¶' | '·' | '¸' | '¹' | 'º' | '»' | '¼' | '½' | '¾' | '¿' | 'À' | 'Á' | 'Â' | 'Ã' | 'Ä' | 'Å' | 'Æ' | 'Ç' | 'È' | 'É' | 'Ê' | 'Ë' | 'Ì' | 'Í' | 'Î' | 'Ï' | 'Ð' | 'Ñ' | 'Ò' | 'Ó' | 'Ô' | 'Õ' | 'Ö' | '×' | 'Ø' | 'Ù' | 'Ú' | 'Û' | 'Ü' | 'Ý' | 'Þ' | 'ß' | 'à' | 'á' | 'â' | 'ã' | 'ä' | 'å' | 'æ' | 'ç' | 'è' | 'é' | 'ê' | 'ë' | 'ì' | 'í' | 'î' | 'ï' | 'ð' | 'ñ' | 'ò' | 'ó' | 'ô') []-􏿿]))> */ - nil, - /* 29 escape <- <'\\'> */ - func() bool { - position257, tokenIndex257, depth257 := position, tokenIndex, depth - { - position258 := position - depth++ - if buffer[position] != rune('\\') { - goto l257 - } - position++ - depth-- - add(ruleescape, position258) - } - return true - l257: - position, tokenIndex, depth = position257, tokenIndex257, depth257 - return false - }, - /* 30 mlBasicString <- <('"' '"' '"' mlBasicBody ('"' '"' '"') Action18)> */ - nil, - /* 31 mlBasicBody <- <((<(basicChar / newline)> Action19) / (escape newline wsnl))*> */ - nil, - /* 32 literalString <- <('\'' '\'' Action20)> */ - nil, - /* 33 literalChar <- <((&('\t') '\t') | (&(' ' | '!' | '"' | '#' | '$' | '%' | '&') [ -&]) | (&('(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '[' | '\\' | ']' | '^' | '_' | '`' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | '{' | '|' | '}' | '~' | '\u007f' | '\u0080' | '\u0081' | '\u0082' | '\u0083' | '\u0084' | '\u0085' | '\u0086' | '\u0087' | '\u0088' | '\u0089' | '\u008a' | '\u008b' | '\u008c' | '\u008d' | '\u008e' | '\u008f' | '\u0090' | '\u0091' | '\u0092' | '\u0093' | '\u0094' | '\u0095' | '\u0096' | '\u0097' | '\u0098' | '\u0099' | '\u009a' | '\u009b' | '\u009c' | '\u009d' | '\u009e' | '\u009f' | '\u00a0' | '¡' | '¢' | '£' | '¤' | '¥' | '¦' | '§' | '¨' | '©' | 'ª' | '«' | '¬' | '\u00ad' | '®' | '¯' | '°' | '±' | '²' | '³' | '´' | 'µ' | '¶' | '·' | '¸' | '¹' | 'º' | '»' | '¼' | '½' | '¾' | '¿' | 'À' | 'Á' | 'Â' | 'Ã' | 'Ä' | 'Å' | 'Æ' | 'Ç' | 'È' | 'É' | 'Ê' | 'Ë' | 'Ì' | 'Í' | 'Î' | 'Ï' | 'Ð' | 'Ñ' | 'Ò' | 'Ó' | 'Ô' | 'Õ' | 'Ö' | '×' | 'Ø' | 'Ù' | 'Ú' | 'Û' | 'Ü' | 'Ý' | 'Þ' | 'ß' | 'à' | 'á' | 'â' | 'ã' | 'ä' | 'å' | 'æ' | 'ç' | 'è' | 'é' | 'ê' | 'ë' | 'ì' | 'í' | 'î' | 'ï' | 'ð' | 'ñ' | 'ò' | 'ó' | 'ô') [(-􏿿]))> */ - nil, - /* 34 mlLiteralString <- <('\'' '\'' '\'' ('\'' '\'' '\'') Action21)> */ - nil, - /* 35 mlLiteralBody <- <(!('\'' '\'' '\'') (mlLiteralChar / newline))*> */ - nil, - /* 36 mlLiteralChar <- <('\t' / [ -􏿿])> */ - nil, - /* 37 hexdigit <- <((&('a' | 'b' | 'c' | 'd' | 'e' | 'f') [a-f]) | (&('A' | 'B' | 'C' | 'D' | 'E' | 'F') [A-F]) | (&('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') [0-9]))> */ - func() bool { - position266, tokenIndex266, depth266 := position, tokenIndex, depth - { - position267 := position - depth++ - { - switch buffer[position] { - case 'a', 'b', 'c', 'd', 'e', 'f': - if c := buffer[position]; c < rune('a') || c > rune('f') { - goto l266 - } - position++ - break - case 'A', 'B', 'C', 'D', 'E', 'F': - if c := buffer[position]; c < rune('A') || c > rune('F') { - goto l266 - } - position++ - break - default: - if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l266 - } - position++ - break - } - } - - depth-- - add(rulehexdigit, position267) - } - return true - l266: - position, tokenIndex, depth = position266, tokenIndex266, depth266 - return false - }, - /* 38 hexQuad <- <(hexdigit hexdigit hexdigit hexdigit)> */ - func() bool { - position269, tokenIndex269, depth269 := position, tokenIndex, depth - { - position270 := position - depth++ - if !_rules[rulehexdigit]() { - goto l269 - } - if !_rules[rulehexdigit]() { - goto l269 - } - if !_rules[rulehexdigit]() { - goto l269 - } - if !_rules[rulehexdigit]() { - goto l269 - } - depth-- - add(rulehexQuad, position270) - } - return true - l269: - position, tokenIndex, depth = position269, tokenIndex269, depth269 - return false - }, - /* 39 boolean <- <(('t' 'r' 'u' 'e') / ('f' 'a' 'l' 's' 'e'))> */ - nil, - /* 40 dateFullYear <- */ - nil, - /* 41 dateMonth <- */ - nil, - /* 42 dateMDay <- */ - nil, - /* 43 timeHour <- */ - func() bool { - position275, tokenIndex275, depth275 := position, tokenIndex, depth - { - position276 := position - depth++ - if !_rules[ruledigitDual]() { - goto l275 - } - depth-- - add(ruletimeHour, position276) - } - return true - l275: - position, tokenIndex, depth = position275, tokenIndex275, depth275 - return false - }, - /* 44 timeMinute <- */ - func() bool { - position277, tokenIndex277, depth277 := position, tokenIndex, depth - { - position278 := position - depth++ - if !_rules[ruledigitDual]() { - goto l277 - } - depth-- - add(ruletimeMinute, position278) - } - return true - l277: - position, tokenIndex, depth = position277, tokenIndex277, depth277 - return false - }, - /* 45 timeSecond <- */ - nil, - /* 46 timeSecfrac <- <('.' digit+)> */ - nil, - /* 47 timeNumoffset <- <(('-' / '+') timeHour ':' timeMinute)> */ - nil, - /* 48 timeOffset <- <('Z' / timeNumoffset)> */ - nil, - /* 49 partialTime <- <(timeHour ':' timeMinute ':' timeSecond timeSecfrac?)> */ - nil, - /* 50 fullDate <- <(dateFullYear '-' dateMonth '-' dateMDay)> */ - nil, - /* 51 fullTime <- <(partialTime timeOffset)> */ - nil, - /* 52 datetime <- <(fullDate 'T' fullTime)> */ - nil, - /* 53 digit <- <[0-9]> */ - func() bool { - position287, tokenIndex287, depth287 := position, tokenIndex, depth - { - position288 := position - depth++ - if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l287 - } - position++ - depth-- - add(ruledigit, position288) - } - return true - l287: - position, tokenIndex, depth = position287, tokenIndex287, depth287 - return false - }, - /* 54 digitDual <- <(digit digit)> */ - func() bool { - position289, tokenIndex289, depth289 := position, tokenIndex, depth - { - position290 := position - depth++ - if !_rules[ruledigit]() { - goto l289 - } - if !_rules[ruledigit]() { - goto l289 - } - depth-- - add(ruledigitDual, position290) - } - return true - l289: - position, tokenIndex, depth = position289, tokenIndex289, depth289 - return false - }, - /* 55 digitQuad <- <(digitDual digitDual)> */ - nil, - /* 56 array <- <('[' Action22 wsnl arrayValues wsnl ']')> */ - nil, - /* 57 arrayValues <- <(val Action23 arraySep? (comment? newline)?)*> */ - nil, - /* 58 arraySep <- <(ws ',' wsnl)> */ - nil, - /* 60 Action0 <- <{ _ = buffer }> */ - nil, - nil, - /* 62 Action1 <- <{ p.SetTableString(begin, end) }> */ - nil, - /* 63 Action2 <- <{ p.AddLineCount(end - begin) }> */ - nil, - /* 64 Action3 <- <{ p.AddLineCount(end - begin) }> */ - nil, - /* 65 Action4 <- <{ p.AddKeyValue() }> */ - nil, - /* 66 Action5 <- <{ p.SetKey(p.buffer, begin, end) }> */ - nil, - /* 67 Action6 <- <{ p.SetKey(p.buffer, begin, end) }> */ - nil, - /* 68 Action7 <- <{ p.SetTime(begin, end) }> */ - nil, - /* 69 Action8 <- <{ p.SetFloat64(begin, end) }> */ - nil, - /* 70 Action9 <- <{ p.SetInt64(begin, end) }> */ - nil, - /* 71 Action10 <- <{ p.SetString(begin, end) }> */ - nil, - /* 72 Action11 <- <{ p.SetBool(begin, end) }> */ - nil, - /* 73 Action12 <- <{ p.SetArray(begin, end) }> */ - nil, - /* 74 Action13 <- <{ p.SetTable(p.buffer, begin, end) }> */ - nil, - /* 75 Action14 <- <{ p.SetArrayTable(p.buffer, begin, end) }> */ - nil, - /* 76 Action15 <- <{ p.StartInlineTable() }> */ - nil, - /* 77 Action16 <- <{ p.EndInlineTable() }> */ - nil, - /* 78 Action17 <- <{ p.SetBasicString(p.buffer, begin, end) }> */ - nil, - /* 79 Action18 <- <{ p.SetMultilineString() }> */ - nil, - /* 80 Action19 <- <{ p.AddMultilineBasicBody(p.buffer, begin, end) }> */ - nil, - /* 81 Action20 <- <{ p.SetLiteralString(p.buffer, begin, end) }> */ - nil, - /* 82 Action21 <- <{ p.SetMultilineLiteralString(p.buffer, begin, end) }> */ - nil, - /* 83 Action22 <- <{ p.StartArray() }> */ - nil, - /* 84 Action23 <- <{ p.AddArrayVal() }> */ - nil, - } - p.rules = _rules -} diff --git a/Godeps/_workspace/src/github.com/naoina/toml/util.go b/Godeps/_workspace/src/github.com/naoina/toml/util.go deleted file mode 100644 index dc6a548d7..000000000 --- a/Godeps/_workspace/src/github.com/naoina/toml/util.go +++ /dev/null @@ -1,79 +0,0 @@ -package toml - -import ( - "go/ast" - "reflect" - "strings" - "unicode" -) - -// toCamelCase returns a copy of the string s with all Unicode letters mapped to their camel case. -// It will convert to upper case previous letter of '_' and first letter, and remove letter of '_'. -func toCamelCase(s string) string { - if s == "" { - return "" - } - result := make([]rune, 0, len(s)) - upper := false - for _, r := range s { - if r == '_' { - upper = true - continue - } - if upper { - result = append(result, unicode.ToUpper(r)) - upper = false - continue - } - result = append(result, r) - } - result[0] = unicode.ToUpper(result[0]) - return string(result) -} - -const ( - fieldTagName = "toml" -) - -func findField(rv reflect.Value, name string) (field reflect.Value, fieldName string, found bool) { - switch rv.Kind() { - case reflect.Struct: - rt := rv.Type() - for i := 0; i < rt.NumField(); i++ { - ft := rt.Field(i) - if !ast.IsExported(ft.Name) { - continue - } - if col, _ := extractTag(ft.Tag.Get(fieldTagName)); col == name { - return rv.Field(i), ft.Name, true - } - } - for _, name := range []string{ - strings.Title(name), - toCamelCase(name), - strings.ToUpper(name), - } { - if field := rv.FieldByName(name); field.IsValid() { - return field, name, true - } - } - case reflect.Map: - return reflect.New(rv.Type().Elem()).Elem(), name, true - } - return field, "", false -} - -func extractTag(tag string) (col, rest string) { - tags := strings.SplitN(tag, ",", 2) - if len(tags) == 2 { - return strings.TrimSpace(tags[0]), strings.TrimSpace(tags[1]) - } - return strings.TrimSpace(tags[0]), "" -} - -func tableName(prefix, name string) string { - if prefix != "" { - return prefix + string(tableSeparator) + name - } - return name -} diff --git a/cmd/drone-server/drone.go b/cmd/drone-server/drone.go index 2c2a98a35..b181450c7 100644 --- a/cmd/drone-server/drone.go +++ b/cmd/drone-server/drone.go @@ -5,7 +5,7 @@ import ( "html/template" "net/http" - "github.com/namsral/flag" + "github.com/drone/drone/Godeps/_workspace/src/github.com/namsral/flag" "github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin" diff --git a/pkg/runner/builtin/runner.go b/pkg/runner/builtin/runner.go index 428181a5e..13d477447 100644 --- a/pkg/runner/builtin/runner.go +++ b/pkg/runner/builtin/runner.go @@ -27,8 +27,8 @@ var ( DockerHost = os.Getenv("DOCKER_HOST") // Docker TLS variables - DockerHostCa = os.Getenv("DOCKER_CA") - DockerHostKey = os.Getenv("DOCKER_KEY") + DockerHostCa = os.Getenv("DOCKER_CA") + DockerHostKey = os.Getenv("DOCKER_KEY") DockerHostCert = os.Getenv("DOCKER_CERT") ) @@ -111,8 +111,8 @@ func (r *Runner) Run(w *queue.Work) error { caCertPool := x509.NewCertPool() caCertPool.AppendCertsFromPEM(caCert) tlc = &tls.Config{ - Certificates: []tls.Certificate{cert}, - RootCAs: caCertPool, + Certificates: []tls.Certificate{cert}, + RootCAs: caCertPool, } }