Class: RuboCop::Markdown::RubyExtractor
- Inherits:
-
Object
- Object
- RuboCop::Markdown::RubyExtractor
- Defined in:
- lib/rubocop/markdown/ruby_extractor.rb
Overview
Extract Ruby codes from Markdown template.
Constant Summary collapse
- SUPPORTED_EXTENSIONS =
%w[ .markdown .md ].freeze
- SUPPORTED_LANGUAGES =
%w[ rb ruby ].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Array<RuboCop::ProcessedSource>?
-
#initialize(processed_source) ⇒ RubyExtractor
constructor
A new instance of RubyExtractor.
Constructor Details
#initialize(processed_source) ⇒ RubyExtractor
Returns a new instance of RubyExtractor.
29 30 31 |
# File 'lib/rubocop/markdown/ruby_extractor.rb', line 29 def initialize(processed_source) @processed_source = processed_source end |
Class Method Details
.call(processed_source) ⇒ Array<RuboCop::ProcessedSource>?
23 24 25 |
# File 'lib/rubocop/markdown/ruby_extractor.rb', line 23 def call(processed_source) new(processed_source).call end |
Instance Method Details
#call ⇒ Array<RuboCop::ProcessedSource>?
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rubocop/markdown/ruby_extractor.rb', line 34 def call return unless supported_file_path_pattern? code_blocks.map do |code_block| { offset: ::RuboCop::Markdown::Position.new( column: code_block.sourcepos[:start_column], content: template_source, line: code_block.sourcepos[:start_line] ).index, processed_source: ::RuboCop::ProcessedSource.new( code_block.string_content, @processed_source.ruby_version, file_path ) } end end |