Class: SocialSnippet::Resolvers::BaseResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/social_snippet/resolvers/base_resolver.rb

Direct Known Subclasses

DepResolver, InsertResolver

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(new_social_snippet) ⇒ BaseResolver

Constructor

Parameters:


11
12
13
14
# File 'lib/social_snippet/resolvers/base_resolver.rb', line 11

def initialize(new_social_snippet)
  @social_snippet = new_social_snippet
  @visited = Set.new
end

Instance Attribute Details

#social_snippetObject (readonly)

Returns the value of attribute social_snippet


5
6
7
# File 'lib/social_snippet/resolvers/base_resolver.rb', line 5

def social_snippet
  @social_snippet
end

#visitedObject (readonly)

Returns the value of attribute visited


6
7
8
# File 'lib/social_snippet/resolvers/base_resolver.rb', line 6

def visited
  @visited
end

Instance Method Details

#each_snip_tags(src, context, base_tag) ⇒ Object

Call block each snip tags

Parameters:


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/social_snippet/resolvers/base_resolver.rb', line 21

def each_snip_tags(src, context, base_tag)
  TagParser.find_snip_tags(src).each do |tag_info|
    t = tag_info[:tag].set_by_tag(base_tag)
    new_context = context.clone

    move_context_by_tag! new_context, t
    overwrite_tag_in_same_repository! context, t
    update_tag_path_by_context! new_context, t
    resolve_tag_repo_ref! t

    snippet = social_snippet.repo_manager.get_snippet(context, t)

    if block_given?
      yield(
        tag_info[:tag],
        tag_info[:line_no],
        snippet,
        new_context
      )
    end
  end
end