diff --git a/CITATION.cff b/CITATION.cff
index 5bc0442..3b39bfb 100644
--- a/CITATION.cff
+++ b/CITATION.cff
@@ -15,6 +15,6 @@ maintainers:
orcid: "https://orcid.org/0000-0003-0900-6903"
repository-code: "https://github.com/caltechlibrary/datatools"
-version: 1.2.11
+version: 1.2.12
license-url: "https://data.caltech.edu/license"
keywords: [ "csv", "excel", "sql", "json", "yaml", "xlsx", "golang", "bash" ]
diff --git a/Makefile b/Makefile
index b38320b..e2a6634 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,6 @@ RELEASE_DATE=$(shell date +'%Y-%m-%d')
RELEASE_HASH=$(shell git log --pretty=format:'%h' -n 1)
-
PROGRAMS = codemeta2cff csv2json csv2mdtable csv2tab csv2xlsx csvcleaner csvcols csvfind csvjoin csvrows finddir findfile json2toml json2yaml jsoncols jsonjoin jsonmunge jsonrange mergepath range reldate reltime sql2csv string tab2csv timefmt toml2json urlparse xlsx2csv xlsx2json yaml2json jsonobjects2csv
MAN_PAGES = codemeta2cff.1 csv2json.1 csv2mdtable.1 csv2tab.1 csv2xlsx.1 csvcleaner.1 csvcols.1 csvfind.1 csvjoin.1 csvrows.1 finddir.1 findfile.1 json2toml.1 json2yaml.1 jsoncols.1 jsonjoin.1 jsonmunge.1 jsonrange.1 mergepath.1 range.1 reldate.1 reltime.1 sql2csv.1 string.1 tab2csv.1 timefmt.1 toml2json.1 urlparse.1 xlsx2csv.1 xlsx2json.1 yaml2json.1 jsonobjects2csv.1
@@ -48,9 +47,6 @@ version.go: .FORCE
--template codemeta-version-go.tmpl \
LICENSE >version.go
-
-
-
about.md: codemeta.json .FORCE
cat codemeta.json | sed -E 's/"@context"/"at__context"/g;s/"@type"/"at__type"/g;s/"@id"/"at__id"/g' >_codemeta.json
if [ -f $(PANDOC) ]; then echo "" | $(PANDOC) --metadata title="About $(PROJECT)" --metadata-file=_codemeta.json --template=codemeta-md.tmpl >about.md; fi
@@ -218,7 +214,7 @@ gen_batfiles: .FORCE
snap: dist/datatools_$(VERSION)_amd64.snap
-release: .FORCE installer.sh clean build man gen_batfiles distribute_docs dist/Linux-x86_64 dist/macOS-x86_64 dist/macOS-arm64 dist/Windows-x86_64 dist/Windows-arm64 dist/Linux-armv7l dist/Linux-aarch64
+release: .FORCE clean build man gen_batfiles distribute_docs dist/Linux-armv7l dist/Linux-aarch64 dist/Linux-x86_64 dist/macOS-x86_64 dist/macOS-arm64 dist/Windows-x86_64 dist/Windows-arm64
.FORCE:
diff --git a/about.html b/about.html
index 19c9ffd..a8df042 100644
--- a/about.html
+++ b/about.html
@@ -25,7 +25,7 @@
About this software
-
+
Authors
- R. S. Doiel
diff --git a/about.md b/about.md
index 0da814b..f32ab70 100644
--- a/about.md
+++ b/about.md
@@ -11,7 +11,7 @@ authors:
orcid: "https://orcid.org/0000-0003-0900-6903"
repository-code: "https://github.com/caltechlibrary/datatools"
-version: 1.2.11
+version: 1.2.12
license-url: "https://data.caltech.edu/license"
keywords: [ "csv", "excel", "sql", "json", "yaml", "xlsx", "golang", "bash" ]
@@ -20,7 +20,7 @@ keywords: [ "csv", "excel", "sql", "json", "yaml", "xlsx", "golang", "bash" ]
About this software
===================
-## datatools 1.2.11
+## datatools 1.2.12
### Authors
diff --git a/codemeta.json b/codemeta.json
index 9cef015..26b23c5 100644
--- a/codemeta.json
+++ b/codemeta.json
@@ -4,14 +4,14 @@
"license": "https://data.caltech.edu/license",
"codeRepository": "https://github.com/caltechlibrary/datatools",
"dateCreated": "2017-02-06",
- "dateRelease": "2024-10-24",
- "dateModified": "2024-10-24",
+ "dateRelease": "2024-11-07",
+ "dateModified": "2024-11-07",
"downloadUrl": "https://github.com/caltechlibrary/datatools/releases/",
"issueTracker": "https://github.com/caltechlibrary/datatools/issues",
"name": "datatools",
- "version": "1.2.11",
+ "version": "1.2.12",
"description": "A set of command line tools for working with CSV, Excel Workbooks, JSON and structured text documents.",
- "releaseNotes": "fix isssue#21, CopyrightYear is an int",
+ "releaseNotes": "fix issue #22, identifying DOI without http prefix",
"applicationCategory": "computer programming",
"developmentStatus": "active",
"funder": {
diff --git a/codemeta/codemeta.go b/codemeta/codemeta.go
index 23ed701..2b1974f 100644
--- a/codemeta/codemeta.go
+++ b/codemeta/codemeta.go
@@ -7,6 +7,9 @@ import (
// Caltech Library package
"github.com/caltechlibrary/doitools"
+
+ // 3rd Party Package
+ "github.com/hscells/doi"
)
type PersonOrOrganization struct {
@@ -53,6 +56,7 @@ type Codemeta struct {
// Additional codemeta Terms are defined at https://codemeta.github.io/terms/
}
+
func (person *PersonOrOrganization) ToJSON() ([]byte, error) {
return JSONMarshalIndent(person, "", "\t")
}
@@ -71,6 +75,15 @@ func (person *PersonOrOrganization) ToCFF() ([]byte, error) {
orcid: %s`, person.FamilyName, person.GivenName, person.Id)), nil
}
+// Check if identifier is a DOI
+func isDOI(identifier string) bool {
+ doi, err := doi.Parse(identifier)
+ if err != nil {
+ return false
+ }
+ return doi.IsValid()
+}
+
// ToCff crosswalks a Codemeta data structure rendering
// CITATION.cff document as an array of byte.
// Based on documentation at https://citation-file-format.github.io/
@@ -96,7 +109,7 @@ repository-code: %q`, cm.CodeRepository))...)
src = append(src, []byte(`
type: software`)...)
}
- if strings.HasPrefix(cm.Identifier, "https://doi.org/") {
+ if isDOI(cm.Identifier) {
if doi, err := doitools.NormalizeDOI(cm.Identifier); err == nil {
src = append(src, []byte(fmt.Sprintf(`
doi: %s`, doi))...)
diff --git a/codemeta/codemeta_test.go b/codemeta/codemeta_test.go
index 1fc13b7..570924d 100644
--- a/codemeta/codemeta_test.go
+++ b/codemeta/codemeta_test.go
@@ -4,6 +4,23 @@ import (
"testing"
)
+func TestIsDOI(t *testing.T) {
+ identifier := "10.22002/5rbqw-9cc91"
+ expected := true
+ got := isDOI(identifier)
+ if expected != got {
+ t.Errorf("for %q, expected %t, got %t", identifier, expected, got)
+ }
+ identifier = "0000-1111-2222-3333"
+ expected = false
+ got = isDOI(identifier)
+ if expected != got {
+ t.Errorf("for %q, expected %t, got %t", identifier, expected, got)
+ }
+
+
+}
+
func TestCodemeta(t *testing.T) {
t.Errorf("TestCodemeta() not implemented.")
}
diff --git a/codemeta2cff.1.md b/codemeta2cff.1.md
index 57e2207..15ac269 100644
--- a/codemeta2cff.1.md
+++ b/codemeta2cff.1.md
@@ -1,6 +1,6 @@
-%codemeta2cff(1) user manual | version 1.2.11 ff4493f
+%codemeta2cff(1) user manual | version 1.2.12 1128bff
% R. S. Doiel
-% 2024-10-24
+% 2024-11-07
# NAME
diff --git a/csv2json.1.md b/csv2json.1.md
index c7c66bb..afb0715 100644
--- a/csv2json.1.md
+++ b/csv2json.1.md
@@ -1,6 +1,6 @@
-%csv2json(1) user manual | version 1.2.11 ff4493f
+%csv2json(1) user manual | version 1.2.12 1128bff
% R. S. Doiel
-% 2024-10-24
+% 2024-11-07
# NAME
diff --git a/csv2mdtable.1.html b/csv2mdtable.1.html
index 4b76f06..7d230ee 100644
--- a/csv2mdtable.1.html
+++ b/csv2mdtable.1.html
@@ -79,7 +79,7 @@ EXAMPLES
cat data1.csv | csv2mdtable > data1.md
Convert data1.csv to data1.md using options.
csv2mdtable -i data1.csv -o data1.md
-csv2mdtable 1.2.11
+csv2mdtable 1.2.12
You can also search for phrases in columns.
csvfind -i books.csv -col=2 -contains "Red Book"
-csvfind 1.2.11
+csvfind 1.2.12
diff --git a/csvfind.1.md b/csvfind.1.md
index c8e91f6..0a3962d 100644
--- a/csvfind.1.md
+++ b/csvfind.1.md
@@ -1,6 +1,6 @@
-%csvfind(1) user manual | version 1.2.11 ff4493f
+%csvfind(1) user manual | version 1.2.12 1128bff
% R. S. Doiel
-% 2024-10-24
+% 2024-11-07
# NAME
@@ -117,5 +117,5 @@ You can also search for phrases in columns.
csvfind -i books.csv -col=2 -contains "Red Book"
~~~
-csvfind 1.2.11
+csvfind 1.2.12
diff --git a/csvjoin.1.html b/csvjoin.1.html
index 21683aa..6aa5d79 100644
--- a/csvjoin.1.html
+++ b/csvjoin.1.html
@@ -139,7 +139,7 @@ EXAMPLES
csvjoin -csv1=data1.csv -col1=2 \
-csv2=data2.csv -col2=4 \
-output=merged-data.csv
-csvjoin 1.2.11
+csvjoin 1.2.12
diff --git a/csvjoin.1.md b/csvjoin.1.md
index e4b3e92..63c2b51 100644
--- a/csvjoin.1.md
+++ b/csvjoin.1.md
@@ -1,6 +1,6 @@
-%csvjoin(1) user manual | version 1.2.11 ff4493f
+%csvjoin(1) user manual | version 1.2.12 1128bff
% R. S. Doiel
-% 2024-10-24
+% 2024-11-07
# NAME
@@ -105,6 +105,6 @@ merged-data.csv..
-output=merged-data.csv
~~~
-csvjoin 1.2.11
+csvjoin 1.2.12
diff --git a/csvrows.1.html b/csvrows.1.html
index 80ef2db..1a0a229 100644
--- a/csvrows.1.html
+++ b/csvrows.1.html
@@ -105,7 +105,7 @@ EXAMPLES
Filter 3 randomly selected rows from 10row.csv rendering new CSV with
a header row from 10row.csv.
csvrows -i 10row.csv -header=true -random=3
-csvrows 1.2.11
+csvrows 1.2.12