Skip to content

Commit

Permalink
refactor to better file structure (close #100)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimus committed Mar 9, 2023
1 parent 4bb6e34 commit 08ccbfa
Show file tree
Hide file tree
Showing 53 changed files with 188 additions and 174 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
gnverifier/gnverifier
gnverifier
debug.test
coverage.txt
t
t.json
.env
Expand Down
23 changes: 20 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# Changelog

## [v1.0.2] - 2023-03-09 Thu

- Add [#100]: refactor to a better file organization.

## [v1.0.1] - 2022-09-30 Fri

- Add: update all modules
- Add: update all modules.

## [v1.0.0] - 2022-08-24 Wed

- Add: prepare for v1.0.0
- Add: prepare for v1.0.0.

## [v1.0.0-RC1] - 2022-05-10 Tue

- Add: update gnmatcher, gnames to v1.0.0-RC1
- Add: update gnmatcher, gnames to v1.0.0-RC1.

## [v0.9.5] - 2022-05-02 Mon

Expand Down Expand Up @@ -193,6 +197,9 @@ This document follows [changelog guidelines]

<!-- VERSIONS -->

[v1.0.2]: https://github.com/gnames/gnverifier/compare/v1.0.1...v1.0.2
[v1.0.1]: https://github.com/gnames/gnverifier/compare/v1.0.0...v1.0.1
[v1.0.0]: https://github.com/gnames/gnverifier/compare/v1.0.0-RC1...v1.0.0
[v1.0.0-rc1]: https://github.com/gnames/gnverifier/compare/v0.9.5...v1.0.0-RC1
[v0.9.5]: https://github.com/gnames/gnverifier/compare/v0.9.4...v0.9.5
[v0.9.4]: https://github.com/gnames/gnverifier/compare/v0.9.3...v0.9.4
Expand Down Expand Up @@ -233,6 +240,16 @@ This document follows [changelog guidelines]

<!-- Issues -->

[#110]: https://github.com/gnames/gnverifier/issues/110
[#109]: https://github.com/gnames/gnverifier/issues/109
[#108]: https://github.com/gnames/gnverifier/issues/108
[#107]: https://github.com/gnames/gnverifier/issues/107
[#106]: https://github.com/gnames/gnverifier/issues/106
[#105]: https://github.com/gnames/gnverifier/issues/105
[#104]: https://github.com/gnames/gnverifier/issues/104
[#103]: https://github.com/gnames/gnverifier/issues/103
[#102]: https://github.com/gnames/gnverifier/issues/102
[#101]: https://github.com/gnames/gnverifier/issues/101
[#100]: https://github.com/gnames/gnverifier/issues/100
[#99]: https://github.com/gnames/gnverifier/issues/99
[#98]: https://github.com/gnames/gnverifier/issues/98
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
FROM alpine:3.14
FROM alpine:3.17

LABEL maintainer="Dmitry Mozzherin"

ENV LAST_FULL_REBUILD 2021-04-09

WORKDIR /bin

COPY ./gnverifier/gnverifier /bin
COPY ./gnverifier /bin

ENTRYPOINT [ "gnverifier" ]

Expand Down
12 changes: 6 additions & 6 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License
The MIT License (MIT)

Copyright (c) 2020-2022 gnames
Copyright © 2020-2022 Dmitry Mozzherin <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -9,13 +9,13 @@ 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 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.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
64 changes: 40 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
PROJ_NAME = gnverifier

VERSION = $(shell git describe --tags)
VER = $(shell git describe --tags --abbrev=0)
DATE = $(shell date -u '+%Y-%m-%d_%H:%M:%S%Z')
FLAG_MODULE = GO111MODULE=on
FLAGS_SHARED = $(FLAG_MODULE) CGO_ENABLED=0 GOARCH=amd64

NO_C = CGO_ENABLED=0
FLAGS_SHARED = $(NO_C) GOARCH=amd64
FLAGS_LD=-ldflags "-w -s \
-X github.com/gnames/gnverifier.Build=${DATE} \
-X github.com/gnames/gnverifier.Version=${VERSION}"
-X github.com/gnames/$(PROJ_NAME)/pkg.Build=$(DATE) \
-X github.com/gnames/$(PROJ_NAME)/pkg.Version=$(VERSION)"
FLAGS_REL = -trimpath -ldflags "-s -w \
-X github.com/gnames/$(PROJ_NAME)/pkg.Build=$(DATE)"

GOCMD=go
GOINSTALL=$(GOCMD) install $(FLAGS_LD)
GOBUILD=$(GOCMD) build $(FLAGS_LD)
GORELEASE = $(GOCMD) build $(FLAGS_REL)
GOCLEAN=$(GOCMD) clean
GOGENERATE=$(GOCMD) generate
GOGET = $(GOCMD) get
Expand All @@ -17,48 +24,57 @@ all: install

test: deps install
@echo Run tests
$(FLAG_MODULE) go test -race ./...
$(GOCMD) test -shuffle=on -count=1 -race -coverprofile=coverage.txt ./...

tools: deps
@echo Installing tools from tools.go
@cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %

deps:
@echo Download go.mod dependencies
$(GOCMD) mod download; \
$(GOGENERATE)

tools: deps
@echo Installing tools from tools.go
@cat gnverifier/tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %

build:
@echo Building
$(GOGENERATE)
cd gnverifier; \
$(GOCLEAN); \
$(FLAGS_SHARED) $(GOBUILD);
$(NO_C) $(GOBUILD);

buildrel:
@echo Building release binary
$(GOGENERATE)
$(GOCLEAN); \
$(NO_C) $(GORELEASE);

install:
@echo Build and install locally
$(GOGENERATE)
$(NO_C) $(GOINSTALL);

release: dockerhub
@echo Building releases for Linux, Mac, Windows
cd gnverifier; \
$(GOCLEAN); \
$(FLAGS_SHARED) GOOS=linux $(GOBUILD); \
tar zcvf /tmp/gnverifier-${VER}-linux.tar.gz gnverifier; \
tar zcvf /tmp/$(PROJ_NAME)-${VER}-linux.tar.gz $(PROJ_NAME); \
$(GOCLEAN); \
$(FLAGS_SHARED) GOOS=darwin $(GOBUILD); \
tar zcvf /tmp/gnverifier-${VER}-mac.tar.gz gnverifier; \
tar zcvf /tmp/$(PROJ_NAME)-${VER}-mac.tar.gz $(PROJ_NAME); \
$(GOCLEAN); \
$(NO_C) GOOS=darwin GOARCH=arm64 $(GOBUILD); \
tar zcvf /tmp/$(PROJ_NAME)-${VER}-mac-arm64.tar.gz $(PROJ_NAME); \
$(GOCLEAN); \
$(FLAGS_SHARED) GOOS=windows $(GOBUILD); \
zip -9 /tmp/gnverifier-${VER}-win-64.zip gnverifier.exe; \
zip -9 /tmp/$(PROJ_NAME)-${VER}-win-64.zip $(PROJ_NAME).exe; \
$(GOCLEAN);

install:
$(GOGENERATE)
cd gnverifier; \
$(FLAGS_SHARED) $(GOINSTALL);

docker: build
docker build -t gnames/gnverifier:latest -t gnames/gnverifier:$(VERSION) .; \
cd gnverifier; \
@echo Build Docker images
docker buildx build -t gnames/$(PROJ_NAME):latest -t gnames/$(PROJ_NAME):$(VERSION) .; \
$(GOCLEAN);

dockerhub: docker
docker push gnames/gnverifier; \
docker push gnames/gnverifier:$(VERSION)
@echo Push Docker images to DockerHub
docker push gnames/$(PROJ_NAME); \
docker push gnames/$(PROJ_NAME):$(VERSION)

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ If you want to cite GNverifier, use [DOI generated by Zenodo][zenodo doi]:
manual curation have priority over auto-curated and uncurated datasets. For
example [Catalogue of Life] or [WoRMS] are considered curated,
[GBIF] auto-curated, [uBio] not curated.
- Fine-tunng the match score by matching authors, years, ranks etc.
- Fine-tuning the match score by matching authors, years, ranks etc.
- It is possible to map any name-strings checklist to any of registered
Data Sources.
- If a Data Source provides a classification for a name, it will be returned in
- If a Data Source provides a classification for a name, it will be returned to
the output.
- The app works for checking just one name-string, or multiple ones written in
a file.
Expand Down Expand Up @@ -151,7 +151,7 @@ go get github.com/gnames/gnverifier/gnverifier

[GNverifier] takes one name-string or a text file with one name-string per
line as an argument, sends a query with these data to a [remote GNames
server][gnames] to match the name-strigs against many different biodiversity
server][gnames] to match the name-strings against many biodiversity
databases and returns results to STDOUT either in JSON, CSV or TSV format.

The app can alto take a query string like
Expand Down Expand Up @@ -293,7 +293,7 @@ gnverifier -f tsv file.csv

Note that a separate JSON "document" is returned for each separate record,
instead of returning one big JSON document for all records. For large lists it
significantly speeds up parsin of the JSON on the user side.
significantly speeds up parsing of the JSON on the user side.

#### jobs

Expand Down Expand Up @@ -372,7 +372,7 @@ gnverifier -p 8777 --web-logs
### nsqd-tcp
Requires `--port`. Allows to redirect web-service log output to [NSQ]
Requires `--port`. Allows redirecting web-service log output to [NSQ]
messaging server's TCP-based endpoint. It is handy for aggregations of logs
from [GNverifier] web-services running inside of Docker containers or in
Kubernetes pods.
Expand Down Expand Up @@ -444,7 +444,7 @@ It includes following operators:
option, if given, will overwrite this setting (`ds:1,2,172`).
`tx:`
: Parent taxon. Limits results to names that contain a particular higher taxon
: Parent taxon. Limit results to names that contain a particular higher taxon
in their classification. If `ds:` is given, uses the classification of the
first data-source in the setting. If `ds:` is not given, uses managerial
classification of the Catalogue of Life (`tx:Hemiptera`, `tx:Animalia`,
Expand All @@ -463,7 +463,7 @@ to enter several settings at once loosely following rules of nomenclature
is possible to have abbreviated specific epithets or range in
years: `n:Mono. gall. Oliv. 1750-1800`.
Often there are errors in species eptithets gender. Because of that search
Often there are errors in species epithets gender. Because of that search
will try to detect names in any gender that correspond to the epithet.
The search requires to have either `sp:`, `isp:` or `asp:` setting,
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions gnverifier/cmd/root.go → cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (
"github.com/gnames/gnquery"
"github.com/gnames/gnquery/ent/search"
"github.com/gnames/gnsys"
"github.com/gnames/gnverifier"
"github.com/gnames/gnverifier/config"
"github.com/gnames/gnverifier/ent/output"
"github.com/gnames/gnverifier/io/verifrest"
"github.com/gnames/gnverifier/io/web"
"github.com/gnames/gnverifier/internal/ent/output"
"github.com/gnames/gnverifier/internal/io/verifrest"
"github.com/gnames/gnverifier/internal/io/web"
gnverifier "github.com/gnames/gnverifier/pkg"
"github.com/gnames/gnverifier/pkg/config"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
Expand Down
21 changes: 0 additions & 21 deletions gnverifier/LICENSE

This file was deleted.

54 changes: 26 additions & 28 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,64 +1,62 @@
module github.com/gnames/gnverifier

go 1.19
go 1.20

require (
github.com/dnaeon/go-vcr v1.2.0
github.com/dustin/go-humanize v1.0.0
github.com/gnames/gnfmt v0.3.0
github.com/dustin/go-humanize v1.0.1
github.com/gnames/gnfmt v0.4.1
github.com/gnames/gnlib v0.14.0
github.com/gnames/gnquery v0.3.3
github.com/gnames/gnsys v0.2.2
github.com/gnames/gnuuid v0.1.1
github.com/labstack/echo/v4 v4.9.0
github.com/labstack/gommon v0.3.1
github.com/maxbrunsfeld/counterfeiter/v6 v6.5.0
github.com/rs/zerolog v1.28.0
github.com/labstack/echo/v4 v4.10.2
github.com/labstack/gommon v0.4.0
github.com/maxbrunsfeld/counterfeiter/v6 v6.6.1
github.com/rs/zerolog v1.29.0
github.com/sfgrp/lognsq v0.1.1
github.com/spf13/cobra v1.5.0
github.com/spf13/viper v1.13.0
github.com/stretchr/testify v1.8.0
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.2
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gnames/gnstats v0.1.0 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nsqio/go-nsq v1.1.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pointlander/compress v1.1.1-0.20190518213731-ff44bd196cc3 // indirect
github.com/pointlander/jetset v1.0.1-0.20190518214125-eee7eff80bd4 // indirect
github.com/pointlander/peg v1.0.1 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.1 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
golang.org/x/tools v0.1.10 // indirect
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.5.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 08ccbfa

Please sign in to comment.