Class: Toml::Merge::FileAnalysis::CommentAugmenter

Inherits:
Object
  • Object
show all
Defined in:
lib/toml/merge/file_analysis.rb

Defined Under Namespace

Classes: OwnerRange

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(analysis, owners: [], **details) ⇒ CommentAugmenter

Returns a new instance of CommentAugmenter.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/toml/merge/file_analysis.rb', line 20

def initialize(analysis, owners: [], **details)
  @analysis = analysis
  @owners = Array(owners)
  @delegate = Ast::Merge::Comment::Augmenter.new(
    lines: analysis.lines,
    comments: analysis.send(:tracked_comment_entries),
    owners: analysis.send(:augmenter_delegate_owners, @owners),
    style: :hash_comment,
    **details,
  )
  @capability = analysis.send(:build_comment_capability, owner_count: @owners.size, **details)
  @attachments_by_owner = @owners.each_with_object({}) do |owner, result|
    result[owner] = analysis.comment_attachment_for(owner)
  end
  @preamble_region = @delegate.preamble_region
  @postlude_region = @delegate.postlude_region
  @orphan_regions = @delegate.orphan_regions
end

Instance Attribute Details

#attachments_by_ownerObject (readonly)

Returns the value of attribute attachments_by_owner.



18
19
20
# File 'lib/toml/merge/file_analysis.rb', line 18

def attachments_by_owner
  @attachments_by_owner
end

#capabilityObject (readonly)

Returns the value of attribute capability.



18
19
20
# File 'lib/toml/merge/file_analysis.rb', line 18

def capability
  @capability
end

#orphan_regionsObject (readonly)

Returns the value of attribute orphan_regions.



18
19
20
# File 'lib/toml/merge/file_analysis.rb', line 18

def orphan_regions
  @orphan_regions
end

#postlude_regionObject (readonly)

Returns the value of attribute postlude_region.



18
19
20
# File 'lib/toml/merge/file_analysis.rb', line 18

def postlude_region
  @postlude_region
end

#preamble_regionObject (readonly)

Returns the value of attribute preamble_region.



18
19
20
# File 'lib/toml/merge/file_analysis.rb', line 18

def preamble_region
  @preamble_region
end

Instance Method Details

#attachment_for(owner) ⇒ Object



39
40
41
# File 'lib/toml/merge/file_analysis.rb', line 39

def attachment_for(owner)
  @attachments_by_owner[owner] || @delegate.attachment_for(owner)
end