Class: Bricolage::JobFile

Inherits:
Object
  • Object
show all
Defined in:
lib/bricolage/jobfile.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_id, values, path) ⇒ JobFile

Returns a new instance of JobFile.



82
83
84
85
86
# File 'lib/bricolage/jobfile.rb', line 82

def initialize(class_id, values, path)
  @class_id = class_id
  @values = values
  @path = Pathname(path)
end

Instance Attribute Details

#class_idObject (readonly)

Returns the value of attribute class_id.



88
89
90
# File 'lib/bricolage/jobfile.rb', line 88

def class_id
  @class_id
end

#pathObject (readonly)

Returns the value of attribute path.



90
91
92
# File 'lib/bricolage/jobfile.rb', line 90

def path
  @path
end

#valuesObject (readonly)

Returns the value of attribute values.



89
90
91
# File 'lib/bricolage/jobfile.rb', line 89

def values
  @values
end

Class Method Details

.load(ctx, path) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/bricolage/jobfile.rb', line 7

def JobFile.load(ctx, path)
  values = if /\.sql\.job\z/ =~ path.to_s
    load_embedded_definition(ctx, path)
  else
    ctx.parameter_file_loader.load_yaml(path)
  end
  parse(values, path)
end

.parse(values, path) ⇒ Object



75
76
77
78
79
80
# File 'lib/bricolage/jobfile.rb', line 75

def JobFile.parse(values, path)
  values = values.dup
  class_id = values.delete('class') or
      raise ParameterError, "missing job class: #{path}"
  new(class_id, values, path)
end

Instance Method Details

#job_idObject



92
93
94
95
# File 'lib/bricolage/jobfile.rb', line 92

def job_id
  base = @path.basename('.job').to_s
  File.basename(base, '.*')
end

#subsystemObject



97
98
99
# File 'lib/bricolage/jobfile.rb', line 97

def subsystem
  @path.parent.basename.to_s
end