2017-07-16 15:06:32 -03:00
|
|
|
package brew
|
|
|
|
|
|
|
|
type templateData struct {
|
2018-06-20 09:46:42 -03:00
|
|
|
Name string
|
|
|
|
Desc string
|
|
|
|
Homepage string
|
|
|
|
DownloadURL string
|
|
|
|
Version string
|
|
|
|
Caveats []string
|
|
|
|
SHA256 string
|
|
|
|
Plist string
|
|
|
|
DownloadStrategy string
|
|
|
|
Install []string
|
|
|
|
Dependencies []string
|
|
|
|
Conflicts []string
|
|
|
|
Tests []string
|
2017-07-16 15:06:32 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
const formulaTemplate = `class {{ .Name }} < Formula
|
|
|
|
desc "{{ .Desc }}"
|
|
|
|
homepage "{{ .Homepage }}"
|
2018-07-26 16:03:28 +03:00
|
|
|
url "{{ .DownloadURL }}"
|
2018-01-17 18:57:41 -02:00
|
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
2017-07-16 15:06:32 -03:00
|
|
|
version "{{ .Version }}"
|
|
|
|
sha256 "{{ .SHA256 }}"
|
2018-03-28 16:14:27 +02:00
|
|
|
|
2018-04-03 21:13:17 -03:00
|
|
|
{{- with .Dependencies }}
|
|
|
|
{{ range $index, $element := . }}
|
2018-04-01 15:07:28 -03:00
|
|
|
depends_on "{{ . }}"
|
2018-03-28 16:14:27 +02:00
|
|
|
{{- end }}
|
|
|
|
{{- end -}}
|
2017-07-16 15:06:32 -03:00
|
|
|
|
2018-04-01 14:25:04 -03:00
|
|
|
{{- with .Conflicts }}
|
|
|
|
{{ range $index, $element := . }}
|
2017-07-16 15:06:32 -03:00
|
|
|
conflicts_with "{{ . }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
def install
|
|
|
|
{{- range $index, $element := .Install }}
|
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
|
2018-04-01 14:25:04 -03:00
|
|
|
{{- with .Caveats }}
|
2017-07-16 15:06:32 -03:00
|
|
|
|
2018-04-05 13:38:32 -07:00
|
|
|
def caveats; <<~EOS
|
2018-04-01 14:25:04 -03:00
|
|
|
{{- range $index, $element := . }}
|
2018-03-28 16:14:27 +02:00
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
EOS
|
2017-07-16 15:06:32 -03:00
|
|
|
end
|
|
|
|
{{- end -}}
|
|
|
|
|
2018-04-01 14:25:04 -03:00
|
|
|
{{- with .Plist }}
|
2017-07-16 15:06:32 -03:00
|
|
|
|
|
|
|
plist_options :startup => false
|
|
|
|
|
2018-02-06 10:08:20 -08:00
|
|
|
def plist; <<~EOS
|
2018-04-01 14:25:04 -03:00
|
|
|
{{ . }}
|
2018-03-28 16:14:27 +02:00
|
|
|
EOS
|
2017-07-16 15:06:32 -03:00
|
|
|
end
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- if .Tests }}
|
|
|
|
|
|
|
|
test do
|
|
|
|
{{- range $index, $element := .Tests }}
|
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
`
|