-
Notifications
You must be signed in to change notification settings - Fork 1
/
stanza.go
126 lines (104 loc) · 2.87 KB
/
stanza.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package cask
// A Stanza represents the interface that each stanza Type specific stanza
// should implement.
type Stanza interface {
String() string
}
// A BaseStanza represents a base for all stanzas. Shouldn't be used as is, but
// inherited by type specific stanzas.
type BaseStanza struct {
// IsGlobal specifies if the appcast belongs to all Cask.Variants. If the
// stanza wasn't found inside if statement, the stanza should be considered as
// global and this value should be true. By default, this value is "false".
IsGlobal bool
}
// A SHA256 represents a sha256 cask stanza.
type SHA256 struct {
BaseStanza
// Value specifies the stanza value.
Value string
}
// NewSHA256 creates a new SHA256 instance and returns its pointer. Requires
// SHA256.Value to be passed as argument.
func NewSHA256(value string) *SHA256 {
return &SHA256{
Value: value,
}
}
// String returns a string representation of the SHA256 struct which is the
// SHA256.Value.
func (s SHA256) String() string {
return s.Value
}
// An URL represents an url cask stanza.
type URL struct {
BaseStanza
// Value specifies the stanza value.
Value string
}
// NewURL creates a new URL instance and returns its pointer. Requires URL.Value
// to be passed as argument.
func NewURL(value string) *URL {
return &URL{
Value: value,
}
}
// String returns a string representation of the URL struct which is the
// URL.Value.
func (u URL) String() string {
return u.Value
}
// An Appcast represents an appcast cask stanza.
type Appcast struct {
BaseStanza
// URL specifies the appcast URL.
URL string
}
// NewAppcast creates a new Appcast instance and returns its pointer. Requires
// both Appcast.URL and Appcast.Checkpoint to be passed as arguments.
func NewAppcast(url string, checkpoint string) *Appcast {
return &Appcast{
URL: url,
}
}
// String returns a string representation of the Appcast struct which is the
// Appcast.URL.
func (a Appcast) String() string {
return a.URL
}
// A Name represents a name cask stanza.
type Name struct {
BaseStanza
// Value specifies the stanza value.
Value string
}
// NewName creates a new Name instance and returns its pointer. Requires
// Name.Value to be passed as argument.
func NewName(value string) *Name {
return &Name{
Value: value,
}
}
// String returns a string representation of the Name struct which is the
// Name.Value.
func (n Name) String() string {
return n.Value
}
// A Homepage represents a homepage cask stanza.
type Homepage struct {
BaseStanza
// Value specifies the stanza value.
Value string
}
// NewHomepage creates a new Homepage instance and returns its pointer. Requires
// Homepage.Value to be passed as argument.
func NewHomepage(value string) *Homepage {
return &Homepage{
Value: value,
}
}
// String returns a string representation of the Homepage struct which is the
// Homepage.Value.
func (h Homepage) String() string {
return h.Value
}