Sha256: b53a01e54cb7482fbb732d0c1f579503cd480aeaf81b95a4175d1f0210136dd2

Contents?: true

Size: 651 Bytes

Versions: 6

Compression:

Stored size: 651 Bytes

Contents

# encoding: utf-8
# author: Dominik Richter
# author: Christoph Hartmann

module Inspec
  class RequireLoader
    Item = Struct.new(:content, :ref, :line, :loaded)

    def initialize
      @contents = {}
    end

    def add(path, content, ref, line)
      @contents[path] = Item.new(content, ref, line, false)
    end

    def load(path)
      c = @contents[path]
      c.loaded = true
      res = [c.content, c.ref, c.line || 1]
      yield res if block_given?
      res
    end

    def exists?(path)
      @contents.key?(path)
    end

    def loaded?(path)
      @contents[path].loaded == true
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
inspec-2.1.81 lib/inspec/require_loader.rb
inspec-2.1.21 lib/inspec/require_loader.rb
inspec-2.1.10 lib/inspec/require_loader.rb
inspec-2.0.32 lib/inspec/require_loader.rb
inspec-2.0.17 lib/inspec/require_loader.rb
inspec-1.51.15 lib/inspec/require_loader.rb