Class: DepsGrapher::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/deps_grapher/input.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Input

Returns a new instance of Input.



5
6
7
# File 'lib/deps_grapher/input.rb', line 5

def initialize(config)
  @config = config
end

Instance Method Details

#filesObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/deps_grapher/input.rb', line 9

def files
  FileUtils.rm_rf File.dirname(config.cache_dir) if config.clean

  layer_visibilities = config.visualizer_options[:layers]

  files = []

  SourceCache::Registry.with_cache config.cache_key do |restored|
    config.layers.each_value do |layer|
      name = layer.name
      source = layer.source

      layer.visible = layer_visibilities.include? name

      SourceCache.register! name, source unless restored

      next unless layer.visible

      source.files.each do |file|
        next if file == config.path

        files << file
      end
    end
  end

  files
end