Class: Inspec::Plugins::RelFetcher
- Inherits:
-
Fetcher
- Object
- PluginRegistry::Plugin
- Fetcher
- Inspec::Plugins::RelFetcher
- Defined in:
- lib/inspec/plugins/fetcher.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Attributes inherited from PluginRegistry::Plugin
Instance Method Summary collapse
- #abs_path(file) ⇒ Object
-
#initialize(fetcher) ⇒ RelFetcher
constructor
A new instance of RelFetcher.
- #read(file) ⇒ Object
Methods inherited from Fetcher
plugin_registry, #relative_target
Methods inherited from PluginRegistry::Plugin
name, plugin_registry, priority, resolve, resolve_next
Constructor Details
#initialize(fetcher) ⇒ RelFetcher
Returns a new instance of RelFetcher.
45 46 47 48 49 50 |
# File 'lib/inspec/plugins/fetcher.rb', line 45 def initialize(fetcher) @parent = fetcher @prefix = get_prefix(fetcher.files) @files = fetcher.files.find_all { |x| x.start_with? prefix } .map { |x| x[prefix.length..-1] } end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
42 43 44 |
# File 'lib/inspec/plugins/fetcher.rb', line 42 def files @files end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
43 44 45 |
# File 'lib/inspec/plugins/fetcher.rb', line 43 def prefix @prefix end |
Instance Method Details
#abs_path(file) ⇒ Object
52 53 54 55 |
# File 'lib/inspec/plugins/fetcher.rb', line 52 def abs_path(file) return nil if file.nil? prefix + file end |
#read(file) ⇒ Object
57 58 59 |
# File 'lib/inspec/plugins/fetcher.rb', line 57 def read(file) @parent.read(abs_path(file)) end |