github.com/vektra/tachyon@v0.0.0-20150921164542-0da4f3861aef/path.go (about)

     1  package tachyon
     2  
     3  import (
     4  	"path/filepath"
     5  )
     6  
     7  type Paths interface {
     8  	Base() string
     9  	Role(name string) string
    10  	Vars(name string) string
    11  	Task(name string) string
    12  	Handler(name string) string
    13  	File(name string) string
    14  	Meta(name string) string
    15  }
    16  
    17  type SimplePath struct {
    18  	Root string
    19  }
    20  
    21  func (s SimplePath) Base() string {
    22  	return s.Root
    23  }
    24  
    25  func (s SimplePath) Role(name string) string {
    26  	return filepath.Join(s.Root, "roles", name)
    27  }
    28  
    29  func (s SimplePath) Vars(name string) string {
    30  	return filepath.Join(s.Root, name)
    31  }
    32  
    33  func (s SimplePath) Task(name string) string {
    34  	return filepath.Join(s.Root, name)
    35  }
    36  
    37  func (s SimplePath) Handler(name string) string {
    38  	return filepath.Join(s.Root, name)
    39  }
    40  
    41  func (s SimplePath) File(name string) string {
    42  	return filepath.Join(s.Root, name)
    43  }
    44  
    45  func (s SimplePath) Meta(name string) string {
    46  	return filepath.Join(s.Root, name)
    47  }
    48  
    49  type SeparatePaths struct {
    50  	Top  string
    51  	Root string
    52  }
    53  
    54  func (s SeparatePaths) Base() string {
    55  	return s.Root
    56  }
    57  
    58  func (s SeparatePaths) Role(name string) string {
    59  	return filepath.Join(s.Top, "roles", name)
    60  }
    61  
    62  func (s SeparatePaths) Vars(name string) string {
    63  	return filepath.Join(s.Root, "vars", name)
    64  }
    65  
    66  func (s SeparatePaths) Task(name string) string {
    67  	return filepath.Join(s.Root, "tasks", name)
    68  }
    69  
    70  func (s SeparatePaths) Handler(name string) string {
    71  	return filepath.Join(s.Root, "handlers", name)
    72  }
    73  
    74  func (s SeparatePaths) File(name string) string {
    75  	return filepath.Join(s.Root, "files", name)
    76  }
    77  
    78  func (s SeparatePaths) Meta(name string) string {
    79  	return filepath.Join(s.Root, "meta", name)
    80  }