2017-11-08 07:28:33 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
type RouteSubset struct {
|
|
|
|
RouteList []*RouteImpl
|
|
|
|
}
|
|
|
|
|
2017-11-10 03:33:11 +00:00
|
|
|
func (set *RouteSubset) Before(lines ...string) *RouteSubset {
|
|
|
|
for _, line := range lines {
|
|
|
|
for _, route := range set.RouteList {
|
|
|
|
route.RunBefore = append(route.RunBefore, Runnable{line, false})
|
|
|
|
}
|
2017-11-08 07:28:33 +00:00
|
|
|
}
|
2017-11-10 03:33:11 +00:00
|
|
|
return set
|
|
|
|
}
|
|
|
|
|
|
|
|
func (set *RouteSubset) LitBefore(lines ...string) *RouteSubset {
|
|
|
|
for _, line := range lines {
|
|
|
|
for _, route := range set.RouteList {
|
|
|
|
route.RunBefore = append(route.RunBefore, Runnable{line, true})
|
|
|
|
}
|
2017-11-08 07:28:33 +00:00
|
|
|
}
|
|
|
|
return set
|
|
|
|
}
|
|
|
|
|
|
|
|
func (set *RouteSubset) Not(path ...string) *RouteSubset {
|
|
|
|
for i, route := range set.RouteList {
|
|
|
|
if inStringList(route.Path, path) {
|
|
|
|
set.RouteList = append(set.RouteList[:i], set.RouteList[i+1:]...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return set
|
|
|
|
}
|