Class: Bricolage::JobFile
- Inherits:
-
Object
- Object
- Bricolage::JobFile
- Defined in:
- lib/bricolage/jobfile.rb
Instance Attribute Summary collapse
-
#class_id ⇒ Object
readonly
Returns the value of attribute class_id.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Class Method Summary collapse
Instance Method Summary collapse
- #global_variables ⇒ Object
-
#initialize(class_id, values, path) ⇒ JobFile
constructor
A new instance of JobFile.
- #job_id ⇒ Object
- #subsystem ⇒ Object
Constructor Details
#initialize(class_id, values, path) ⇒ JobFile
Returns a new instance of JobFile.
112 113 114 115 116 |
# File 'lib/bricolage/jobfile.rb', line 112 def initialize(class_id, values, path) @class_id = class_id @values = values @path = Pathname(path) end |
Instance Attribute Details
#class_id ⇒ Object (readonly)
Returns the value of attribute class_id.
118 119 120 |
# File 'lib/bricolage/jobfile.rb', line 118 def class_id @class_id end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
120 121 122 |
# File 'lib/bricolage/jobfile.rb', line 120 def path @path end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
119 120 121 |
# File 'lib/bricolage/jobfile.rb', line 119 def values @values end |
Class Method Details
.load(ctx, path) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bricolage/jobfile.rb', line 8 def JobFile.load(ctx, path) values = case path.to_s when /\.sql\.job\z/ (ctx, path) when /\.(?:rb|py|sh)\.job\z/ (ctx, path) else ctx.parameter_file_loader.load_yaml(path) end parse(values, path) end |
.parse(values, path) ⇒ Object
105 106 107 108 109 110 |
# File 'lib/bricolage/jobfile.rb', line 105 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
#global_variables ⇒ Object
131 132 133 134 135 |
# File 'lib/bricolage/jobfile.rb', line 131 def global_variables { 'script' => @path.to_s } end |
#job_id ⇒ Object
122 123 124 125 |
# File 'lib/bricolage/jobfile.rb', line 122 def job_id base = @path.basename('.job').to_s File.basename(base, '.*') end |
#subsystem ⇒ Object
127 128 129 |
# File 'lib/bricolage/jobfile.rb', line 127 def subsystem @path.parent.basename.to_s end |