Class: Leftovers::MergedConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/leftovers/merged_config.rb

Constant Summary collapse

MEMOIZED_IVARS =
%i{
  @exclude_paths
  @include_paths
  @test_paths
  @precompilers
  @dynamic
  @keep
  @test_only
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(load_defaults: false) ⇒ MergedConfig

Returns a new instance of MergedConfig.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/leftovers/merged_config.rb', line 18

def initialize(load_defaults: false)
  @configs = []
  @loaded_configs = ::Set.new.compare_by_identity
  return unless load_defaults

  self << :ruby
  self << :leftovers
  self << project_config
  self << project_todo
  load_bundled_gem_config
end

Instance Method Details

#<<(config) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/leftovers/merged_config.rb', line 30

def <<(config)
  config = Config[config]

  return if @loaded_configs.include?(config.name)

  unmemoize
  @configs << config
  @loaded_configs << config.name
  config.gems.each { |gem| self << gem }
  require_requires(config)
end

#dynamicObject



58
59
60
# File 'lib/leftovers/merged_config.rb', line 58

def dynamic
  @dynamic ||= ProcessorBuilders::Each.build(@configs.map(&:dynamic))
end

#exclude_pathsObject



42
43
44
# File 'lib/leftovers/merged_config.rb', line 42

def exclude_paths
  @exclude_paths ||= @configs.flat_map(&:exclude_paths)
end

#include_pathsObject



46
47
48
# File 'lib/leftovers/merged_config.rb', line 46

def include_paths
  @include_paths ||= @configs.flat_map(&:include_paths)
end

#keepObject



62
63
64
# File 'lib/leftovers/merged_config.rb', line 62

def keep
  @keep ||= MatcherBuilders::Or.build(@configs.map(&:keep))
end

#precompilersObject



54
55
56
# File 'lib/leftovers/merged_config.rb', line 54

def precompilers
  @precompilers ||= Precompilers.build(@configs.flat_map(&:precompile))
end

#test_onlyObject



66
67
68
# File 'lib/leftovers/merged_config.rb', line 66

def test_only
  @test_only ||= MatcherBuilders::Or.build(@configs.map(&:test_only))
end

#test_pathsObject



50
51
52
# File 'lib/leftovers/merged_config.rb', line 50

def test_paths
  @test_paths ||= MatcherBuilders::Path.build(@configs.flat_map(&:test_paths))
end