Class: Grably::Job::Manifest
- Inherits:
-
Object
- Object
- Grably::Job::Manifest
- Defined in:
- lib/grably/job/manifest.rb
Overview
Manifest file with job data. Manifest keeps information about previous run including passed arguments and output file digests
Constant Summary collapse
- MANIFEST =
Manifest file location relative to jobdir
'.manifest'.freeze
Instance Attribute Summary collapse
-
#manifest_file ⇒ Object
readonly
Returns the value of attribute manifest_file.
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(job_dir) ⇒ Manifest
constructor
A new instance of Manifest.
- #load ⇒ Object
- #meta ⇒ Object
- #remove ⇒ Object
- #result ⇒ Object
- #result=(products) ⇒ Object
-
#update(name, type, value, update_hook) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize.
Constructor Details
Instance Attribute Details
#manifest_file ⇒ Object (readonly)
Returns the value of attribute manifest_file.
12 13 14 |
# File 'lib/grably/job/manifest.rb', line 12 def manifest_file @manifest_file end |
Instance Method Details
#dump ⇒ Object
58 59 60 |
# File 'lib/grably/job/manifest.rb', line 58 def dump save_obj(manifest_file, @data) end |
#load ⇒ Object
54 55 56 |
# File 'lib/grably/job/manifest.rb', line 54 def load @data = load_obj(manifest_file) if File.exist?(manifest_file) end |
#meta ⇒ Object
46 47 48 |
# File 'lib/grably/job/manifest.rb', line 46 def @data. end |
#remove ⇒ Object
62 63 64 |
# File 'lib/grably/job/manifest.rb', line 62 def remove FileUtils.rm_f(manifest_file) end |
#result ⇒ Object
50 51 52 |
# File 'lib/grably/job/manifest.rb', line 50 def result @data.result.first end |
#result=(products) ⇒ Object
41 42 43 44 |
# File 'lib/grably/job/manifest.rb', line 41 def result=(products) digests = Grably::Digest.digest(*products) @data.result = [products, digests] end |
#update(name, type, value, update_hook) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/grably/job/manifest.rb', line 20 def update(name, type, value, update_hook) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize case type when :src old_value, old_digest = @data.src[name] new_digest = Grably::Digest.digest(value).first when :srcs old_value, old_digest = @data.srcs[name] new_digest = Grably::Digest.digest(*value) when :opt old_value, _old_digest = @data.opt[name] old_digest = nil new_digest = nil else raise ArgumentError, 'Invalid type: ' + type end @data.send(type)[name] = [value, new_digest] update_hook.call(name, type, old_value, old_digest, value, new_digest) [old_value, old_digest] end |