-
Notifications
You must be signed in to change notification settings - Fork 1
/
variables.go
173 lines (155 loc) · 4.82 KB
/
variables.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package labo
import (
"fmt"
"net/http"
"os"
"regexp"
"strings"
"text/tabwriter"
"time"
)
var (
// client is the HTTP client used throughout the Nintendo Labo package.
client = &http.Client{Timeout: (time.Second * 10)}
)
var (
// kitsRequest is a HTTP GET request for all Nintendo Labo full kits.
kitsRequest, _ = http.NewRequest(http.MethodGet, storeURIKits, nil)
// laboRequest is a HTTP GET request for both Nintendo Labo full kits and parts.
laboRequest, _ = http.NewRequest(http.MethodGet, storeURILabo, nil)
// partsRequest is a HTTP GET request for all Nintendo Labo parts kits.
partsRequest, _ = http.NewRequest(http.MethodGet, storeURIParts, nil)
)
var (
// partsAmounts is the collection of all defined part amount namespaces.
partAmounts = []string{
partAmountOne,
partAmountTwo,
partAmountThree,
partAmountFour,
partAmountFive,
partAmountSix,
partAmountSeven,
partAmountEight,
partAmountNine,
partAmountTen,
partAmountEleven,
partAmountTwelve,
partAmountThirteen}
)
var (
// partColors is the collection of all defined part color namespaces.
partColors = []string{
partColorBlue,
partColorGray,
partColorOrange,
partColorRed,
partColorYellow}
)
var (
// partsGenders is the collection of all defined part gender namespaces.
partGenders = []string{
partGenderFemale,
partGenderMail,
partGenderMale}
)
var (
// partShapes is the collection all defined part shape namespaces.
partShapes = []string{
partShapeOctagonal,
partShapeSquare}
)
var (
// partSizes is the collection of all defined part size namespaces.
partSizes = []string{
partSizeLarge,
partSizeMedium,
partSizeSmall}
)
var (
categoryMap = map[string]string{
kitsID: categoryKit,
laboID: categoryLabo,
partsID: categoryParts}
)
var (
categoryIDMap = map[string]string{
categoryKit: kitsID,
categoryLabo: laboID,
categoryParts: partsID}
)
var (
// partAmountMap is the lookup used to return the correct numeric value for a string number expression.
partAmountMap = map[string]int{
partAmountOne: 1,
partAmountTwo: 2,
partAmountThree: 3,
partAmountFour: 4,
partAmountFive: 5,
partAmountSix: 6,
partAmountSeven: 7,
partAmountEight: 8,
partAmountNine: 9,
partAmountTen: 10,
partAmountEleven: 11,
partAmountTwelve: 12,
partAmountThirteen: 13}
)
var (
// partColorMap is the lookup used to return the correct Nintendo Labo part color value for a string.
partColorMap = map[string]string{
partColorBlue: (partColorBlue),
partColorGray: (partColorGray),
partColorOrange: (partColorOrange),
partColorRed: (partColorRed),
partColorYellow: (partColorYellow)}
)
var (
// partGenderMap is the lookup used to return the correct Nintendo Labo part gender value for a string.
partGenderMap = map[string]string{
partGenderFemale: (partGenderFemale),
partGenderMail: (partGenderMale),
partGenderMale: (partGenderMale)}
)
var (
// partShapeMap is the lookup used to return the correct Nintendo Labo part shape value for a string.
partShapeMap = map[string]string{
partShapeOctagonal: (partShapeOctagonal),
partShapeSquare: (partShapeSquare)}
)
var (
partAmountExpression = fmt.Sprintf(patternIgnorecase, strings.Join(partAmounts, "|"))
partColorsExpression = fmt.Sprintf(patternIgnorecase, strings.Join(partColors, "|"))
partGenderExpression = fmt.Sprintf(patternIgnorecase, strings.Join(partGenders, "|"))
partShapeExpression = fmt.Sprintf(patternIgnorecase, strings.Join(partShapes, "|"))
partSizeExpression = fmt.Sprintf(patternIgnorecase, strings.Join(partSizes, "|"))
partSparesExpression = fmt.Sprintf(patternIgnorecase, "spares")
)
var (
regexpMatchAmount = regexp.MustCompile(partAmountExpression)
regexpMatchColor = regexp.MustCompile(partColorsExpression)
regexpMatchCurrency = regexp.MustCompile(`([+-]?[0-9]{1,3}(?:,?[0-9]{3})*(?:\.[0-9]{2})?){1}`)
regexpMatchGender = regexp.MustCompile(partGenderExpression)
regexpMatchNonAlphaNumeric = regexp.MustCompile(`[^a-zA-Z0-9\s]+`)
regexpMatchNonAlphaNumericNoSpace = regexp.MustCompile(`[^a-zA-Z0-9]+`)
regexpMatchNonNumeric = regexp.MustCompile(`[^0-9]+`)
regexpMatchNumbers = regexp.MustCompile(`(\d+)`)
regexpMatchShape = regexp.MustCompile(partShapeExpression)
regexpMatchSize = regexp.MustCompile(partSizeExpression)
regexpMatchMultipleSpaces = regexp.MustCompile(`\s{2,}`)
regexpMatchSpares = regexp.MustCompile(partSparesExpression)
)
var (
partRegexps = []*regexp.Regexp{
regexpMatchAmount,
regexpMatchColor,
regexpMatchGender,
regexpMatchNonAlphaNumeric,
regexpMatchNumbers,
regexpMatchShape,
regexpMatchSize,
regexpMatchSpares}
)
var (
w = new(tabwriter.Writer).Init(os.Stdout, 4, 4, 0, '\t', 0)
)