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.
9 10 11 |
# File 'lib/inspec/require_loader.rb', line 9 def initialize @contents = {} end |
Instance Method Details
#add(path, content, ref, line) ⇒ Object
13 14 15 |
# File 'lib/inspec/require_loader.rb', line 13 def add(path, content, ref, line) @contents[path] = Item.new(content, ref, line, false) end |
#exists?(path) ⇒ Boolean
25 26 27 |
# File 'lib/inspec/require_loader.rb', line 25 def exists?(path) @contents.key?(path) end |
#load(path) {|res| ... } ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/inspec/require_loader.rb', line 17 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
29 30 31 |
# File 'lib/inspec/require_loader.rb', line 29 def loaded?(path) @contents[path].loaded == true end |