Class: Necropsy::EntryPoints::Plain

Inherits:
Object
  • Object
show all
Defined in:
lib/necropsy/entry_points/plain.rb

Constant Summary collapse

SCRIPT_PATTERNS =
[
  'bin/*',
  'exe/*',
  'Rakefile',
  '**/*.rake',
  '*.gemspec'
].freeze

Instance Method Summary collapse

Instance Method Details

#apply(graph, project) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/necropsy/entry_points/plain.rb', line 14

def apply(graph, project)
  graph.nodes.values.select { |node| node.kind == :block_entry && !node.test }.each do |node|
    next unless SCRIPT_PATTERNS.any? { |pattern| File.fnmatch?(pattern, node.file, File::FNM_PATHNAME) }

    graph.add_entry_point(node.id, :main_script)
  end

  project.config.entry_point_patterns.each do |pattern|
    graph.nodes.each_key do |node_id|
      graph.add_entry_point(node_id, :public_api_declared) if File.fnmatch?(pattern, node_id)
    end
  end

  graph.method_nodes.each do |node|
    next unless node.file == 'lib/necropsy.rb'
    next unless node.kind == :singleton_method && node.owner == 'Necropsy'

    graph.add_entry_point(node.id, :public_api_declared)
  end
end