Skip to content

Commit

Permalink
Minor corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
evangelion1204 committed Jun 29, 2015
1 parent 072033d commit 651612f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ Parser = (function() {
};
for (_i = 0, _len = lines.length; _i < _len; _i++) {
line = lines[_i];
line = line.trim();
_ref = this.handlers;
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
handler = _ref[_j];
Expand Down Expand Up @@ -170,7 +169,7 @@ Parser = (function() {

Parser.prototype.handleMultiLineStart = function(ctx, line) {
var key, keys, value, _ref;
if (!this.isMultiLine(line)) {
if (!this.isMultiLine(line.trim())) {
return false;
}
_ref = this.getMultiKeyValue(line), key = _ref[0], value = _ref[1];
Expand All @@ -182,7 +181,7 @@ Parser = (function() {

Parser.prototype.handleMultiLineEnd = function(ctx, line) {
var status, value, _ref;
if (!ctx.multiLineKeys || !this.isMultiLineEnd(line)) {
if (!ctx.multiLineKeys || !this.isMultiLineEnd(line.trim())) {
return false;
}
_ref = this.getMultiLineEndValue(line), value = _ref[0], status = _ref[1];
Expand All @@ -202,19 +201,20 @@ Parser = (function() {
};

Parser.prototype.handleMultiLineAppend = function(ctx, line) {
if (!ctx.multiLineKeys || this.isMultiLineEnd(line)) {
if (!ctx.multiLineKeys || this.isMultiLineEnd(line.trim())) {
return false;
}
ctx.multiLineValue += '\n' + line;
return true;
};

Parser.prototype.handleComment = function(ctx, line) {
return this.isComment(line);
return this.isComment(line.trim());
};

Parser.prototype.handleSection = function(ctx, line) {
var section;
line = line.trim();
if (!this.isSection(line)) {
return false;
}
Expand All @@ -228,6 +228,7 @@ Parser = (function() {

Parser.prototype.handleSingleLine = function(ctx, line) {
var key, keys, status, value, _ref;
line = line.trim();
if (!this.isSingleLine(line)) {
return false;
}
Expand Down
12 changes: 6 additions & 6 deletions src/parser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class Parser
multiLineValue: ''

for line in lines
line = line.trim()

for handler in @handlers
stop = handler.call(this, ctx, line)

Expand Down Expand Up @@ -139,7 +137,7 @@ class Parser
return result[1]

handleMultiLineStart: (ctx, line) ->
return false unless @isMultiLine(line)
return false unless @isMultiLine(line.trim())

[key, value] = @getMultiKeyValue(line)
keys = key.split('.')
Expand All @@ -150,7 +148,7 @@ class Parser
return true

handleMultiLineEnd: (ctx, line) ->
return false if not ctx.multiLineKeys or not @isMultiLineEnd(line)
return false if not ctx.multiLineKeys or not @isMultiLineEnd(line.trim())

[value, status] = @getMultiLineEndValue(line)

Expand All @@ -174,15 +172,16 @@ class Parser
return true

handleMultiLineAppend: (ctx, line) ->
return false if not ctx.multiLineKeys or @isMultiLineEnd(line)
return false if not ctx.multiLineKeys or @isMultiLineEnd(line.trim())

ctx.multiLineValue += '\n' + line
return true

handleComment: (ctx, line) ->
return @isComment(line)
return @isComment(line.trim())

handleSection: (ctx, line) ->
line = line.trim()
return false unless @isSection(line)
section = @getSection(line)

Expand All @@ -194,6 +193,7 @@ class Parser
return true

handleSingleLine: (ctx, line) ->
line = line.trim()
return false unless @isSingleLine(line)

[key, value, status] = @getKeyValue(line)
Expand Down

0 comments on commit 651612f

Please sign in to comment.