Class: RightScraper::Scanners::WorkflowMetadata

Inherits:
Base
  • Object
show all
Defined in:
lib/right_scraper/scanners/workflow_metadata.rb

Overview

Load workflow metadata from a filesystem.

Instance Method Summary collapse

Methods inherited from Base

#end, #finish, #initialize

Constructor Details

This class inherits a constructor from RightScraper::Scanners::Base

Instance Method Details

#begin(workflow) ⇒ Object

Begin a scan for the given workflow.

Parameters

workflow(RightScraper::Resources::Workflow)

workflow to scan



34
35
36
37
# File 'lib/right_scraper/scanners/workflow_metadata.rb', line 34

def begin(workflow)
  @workflow = workflow
  @metadata_filename = File.basename(workflow.)
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 workflow



47
48
49
50
51
52
53
# File 'lib/right_scraper/scanners/workflow_metadata.rb', line 47

def notice(relative_position)
  if relative_position == @metadata_filename
    @logger.operation(:metadata_parsing) do
      @workflow. = JSON.parse(yield)
    end
  end
end

#notice_dir(relative_position) ⇒ Object

Notice a directory during scanning. Since the workflow definition and metadata live 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 workflow

Returns

Boolean

should the scanning recurse into the directory



65
66
67
# File 'lib/right_scraper/scanners/workflow_metadata.rb', line 65

def notice_dir(relative_position)
  relative_position == nil
end