Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4 from andybalholm/master

support for comments - Thanks andybalholm!
  • Loading branch information...
commit 22dc07a224454b8d66ce10c953ae406cd941618e 2 parents 5ef85da + 3a06eea
@kylelemons authored
View
1  .gitignore
@@ -1,3 +1,4 @@
+*.out
.DS_Store
*.[568ao]
._*
View
2  yaml/config.go
@@ -32,7 +32,7 @@ func ReadFile(filename string) (*File, os.Error) {
return f, nil
}
-// ReadFile reads a YAML configuration file from a static string.
+// ReadString reads a YAML configuration file from a static string.
func ReadString(configuration string) (*File, os.Error) {
var err os.Error
buf := bytes.NewBufferString(configuration)
View
7 yaml/parser.go
@@ -251,6 +251,7 @@ func (lb *lineBuffer) Next(min int) (next *indentedLine) {
l.line = append(l.line, read...)
}
lb.readLines++
+
for _, ch := range l.line {
switch ch {
case ' ':
@@ -261,6 +262,12 @@ func (lb *lineBuffer) Next(min int) (next *indentedLine) {
break
}
l.line = l.line[l.indent:]
+
+ // Ignore blank lines and comments.
+ if len(l.line) == 0 || l.line[0] == '#' {
+ return lb.Next(min)
+ }
+
lb.pending = l
}
next = lb.pending
View
1  yaml/parser_test.go
@@ -23,6 +23,7 @@ var parseTests = []struct {
" e: f\n" +
" g: h: i\n" +
" j: k\n" +
+ "# comment\n" +
" l: m\n" +
"n: o\n" +
"",
Please sign in to comment.
Something went wrong with that request. Please try again.