Class: RightScraper::Scanners::CookbookMetadata
- Defined in:
- lib/right_scraper/scanners/cookbook_metadata.rb
Overview
Load cookbook metadata from a filesystem.
Instance Method Summary collapse
-
#begin(cookbook) ⇒ Object
Begin a scan for the given cookbook.
-
#notice(relative_position) ⇒ Object
Notice a file during scanning.
-
#notice_dir(relative_position) ⇒ Object
Notice a directory during scanning.
Methods inherited from Base
Constructor Details
This class inherits a constructor from RightScraper::Scanners::Base
Instance Method Details
#begin(cookbook) ⇒ Object
Begin a scan for the given cookbook.
Parameters
- cookbook(RightScraper::Resources::Cookbook)
-
cookbook to scan
34 35 36 |
# File 'lib/right_scraper/scanners/cookbook_metadata.rb', line 34 def begin(cookbook) @cookbook = cookbook end |
#notice(relative_position) ⇒ Object
Notice a file during scanning.
Block
Return the data for this file. We use a block because it may not always be necessary to read the data.
Parameters
- relative_position(String)
-
relative pathname for the file from root of cookbook
46 47 48 49 50 51 52 |
# File 'lib/right_scraper/scanners/cookbook_metadata.rb', line 46 def notice(relative_position) if relative_position == "metadata.json" @logger.operation(:metadata_parsing) do @cookbook. = JSON.parse(yield) end end end |
#notice_dir(relative_position) ⇒ Object
Notice a directory during scanning. Since metadata.json is by definition only in the root directory we don’t need to recurse, but we do need to go into the first directory (identified by relative_position
being nil
).
Parameters
- relative_position(String)
-
relative pathname for the directory from root of cookbook
Returns
- Boolean
-
should the scanning recurse into the directory
64 65 66 |
# File 'lib/right_scraper/scanners/cookbook_metadata.rb', line 64 def notice_dir(relative_position) relative_position == nil end |