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.
44 45 46 47 48 49 |
# File 'lib/inspec/plugins/fetcher.rb', line 44 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.
41 42 43 |
# File 'lib/inspec/plugins/fetcher.rb', line 41 def files @files end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
42 43 44 |
# File 'lib/inspec/plugins/fetcher.rb', line 42 def prefix @prefix end |
Instance Method Details
#abs_path(file) ⇒ Object
51 52 53 54 |
# File 'lib/inspec/plugins/fetcher.rb', line 51 def abs_path(file) return nil if file.nil? prefix + file end |
#read(file) ⇒ Object
56 57 58 |
# File 'lib/inspec/plugins/fetcher.rb', line 56 def read(file) @parent.read(abs_path(file)) end |