Class: Inspec::RequireLoader
- Inherits:
-
Object
- Object
- Inspec::RequireLoader
- Defined in:
- lib/inspec/require_loader.rb
Defined Under Namespace
Classes: Item
Instance Method Summary collapse
- #add(path, content, ref, line) ⇒ Object
- #exists?(path) ⇒ Boolean
-
#initialize ⇒ RequireLoader
constructor
A new instance of RequireLoader.
- #load(path) {|res| ... } ⇒ Object
- #loaded?(path) ⇒ Boolean
Constructor Details
#initialize ⇒ RequireLoader
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
21 22 23 |
# File 'lib/inspec/require_loader.rb', line 21 def exists?(path) @contents.key?(path) end |
#load(path) {|res| ... } ⇒ Object
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
25 26 27 |
# File 'lib/inspec/require_loader.rb', line 25 def loaded?(path) @contents[path].loaded == true end |