-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cloc | ||
|
||
// LanguageSummary to generate output like cloc | ||
type LanguageSummaryCloc struct { | ||
Name string `yaml:"name"` | ||
Code int64 `yaml:"code"` | ||
Comment int64 `yaml:"comment"` | ||
Blank int64 `yaml:"blank"` | ||
Count int64 `yaml:"nFiles"` | ||
} | ||
|
||
type SummaryStruct struct { | ||
Code int64 `yaml:"code"` | ||
Comment int64 `yaml:"comment"` | ||
Blank int64 `yaml:"blank"` | ||
Count int64 `yaml:"nFiles"` | ||
} | ||
|
||
type HeaderStruct struct { | ||
Url string `yaml:"url"` | ||
Version string `yaml:"version"` | ||
ElapsedSeconds float64 `yaml:"elapsed_seconds"` | ||
NFiles int64 `yaml:"n_files"` | ||
NLines int64 `yaml:"n_lines"` | ||
FilesPerSecond float64 `yaml:"files_per_second"` | ||
LinesPerSecond float64 `yaml:"lines_per_second"` | ||
} | ||
|
||
type LanguageReportStart struct { | ||
Header HeaderStruct | ||
} | ||
|
||
type LanguageReportEnd struct { | ||
Sum SummaryStruct `yaml:"SUM"` | ||
} | ||
|
||
type ClocSummary struct { | ||
Header HeaderStruct | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package cloc | ||
|
||
|
||
import ( | ||
"fmt" | ||
. "github.com/onsi/gomega" | ||
"gopkg.in/yaml.v2" | ||
"log" | ||
"testing" | ||
) | ||
|
||
func Test_Yaml_Parse_Model(t *testing.T) { | ||
t.Parallel() | ||
g := NewGomegaWithT(t) | ||
|
||
|
||
var data = ` | ||
header: | ||
url: https://github.com/boyter/scc/ | ||
version: 2.13.0 | ||
elapsed_seconds: 0.006 | ||
n_files: 25 | ||
n_lines: 4045 | ||
files_per_second: 4166.666666666667 | ||
lines_per_second: 674166.6666666666 | ||
` | ||
|
||
var header = LanguageReportStart{} | ||
err := yaml.Unmarshal([]byte(data), &header) | ||
if err != nil { | ||
log.Fatalf("error: %v", header) | ||
} | ||
|
||
g.Expect(header.Header.Version).To(Equal("2.13.0")) | ||
} |