github.com/mattdotmatt/gauge@v0.3.2-0.20160421115137-425a4cdccb62/formatter/formatSpecification.go (about) 1 // Copyright 2015 ThoughtWorks, Inc. 2 3 // This file is part of Gauge. 4 5 // Gauge is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 10 // Gauge is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 15 // You should have received a copy of the GNU General Public License 16 // along with Gauge. If not, see <http://www.gnu.org/licenses/>. 17 18 package formatter 19 20 import ( 21 "bytes" 22 23 "github.com/getgauge/gauge/gauge" 24 ) 25 26 type formatter struct { 27 buffer bytes.Buffer 28 } 29 30 func (formatter *formatter) SpecHeading(specHeading *gauge.Heading) { 31 formatter.buffer.WriteString(FormatHeading(specHeading.Value, "=")) 32 } 33 34 func (formatter *formatter) SpecTags(tags *gauge.Tags) { 35 formatter.buffer.WriteString(FormatTags(tags)) 36 } 37 38 func (formatter *formatter) DataTable(table *gauge.Table) { 39 formatter.buffer.WriteString(FormatTable(table)) 40 } 41 42 func (formatter *formatter) ExternalDataTable(extDataTable *gauge.DataTable) { 43 formatter.buffer.WriteString(FormatExternalDataTable(extDataTable)) 44 } 45 46 func (formatter *formatter) ContextStep(step *gauge.Step) { 47 formatter.Step(step) 48 } 49 50 func (formatter *formatter) TearDown(t *gauge.TearDown) { 51 formatter.buffer.WriteString(t.Value + "\n") 52 } 53 54 func (formatter *formatter) Scenario(scenario *gauge.Scenario) { 55 } 56 57 func (formatter *formatter) ScenarioHeading(scenarioHeading *gauge.Heading) { 58 formatter.buffer.WriteString(FormatHeading(scenarioHeading.Value, "-")) 59 } 60 61 func (formatter *formatter) ScenarioTags(scenarioTags *gauge.Tags) { 62 formatter.SpecTags(scenarioTags) 63 } 64 65 func (formatter *formatter) Step(step *gauge.Step) { 66 formatter.buffer.WriteString(FormatStep(step)) 67 } 68 69 func (formatter *formatter) Comment(comment *gauge.Comment) { 70 formatter.buffer.WriteString(FormatComment(comment)) 71 }