github.com/lastbackend/toolkit@v0.0.0-20241020043710-cafa37b95aad/pkg/runtime/meta/meta.go (about)

     1  package meta
     2  
     3  import (
     4  	"regexp"
     5  	"strings"
     6  )
     7  
     8  type Meta struct {
     9  	name        string
    10  	version     string
    11  	description string
    12  	prefix      string
    13  }
    14  
    15  func (m *Meta) SetName(name string) *Meta {
    16  	m.name = name
    17  	return m
    18  }
    19  
    20  func (m *Meta) GetName() string {
    21  	return m.name
    22  }
    23  
    24  func (m *Meta) GetSlug() string {
    25  	slug := regexp.MustCompile(`[^_a-zA-Z0-9 ]+`).ReplaceAllString(m.name, "_")
    26  	return slug
    27  }
    28  
    29  func (m *Meta) SetVersion(version string) *Meta {
    30  	m.version = version
    31  	return m
    32  }
    33  
    34  func (m *Meta) GetVersion() string {
    35  	return m.version
    36  }
    37  
    38  func (m *Meta) SetDescription(description string) *Meta {
    39  	m.description = description
    40  	return m
    41  }
    42  
    43  func (m *Meta) GetDescription() string {
    44  	return m.description
    45  }
    46  
    47  func (m *Meta) SetEnvPrefix(prefix string) *Meta {
    48  	m.prefix = strings.ToUpper(regexp.MustCompile(`[^_a-zA-Z0-9 ]+`).ReplaceAllString(prefix, ""))
    49  	return m
    50  }
    51  
    52  func (m *Meta) GetEnvPrefix() string {
    53  	return m.prefix
    54  }