Class: JsDependency::SourceAnalysis::Orphan

Inherits:
Object
  • Object
show all
Defined in:
lib/js_dependency/source_analysis/orphan.rb

Overview

Components is not depended on.

Instance Method Summary collapse

Constructor Details

#initialize(index, src_path) ⇒ Orphan

Returns a new instance of Orphan.

Parameters:

  • index (Hash)
  • src_path (String)


11
12
13
14
# File 'lib/js_dependency/source_analysis/orphan.rb', line 11

def initialize(index, src_path)
  @index = index
  @src_path = src_path
end

Instance Method Details

#callArray<String>

Returns:

  • (Array<String>)


17
18
19
20
21
22
23
24
25
26
# File 'lib/js_dependency/source_analysis/orphan.rb', line 17

def call
  orphan_index = @index.filter do |target_path, _child_paths|
    orphan?(target_path)
  end

  orphan_index = orphan_index.transform_keys do |target_path|
    relative_path_or_external_path(target_path, @src_path)
  end
  orphan_index.keys.uniq.sort
end