Sha256: 0cd8936c806ab80e81079f28e5bf57495826e1fc5f847b1cbe4c4f039ca462b2

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Leftovers
  class Config
    attr_reader :name

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

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

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

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

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

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

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

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

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

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

    private

    def yaml
      @yaml ||= ::Leftovers::ConfigLoader.load(name, path: @path, content: @content)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
leftovers-0.11.1 lib/leftovers/config.rb
leftovers-0.11.0 lib/leftovers/config.rb
leftovers-0.10.0 lib/leftovers/config.rb
leftovers-0.9.0 lib/leftovers/config.rb
leftovers-0.8.0 lib/leftovers/config.rb