Skip to content

Commit

Permalink
Patch Parser::Source::Buffer#source_lines
Browse files Browse the repository at this point in the history
The original one uses String#chomp!
  • Loading branch information
elia committed Apr 26, 2018
1 parent 1da65a0 commit e67d849
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .rubocop.yml
Expand Up @@ -385,8 +385,13 @@ Style/MutableConstant:
Style/EmptyCaseCondition:
Enabled: false


# Use whatever suites the situation, sometimes assign_inside_condition is
# more readable over assign_to_condition despite the risk of repeating the
# variable name.
Style/ConditionalAssignment:
Enabled: false

Naming/MemoizedInstanceVariableName:
Exclude:
- lib/opal/parser/patch.rb # it's a monkey-patch on the parser gem
10 changes: 10 additions & 0 deletions lib/opal/parser/patch.rb
Expand Up @@ -13,4 +13,14 @@ def extend_string(string, ts, te)
@buffer += string
end
end

class Parser::Source::Buffer
def source_lines
@lines ||= begin
lines = @source.lines.to_a
lines << '' if @source.end_with?("\n")
lines.map { |line| line.chomp("\n") }
end
end
end
end

0 comments on commit e67d849

Please sign in to comment.