Module: Grably::Job::InstanceMethods
- Defined in:
- lib/grably/job/instance.rb
Overview
rubocop:disable Metrics/ModuleLength, Style/Documentation
Instance Method Summary collapse
-
#changed? ⇒ Boolean
When job is changed it need to be reevaluated so build method will be launched.
-
#clean ⇒ Object
Celans job state by removing all files from working directory.
-
#incremental? ⇒ Boolean
If job contains incremental srcs it is incremental.
- #job_dir(path = nil) ⇒ Object
- #meta ⇒ Object
-
#run(task, working_dir, *args) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize.
-
#stateful? ⇒ Boolean
Means that job has state which can be tracked between launches.
Instance Method Details
#changed? ⇒ Boolean
When job is changed it need to be reevaluated so build method will be launched. If job remains unchanged previous result will be returned
27 28 29 |
# File 'lib/grably/job/instance.rb', line 27 def changed? @changed end |
#clean ⇒ Object
Celans job state by removing all files from working directory
53 54 55 |
# File 'lib/grably/job/instance.rb', line 53 def clean FileUtils.rm_rf(Dir[File.join(@job_dir, '*')]) end |
#incremental? ⇒ Boolean
If job contains incremental srcs it is incremental. Incremental job does not clean self state between launches. It should be managed by user.
40 41 42 |
# File 'lib/grably/job/instance.rb', line 40 def incremental? @job_args.any? { |_name, desc| desc.first == :isrc } end |
#job_dir(path = nil) ⇒ Object
44 45 46 |
# File 'lib/grably/job/instance.rb', line 44 def job_dir(path = nil) path.nil? ? @job_dir : File.join(@job_dir, path) end |
#meta ⇒ Object
48 49 50 |
# File 'lib/grably/job/instance.rb', line 48 def @manifest. end |
#run(task, working_dir, *args) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/grably/job/instance.rb', line 4 def run(task, working_dir, *args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize prepare(task, working_dir) initialize_state(*args) if stateful? if changed? clean unless incremental? log " * [#{self.class.job_call_name}] building" result = @manifest.result = Grably::Core::Product.(build) @manifest.dump else log " * [#{self.class.job_call_name}] uptodate" result = @manifest.result end result rescue StandardError => err # If any error occured this will force rebuild on next run @manifest.remove if @manifest raise(err) end |
#stateful? ⇒ Boolean
Means that job has state which can be tracked between launches. If job is stateless it always changed.
33 34 35 |
# File 'lib/grably/job/instance.rb', line 33 def stateful? @stateful end |