aboutsummaryrefslogtreecommitdiffstats
path: root/skate
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-07-10 03:13:20 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-07-10 03:13:20 +0200
commit9f2c63a4e87a2638cc63620e6722fae494495dc6 (patch)
treea715f828046f64d7737f69576683843685854e49 /skate
parentd642a578df04040b9df58c83c5ebf135b7b2ce81 (diff)
downloadrefcat-9f2c63a4e87a2638cc63620e6722fae494495dc6.tar.gz
refcat-9f2c63a4e87a2638cc63620e6722fae494495dc6.zip
schema: flesh our unstructured rendering
Diffstat (limited to 'skate')
-rw-r--r--skate/schema.go30
-rw-r--r--skate/schema_test.go26
2 files changed, 56 insertions, 0 deletions
diff --git a/skate/schema.go b/skate/schema.go
index a9b6a96..77460d1 100644
--- a/skate/schema.go
+++ b/skate/schema.go
@@ -150,6 +150,36 @@ func ReleaseToUnstructured(r *Release) string {
}
fmt.Fprintf(&buf, `%s`, r.ContainerName)
}
+ if r.Volume != "" {
+ if buf.Len() > 0 {
+ fmt.Fprintf(&buf, ", ")
+ }
+ fmt.Fprintf(&buf, `vol. %s`, r.Volume)
+ }
+ if r.Issue != "" {
+ if buf.Len() > 0 {
+ fmt.Fprintf(&buf, ", ")
+ }
+ fmt.Fprintf(&buf, `no. %s`, r.Issue)
+ }
+ if r.ReleaseYear() > 0 {
+ if buf.Len() > 0 {
+ fmt.Fprintf(&buf, ", ")
+ }
+ fmt.Fprintf(&buf, `%s`, r.ReleaseYearString())
+ }
+ if r.Pages != "" {
+ if buf.Len() > 0 {
+ fmt.Fprintf(&buf, ", ")
+ }
+ fmt.Fprintf(&buf, `pp. %s`, r.Pages)
+ }
+ if r.Publisher != "" {
+ if buf.Len() > 0 {
+ fmt.Fprintf(&buf, ", ")
+ }
+ fmt.Fprintf(&buf, `%s`, r.Publisher)
+ }
return buf.String()
}
diff --git a/skate/schema_test.go b/skate/schema_test.go
index a8f1ecf..cfffced 100644
--- a/skate/schema_test.go
+++ b/skate/schema_test.go
@@ -262,16 +262,42 @@ func TestReleaseToUnstructured(t *testing.T) {
s string
}{
{r: &Release{}, s: ""},
+ {r: &Release{Volume: "12"}, s: "vol. 12"},
+ {r: &Release{Volume: "12", Issue: "X"}, s: "vol. 12, no. X"},
+ {r: &Release{Volume: "12", Issue: "X", ReleaseYearValue: "1999"}, s: "vol. 12, no. X, 1999"},
+ {r: &Release{Volume: "12", ContainerName: "Solar",
+ ReleaseYearValue: "1999"}, s: "Solar, vol. 12, 1999"},
{r: &Release{
Title: "ABC",
}, s: "ABC"},
{r: &Release{
+ Title: "ABC",
+ ReleaseYearValue: "2000",
+ }, s: "ABC, 2000"},
+ {r: &Release{
+ ContainerName: "Journal of Letters",
+ }, s: "Journal of Letters"},
+ {r: &Release{
+ ContainerName: "Journal of Letters",
+ }, s: "Journal of Letters"},
+ {r: &Release{
Title: "ABC",
ContainerName: "Journal of Letters",
}, s: "ABC. Journal of Letters"},
{r: &Release{
Title: "ABC",
ContainerName: "Journal of Letters",
+ Volume: "12",
+ Pages: "1-10",
+ }, s: "ABC. Journal of Letters, vol. 12, pp. 1-10"},
+ {r: &Release{
+ Title: "ABC",
+ ReleaseYearValue: "2010",
+ ContainerName: "Journal of Letters",
+ }, s: "ABC. Journal of Letters, 2010"},
+ {r: &Release{
+ Title: "ABC",
+ ContainerName: "Journal of Letters",
Contribs: []struct {
Index int `json:"index,omitempty"`
RawName string `json:"raw_name,omitempty"`