Sha256: 948d9980540983f7690c2c0f59b6590d6de011a99e90b2e89a9774a245e85754
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module AnnotateRb module ModelAnnotator module AnnotatedFile # Updates existing annotations class Updater def initialize(file_content, new_annotations, _annotation_position, options) @options = options @new_annotations = new_annotations @file_content = file_content @parsed_file = FileParser::ParsedFile.new(@file_content, @new_annotations, options).parse end # @return [String] Returns the annotated file content to be written back to a file def update return "" if !@parsed_file.has_annotations? new_annotation = wrapped_content(@new_annotations) _content = @file_content.sub(@parsed_file.annotations, new_annotation) end private def wrapped_content(content) wrapper_open = if @options[:wrapper_open] "# #{@options[:wrapper_open]}\n" else "" end wrapper_close = if @options[:wrapper_close] "# #{@options[:wrapper_close]}\n" else "" end _wrapped_info_block = "#{wrapper_open}#{content}#{wrapper_close}" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
annotaterb-4.7.0 | lib/annotate_rb/model_annotator/annotated_file/updater.rb |
annotaterb-4.6.0 | lib/annotate_rb/model_annotator/annotated_file/updater.rb |