aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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"`