Class: Suspenders::Actions::StripCommentsAction::StripLeadingScopeNewlines
- Inherits:
-
Object
- Object
- Suspenders::Actions::StripCommentsAction::StripLeadingScopeNewlines
- Defined in:
- lib/suspenders/actions/strip_comments_action.rb
Overview
The intent of this class is purely aesthetic: remove leading newlines inside of code scopes like blocks and begin/end. Example input:
module MyGem
MyGem.application.configure do |config|
config.option1 = true
config.option2 = false
end
end
The output is:
module MyGem
MyGem.application.configure do |config|
config.option1 = true
config.option2 = false
end
end
Defined Under Namespace
Classes: LeadingNewlineStripRewriter
Class Method Summary collapse
Class Method Details
.call(source, parser) ⇒ Object
140 141 142 143 144 145 |
# File 'lib/suspenders/actions/strip_comments_action.rb', line 140 def self.call(source, parser) buffer = Parser::Source::Buffer.new(nil, source: source) ast = parser.parse(buffer) LeadingNewlineStripRewriter.new.rewrite(buffer, ast).lstrip end |