Class: Leftovers::Config

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, path: nil, content: nil) ⇒ Config

Returns a new instance of Config.



19
20
21
22
23
# File 'lib/leftovers/config.rb', line 19

def initialize(name, path: nil, content: nil)
  @name = name.to_sym
  @path = path
  @content = content
end

Instance Attribute Details

#nameObject (readonly) Also known as: to_sym

Returns the value of attribute name.



5
6
7
# File 'lib/leftovers/config.rb', line 5

def name
  @name
end

Class Method Details

.[](name_or_config) ⇒ Object



8
9
10
11
12
13
# File 'lib/leftovers/config.rb', line 8

def self.[](name_or_config)
  return name_or_config if name_or_config.is_a?(self)

  @loaded_configs ||= {}
  @loaded_configs[name_or_config] ||= new(name_or_config)
end

.resetObject



15
16
17
# File 'lib/leftovers/config.rb', line 15

def self.reset
  @loaded_configs = {}
end

Instance Method Details

#dynamicObject



45
46
47
# File 'lib/leftovers/config.rb', line 45

def dynamic
  @dynamic ||= ProcessorBuilders::Dynamic.build(yaml[:dynamic])
end

#exclude_pathsObject



29
30
31
# File 'lib/leftovers/config.rb', line 29

def exclude_paths
  @exclude_paths ||= Array(yaml[:exclude_paths])
end

#gemsObject



25
26
27
# File 'lib/leftovers/config.rb', line 25

def gems
  @gems ||= Array(yaml[:gems]).map(&:to_sym)
end

#include_pathsObject



33
34
35
# File 'lib/leftovers/config.rb', line 33

def include_paths
  @include_paths ||= Array(yaml[:include_paths])
end

#keepObject



49
50
51
# File 'lib/leftovers/config.rb', line 49

def keep
  @keep ||= MatcherBuilders::Node.build(yaml[:keep])
end

#precompileObject



41
42
43
# File 'lib/leftovers/config.rb', line 41

def precompile
  @precompile ||= ::Leftovers.wrap_array(yaml[:precompile])
end

#requiresObject



57
58
59
# File 'lib/leftovers/config.rb', line 57

def requires
  @requires ||= Array(yaml[:requires])
end

#test_onlyObject



53
54
55
# File 'lib/leftovers/config.rb', line 53

def test_only
  @test_only ||= MatcherBuilders::Node.build(yaml[:test_only])
end

#test_pathsObject



37
38
39
# File 'lib/leftovers/config.rb', line 37

def test_paths
  @test_paths ||= Array(yaml[:test_paths])
end