Documentation
¶
Overview ¶
Copyright © 2014, All rights reserved Joel Scoble, https://github.com/mohae/transmogrifier
This is licensed under The MIT License. Please refer to the included LICENSE file for more information. If the LICENSE file has not been included, please refer to the url above.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License
Index ¶
- Variables
- func NewResource(s string, f FormatType, t ResourceType) resource
- type CSV
- func (c *CSV) HasHeader() bool
- func (c *CSV) HeaderRow() []string
- func (c *CSV) Read(r io.Reader) error
- func (c *CSV) ReadFile(f string) error
- func (c *CSV) ReadSource() error
- func (c *CSV) Rows() [][]string
- func (c *CSV) SetHasHeader(b bool)
- func (c *CSV) SetSource(s string)
- func (c *CSV) Source() string
- type FormatType
- type MDTable
- func (m MDTable) Bytes() []byte
- func (m *MDTable) SetColumnAlignment(cols []string)
- func (m *MDTable) SetColumnEmphasis(cols []string)
- func (m *MDTable) SetColumnNames(cols []string)
- func (m *MDTable) SetDest(s string)
- func (m *MDTable) SetFormatSource(s string) error
- func (m *MDTable) SetHasColumnNames(b bool)
- func (m *MDTable) SetSource(s string) error
- func (m *MDTable) SetUseFormat(b bool)
- func (m MDTable) String() string
- func (m *MDTable) TransmogrifyStringTable(t [][]string) error
- func (m *MDTable) WriteToFile() (name string, n int, err error)
- type ResourceType
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoSource = errors.New("no source was specified")
)
Common errors
Functions ¶
func NewResource ¶
func NewResource(s string, f FormatType, t ResourceType) resource
Types ¶
type CSV ¶
type CSV struct {
// contains filtered or unexported fields
}
CSV is a struct for representing and working with csv data.
func NewCSV ¶
func NewCSV() *CSV
NewCSV returns an initialize CSV object. It still needs to be configured for use.
func NewCSVSource ¶
NewCSVSource creates a new *CSV with its source set,
func (*CSV) Read ¶
ReadAll takes a reader, and reads the data connected with it as CSV data. If there is a header row, CSV.hasHeader == true, the headerRow field is populated with the first row of the source. This reads the entire file at once. If an error occurs, it is returned
func (*CSV) ReadFile ¶
ReadFile takes a path, reads the contents of the file and returns any error encountered. The entire file will be read at once.
func (*CSV) ReadSource ¶
func (*CSV) SetHasHeader ¶
type FormatType ¶
type FormatType int
FormatType is the format of a resource
func FormatTypeFromString ¶
func FormatTypeFromString(s string) FormatType
func (FormatType) String ¶
func (f FormatType) String() string
type MDTable ¶
type MDTable struct {
// contains filtered or unexported fields
}
MDTable is a struct for representing and working with markdown tables
func (*MDTable) SetColumnAlignment ¶
func (*MDTable) SetColumnEmphasis ¶
func (*MDTable) SetDest ¶
SetDest sets the destination of the Write operation. If the destination is an empty string, "", the source name will be concatinated with '.md'. Any non-empty dest string will be used as the destination.
Currently, only write to file is supported.
func (*MDTable) SetFormatSource ¶
SetFormatSource set's the source of the format information and sets useFormat to 'true'. If the formatSource != "", it will be used as the location of the formatting information for the MD Table. If it isn't set and useFormat == true, the format source is expected to be in the same location as the source, with the same name + an extension of '.fmt'.
func (*MDTable) SetSource ¶
SetSource set's the Source to the passed value. The source's extension is checked to see if it is a supported format. An error is returned if it isn't.
func (*MDTable) SetUseFormat ¶
SetUseFormat: whether or not a format should be applied to the MD table.
func (*MDTable) TransmogrifyStringTable ¶
Transmogrify transomgrifies the source into a MD table. The result is held in md and can be obtained by m.MD(). Any error encountered is returned. SetHasHeader needs to be called prior to calling this method.
type ResourceType ¶
type ResourceType int
ResourceType is the type of a resource
const ( UnsupportedResource ResourceType = iota File )
func ResourceTypeFromString ¶
func ResourceTypeFromString(s string) ResourceType
ResourceTypeFromString returns the ResourceType constant
func (ResourceType) String ¶
func (r ResourceType) String() string
