Class: JobGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/job_generator.rb

Overview

A class for parsing a data directory and creating Job Specs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ JobGenerator

Intialize spec and previous step and set job defaults.



10
11
12
13
14
15
16
17
# File 'lib/generators/job_generator.rb', line 10

def initialize(config = {})
  @spec = {}
  config_defaults = {}
  @config = config_defaults.merge(config)
  
  @previous_step = @config['previous_step']
  @spec['method'] = @config['method'] if @config['method']
end

Instance Attribute Details

#previous_stepObject (readonly)

The spec hash of a previous step (i.e. the recon hash to build a preprocessing hash on.)



7
8
9
# File 'lib/generators/job_generator.rb', line 7

def previous_step
  @previous_step
end

#specObject (readonly)

Configuration details are put in a spec hash and used to drive processing.



5
6
7
# File 'lib/generators/job_generator.rb', line 5

def spec
  @spec
end

Instance Method Details

#config_requires(*args) ⇒ Object



19
20
21
22
23
24
# File 'lib/generators/job_generator.rb', line 19

def config_requires(*args)
  missing_args = [*args.collect { |arg| arg unless @config.has_key?(arg) }].flatten.compact
  unless missing_args.empty?
    raise DriverConfigError, "Missing Configuration for: #{missing_args.join(', ')}"
  end      
end

#spec_validates(*args) ⇒ Object



26
27
28
29
30
31
# File 'lib/generators/job_generator.rb', line 26

def spec_validates(*args)
  invalid_args = [*args.collect{ |arg| arg if eval("@spec['#{arg}'].nil?")  }].flatten.compact
  unless invalid_args.empty?
    raise DriverConfigError, "Job could not create: #{invalid_args.join(', ')}"
  end
end