Class: SocialSnippet::Resolvers::DepResolver

Inherits:
BaseResolver show all
Defined in:
lib/social_snippet/resolvers/dep_resolver.rb

Instance Attribute Summary collapse

Attributes inherited from BaseResolver

#social_snippet, #visited

Instance Method Summary collapse

Methods inherited from BaseResolver

#each_snip_tags

Constructor Details

#initialize(social_snippet) ⇒ DepResolver

Constructor


10
11
12
13
# File 'lib/social_snippet/resolvers/dep_resolver.rb', line 10

def initialize(social_snippet)
  @dep_to = {} # dep_to[tag_from] = tag_to
  super(social_snippet)
end

Instance Attribute Details

#dep_toObject (readonly)

Returns the value of attribute dep_to


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

def dep_to
  @dep_to
end

Instance Method Details

#find(src, context_from, tag_from) ⇒ Object

Find all missing depended snippets


20
21
22
23
24
25
26
27
28
29
# File 'lib/social_snippet/resolvers/dep_resolver.rb', line 20

def find(src, context_from, tag_from)
  found_tags = find_func src, context_from, tag_from
  found_tags.each do |tag_info|
    # remove self from deps graph
    tag = tag_info[:tag]
    dep_to[tag.to_path] ||= ::Set.new
    dep_to[tag.to_path].delete tag_from.to_path
  end
  found_tags
end