Class: RightScraper::Scanners::WorkflowManifest

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

Overview

Build manifests from a filesystem.

Instance Method Summary collapse

Methods inherited from Base

#finish

Constructor Details

#initialize(*args) ⇒ WorkflowManifest

Create a new manifest scanner. Does not accept any new arguments.



32
33
34
35
# File 'lib/right_scraper/scanners/workflow_manifest.rb', line 32

def initialize(*args)
  super
  @manifest = {}
end

Instance Method Details

#begin(workflow) ⇒ Object

Retrieve relative workflow files positions

Parameters

workflow(Resources::Workflow)

Workflow whose manifest is being built



41
42
43
44
45
# File 'lib/right_scraper/scanners/workflow_manifest.rb', line 41

def begin(workflow)
  @workflow = workflow
  @metadata_filename = File.basename(@workflow.)
  @definition_filename = File.basename(@workflow.definition_path)
end

#end(resource) ⇒ Object

Complete a scan for the given resource.

Parameters ===

resource(RightScraper::Resources::Base)

resource to scan



51
52
53
54
# File 'lib/right_scraper/scanners/workflow_manifest.rb', line 51

def end(resource)
  resource.manifest = @manifest
  @manifest = {}
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 file from root of resource



64
65
66
67
68
# File 'lib/right_scraper/scanners/workflow_manifest.rb', line 64

def notice(relative_position)
  if [ @metadata_filename, @definition_filename ].include?(relative_position)
    @manifest[relative_position] = Digest::SHA1.hexdigest(yield)
  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



80
81
82
# File 'lib/right_scraper/scanners/workflow_manifest.rb', line 80

def notice_dir(relative_position)
  relative_position == nil
end