Class: Inspec::RequireLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/require_loader.rb

Defined Under Namespace

Classes: Item

Instance Method Summary collapse

Constructor Details

#initializeRequireLoader

Returns a new instance of RequireLoader.



5
6
7
# File 'lib/inspec/require_loader.rb', line 5

def initialize
  @contents = {}
end

Instance Method Details

#add(path, content, ref, line) ⇒ Object



9
10
11
# File 'lib/inspec/require_loader.rb', line 9

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

#exists?(path) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/inspec/require_loader.rb', line 21

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

#load(path) {|res| ... } ⇒ Object

Yields:

  • (res)


13
14
15
16
17
18
19
# File 'lib/inspec/require_loader.rb', line 13

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

#loaded?(path) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/inspec/require_loader.rb', line 25

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