Class: Tebako::ApplicationBuildState
- Inherits:
-
Object
- Object
- Tebako::ApplicationBuildState
- Defined in:
- lib/tebako/application_build_state.rb
Overview
Skips the complete application pipeline when its final output is already current.
Constant Summary collapse
- SCHEMA_VERSION =
1
Instance Method Summary collapse
- #fetch(output) ⇒ Object
-
#initialize(cache_dir:, project_root:, metadata:, excluded: [], implementation_root: nil, stage: "application_build") ⇒ ApplicationBuildState
constructor
A new instance of ApplicationBuildState.
Constructor Details
#initialize(cache_dir:, project_root:, metadata:, excluded: [], implementation_root: nil, stage: "application_build") ⇒ ApplicationBuildState
Returns a new instance of ApplicationBuildState.
24 25 26 27 28 29 30 31 32 |
# File 'lib/tebako/application_build_state.rb', line 24 def initialize(cache_dir:, project_root:, metadata:, excluded: [], implementation_root: nil, stage: "application_build") @cache_dir = cache_dir @project_root = project_root @metadata = @excluded = excluded @implementation_root = implementation_root || File.(__dir__) @stage = stage end |
Instance Method Details
#fetch(output) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/tebako/application_build_state.rb', line 34 def fetch(output) state_path = state_path(output) FileUtils.mkdir_p(@cache_dir) File.open("#{state_path}.lock", File::RDWR | File::CREAT, 0o644) do |lock| lock.flock(File::LOCK_EX) key = build_key if current?(state_path, output, key) Tebako::BuildReporter.record( stage: @stage, status: "reused", reason: "project, runtime, options, and final package are unchanged", key: key ) return :hit end yield save(state_path, output, key) Tebako::BuildReporter.record( stage: @stage, status: "rebuilt", reason: "application build inputs or final package changed", key: key ) :miss end end |