Skip to content

Commit

Permalink
Isolate jennifer dependency to spdxgen package (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdk authored Sep 11, 2018
1 parent 273a4db commit 03c57a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
17 changes: 0 additions & 17 deletions spdx/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

package spdx

import (
"github.com/dave/jennifer/jen"
)

type License struct {
Name string `json:"name"`
Identifier string `json:"licenseId"`
Expand All @@ -18,16 +14,3 @@ type License struct {
Deprecated bool `json:"isDeprecatedLicenseId"`
OSIApproved bool `json:"isOsiApproved"`
}

func (l *License) JenValue() jen.Dict {
return jen.Dict{
jen.Id("Name"): jen.Lit(l.Name),
jen.Id("Identifier"): jen.Lit(l.Identifier),
jen.Id("Text"): jen.Lit(l.Text),
jen.Id("URIs"): jen.Lit(l.URIs),
jen.Id("StandardTemplate"): jen.Lit(l.StandardTemplate),
jen.Id("StandardHeader"): jen.Lit(l.StandardHeader),
jen.Id("Deprecated"): jen.Lit(l.Deprecated),
jen.Id("OSIApproved"): jen.Lit(l.OSIApproved),
}
}
11 changes: 10 additions & 1 deletion spdxgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,16 @@ func render(pkg string, license spdx.License) string {
// https://github.com/golang/go/issues/13560#issuecomment-277804473
f.HeaderComment("Code generated by github.com/joshdk/licensor/spdxgen. DO NOT EDIT.")

value := license.JenValue()
value := jen.Dict{
jen.Id("Name"): jen.Lit(license.Name),
jen.Id("Identifier"): jen.Lit(license.Identifier),
jen.Id("Text"): jen.Lit(license.Text),
jen.Id("URIs"): jen.Lit(license.URIs),
jen.Id("StandardTemplate"): jen.Lit(license.StandardTemplate),
jen.Id("StandardHeader"): jen.Lit(license.StandardHeader),
jen.Id("Deprecated"): jen.Lit(license.Deprecated),
jen.Id("OSIApproved"): jen.Lit(license.OSIApproved),
}

f.Func().Id("init").Params().Block(
jen.Id("licenses").Op("=").Append(
Expand Down

0 comments on commit 03c57a2

Please sign in to comment.