-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadaptors.go
63 lines (53 loc) · 1.33 KB
/
adaptors.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
package snag
import (
"github.com/samxsmith/snag/builder"
"github.com/samxsmith/snag/config"
"github.com/samxsmith/snag/parser"
)
func schemaToBuilderType(ct config.AggregationType) builder.AggregationType {
switch ct {
case config.AggregationTypeCount:
return builder.AggregationTypeCount
case config.AggregationTypeList:
return builder.AggregationTypeList
default:
}
panic("unknown type: ")
}
func schemaToBuilderSortCols(cls []config.SortColumn) []builder.SortCol {
bcols := make([]builder.SortCol, len(cls))
for i, col := range cls {
bc := builder.SortCol{
Name: col.Name,
Type: schemaToBuilderSortType(col.ColType),
SortAscending: col.SortAscending,
}
bcols[i] = bc
}
return bcols
}
func schemaToBuilderSortType(t config.SortType) builder.SortColType {
switch t {
case config.SortTypeNumber:
return builder.SortColTypeNum
case config.SortTypeDate:
return builder.SortColTypeDate
default:
}
panic("unknown sort type")
}
func createBuilderEntry(m LineMatch, e parser.Entry) builder.Entry {
return builder.Entry{
SourceFilePath: m.FilePath,
Fields: e.Fields,
}
}
func schemaToBuilderSourceLink(c config.LinkType) builder.LinkType {
if c == config.WikiLink {
return builder.WikiLink
}
if c == config.MarkdownLink {
return builder.MarkdownLink
}
return builder.NoLink
}