mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Initial commit
This commit is contained in:
29
vendor/github.com/gobuffalo/mapi/.gitignore
generated
vendored
Normal file
29
vendor/github.com/gobuffalo/mapi/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
*.log
|
||||
.DS_Store
|
||||
doc
|
||||
tmp
|
||||
pkg
|
||||
*.gem
|
||||
*.pid
|
||||
coverage
|
||||
coverage.data
|
||||
build/*
|
||||
*.pbxuser
|
||||
*.mode1v3
|
||||
.svn
|
||||
profile
|
||||
.console_history
|
||||
.sass-cache/*
|
||||
.rake_tasks~
|
||||
*.log.lck
|
||||
solr/
|
||||
.jhw-cache/
|
||||
jhw.*
|
||||
*.sublime*
|
||||
node_modules/
|
||||
dist/
|
||||
generated/
|
||||
.vendor/
|
||||
bin/*
|
||||
gin-bin
|
||||
.idea/
|
||||
3
vendor/github.com/gobuffalo/mapi/.gometalinter.json
generated
vendored
Normal file
3
vendor/github.com/gobuffalo/mapi/.gometalinter.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Enable": ["vet", "golint", "goimports", "deadcode", "gotype", "ineffassign", "misspell", "nakedret", "unconvert", "megacheck", "varcheck"]
|
||||
}
|
||||
21
vendor/github.com/gobuffalo/mapi/LICENSE
generated
vendored
Normal file
21
vendor/github.com/gobuffalo/mapi/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 Mark Bates
|
||||
|
||||
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.
|
||||
40
vendor/github.com/gobuffalo/mapi/Makefile
generated
vendored
Normal file
40
vendor/github.com/gobuffalo/mapi/Makefile
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
TAGS ?= "sqlite"
|
||||
GO_BIN ?= go
|
||||
|
||||
install:
|
||||
packr
|
||||
$(GO_BIN) install -v .
|
||||
|
||||
deps:
|
||||
$(GO_BIN) get github.com/gobuffalo/release
|
||||
$(GO_BIN) get github.com/gobuffalo/packr/packr
|
||||
$(GO_BIN) get -tags ${TAGS} -t ./...
|
||||
$(GO_BIN) mod tidy
|
||||
|
||||
build:
|
||||
packr
|
||||
$(GO_BIN) build -v .
|
||||
|
||||
test:
|
||||
packr
|
||||
$(GO_BIN) test -tags ${TAGS} ./...
|
||||
|
||||
ci-test: deps
|
||||
$(GO_BIN) test -tags ${TAGS} -race ./...
|
||||
|
||||
lint:
|
||||
gometalinter --vendor ./... --deadline=1m --skip=internal
|
||||
|
||||
update:
|
||||
$(GO_BIN) get -u -tags ${TAGS}
|
||||
$(GO_BIN) mod tidy
|
||||
packr
|
||||
make test
|
||||
make install
|
||||
$(GO_BIN) mod tidy
|
||||
|
||||
release-test:
|
||||
$(GO_BIN) test -tags ${TAGS} -race ./...
|
||||
|
||||
release:
|
||||
release -y -f version.go
|
||||
8
vendor/github.com/gobuffalo/mapi/go.mod
generated
vendored
Normal file
8
vendor/github.com/gobuffalo/mapi/go.mod
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
module github.com/gobuffalo/mapi
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pkg/errors v0.8.0
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/testify v1.2.2
|
||||
)
|
||||
8
vendor/github.com/gobuffalo/mapi/go.sum
generated
vendored
Normal file
8
vendor/github.com/gobuffalo/mapi/go.sum
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
109
vendor/github.com/gobuffalo/mapi/mapi.go
generated
vendored
Normal file
109
vendor/github.com/gobuffalo/mapi/mapi.go
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
package mapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var ErrNotFound = errors.New("not found")
|
||||
|
||||
type Mapi map[string]interface{}
|
||||
|
||||
func (mi Mapi) String() string {
|
||||
b, _ := mi.MarshalJSON()
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func (mi Mapi) Interface() interface{} {
|
||||
return mi
|
||||
}
|
||||
|
||||
func (mi Mapi) Pluck(s string) (interface{}, error) {
|
||||
keys := strings.Split(s, ":")
|
||||
return reduce(keys, mi)
|
||||
}
|
||||
|
||||
func (mi *Mapi) UnmarshalJSON(b []byte) error {
|
||||
mm := map[string]interface{}{}
|
||||
if err := json.Unmarshal(b, &mm); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
unmarshal(mm)
|
||||
(*mi) = Mapi(mm)
|
||||
return nil
|
||||
}
|
||||
|
||||
func unmarshal(m map[string]interface{}) {
|
||||
for k, v := range m {
|
||||
if mv, ok := v.(map[string]interface{}); ok {
|
||||
unmarshal(mv)
|
||||
m[k] = Mapi(mv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (mi Mapi) MarshalJSON() ([]byte, error) {
|
||||
m := map[string]interface{}{}
|
||||
|
||||
for k, v := range mi {
|
||||
rv := reflect.Indirect(reflect.ValueOf(v))
|
||||
switch rv.Kind() {
|
||||
case reflect.Map:
|
||||
mm := Mapi{}
|
||||
for _, xk := range rv.MapKeys() {
|
||||
mm[xk.String()] = rv.MapIndex(xk).Interface()
|
||||
}
|
||||
m[k] = mm
|
||||
default:
|
||||
if _, ok := v.(Mapi); ok {
|
||||
continue
|
||||
}
|
||||
if _, err := json.Marshal(v); err == nil {
|
||||
// if it can be marshaled, add it to the map
|
||||
m[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
return json.Marshal(m)
|
||||
}
|
||||
|
||||
func reduce(keys []string, in interface{}) (interface{}, error) {
|
||||
if len(keys) == 0 {
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
|
||||
rv := reflect.Indirect(reflect.ValueOf(in))
|
||||
if !rv.IsValid() {
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
if rv.Kind() != reflect.Map {
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
|
||||
var key reflect.Value
|
||||
for _, k := range rv.MapKeys() {
|
||||
if k.String() == keys[0] {
|
||||
key = k
|
||||
break
|
||||
}
|
||||
}
|
||||
if !key.IsValid() {
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
|
||||
keys = keys[1:]
|
||||
iv := rv.MapIndex(key)
|
||||
|
||||
if !iv.IsValid() {
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
|
||||
if len(keys) == 0 {
|
||||
return iv.Interface(), nil
|
||||
}
|
||||
|
||||
return reduce(keys, iv.Interface())
|
||||
}
|
||||
10
vendor/github.com/gobuffalo/mapi/shoulders.md
generated
vendored
Normal file
10
vendor/github.com/gobuffalo/mapi/shoulders.md
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# github.com/gobuffalo/mapi Stands on the Shoulders of Giants
|
||||
|
||||
github.com/gobuffalo/mapi does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants this project would not be possible. Please make sure to check them out and thank them for all of their hard work.
|
||||
|
||||
Thank you to the following **GIANTS**:
|
||||
|
||||
|
||||
* [github.com/gobuffalo/mapi](https://godoc.org/github.com/gobuffalo/mapi)
|
||||
|
||||
* [github.com/pkg/errors](https://godoc.org/github.com/pkg/errors)
|
||||
3
vendor/github.com/gobuffalo/mapi/version.go
generated
vendored
Normal file
3
vendor/github.com/gobuffalo/mapi/version.go
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
package mapi
|
||||
|
||||
const Version = "v1.0.1"
|
||||
Reference in New Issue
Block a user