Class: Binary::Merge::Provider
- Inherits:
-
Object
- Object
- Binary::Merge::Provider
- Defined in:
- lib/binary/merge/provider.rb,
sig/binary/merge.rbs
Overview
Safety-first provider for opaque binary documents. rubocop:disable Metrics/ClassLength, Metrics/MethodLength, Metrics/ParameterLists -- provider operations and envelopes form one cohesive boundary
Instance Method Summary collapse
- #analyze(request) ⇒ Hash[Symbol, untyped]
- #capabilities ⇒ Hash[Symbol, untyped]
- #diff2(request) ⇒ Hash[Symbol, untyped]
- #family ⇒ String
- #merge2(request) ⇒ Hash[Symbol, untyped]
- #merge3(request) ⇒ Hash[Symbol, untyped]
- #provider_id ⇒ String
Instance Method Details
#analyze(request) ⇒ Hash[Symbol, untyped]
22 23 24 25 |
# File 'lib/binary/merge/provider.rb', line 22 def analyze(request) source = request.fetch(:source) result(:analyze, request, analysis: { bytesize: source.bytesize, binary: true }) end |
#capabilities ⇒ Hash[Symbol, untyped]
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/binary/merge/provider.rb', line 11 def capabilities { operations: Ast::Merge::ProviderContract::OPERATIONS, dialects: %i[binary], backends: %i[raw_bytes], profiles: %i[opaque_document], role: :workflow, source_preservation: %i[exact_source opaque_conflict_retains_ours] }.freeze end |
#diff2(request) ⇒ Hash[Symbol, untyped]
27 28 29 30 31 32 |
# File 'lib/binary/merge/provider.rb', line 27 def diff2(request) before = request.fetch(:before_source) after = request.fetch(:after_source) changes = before == after ? [] : [classification(before, before, after)] result(:diff2, request, changes: changes, diff: { changed: before != after }) end |
#family ⇒ String
9 |
# File 'lib/binary/merge/provider.rb', line 9 def family = 'binary' |
#merge2(request) ⇒ Hash[Symbol, untyped]
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/binary/merge/provider.rb', line 34 def merge2(request) current = request.fetch(:current_source) incoming = request.fetch(:incoming_source) rendered = render(request, :ours, current) fallback = if current == incoming [] else [{ category: :opaque_binary_preserve_current, reason: 'Opaque binary documents cannot be combined safely without a format-specific provider.' }] end result( :merge2, request, output: rendered.content, changes: current == incoming ? [] : [classification(current, current, incoming)], fallbacks: fallback, render_report: render_report(rendered, current == incoming ? :exact_revision : :preserve_current), verification: exact_verification(rendered, current) ) end |
#merge3(request) ⇒ Hash[Symbol, untyped]
57 58 59 60 61 62 63 64 65 |
# File 'lib/binary/merge/provider.rb', line 57 def merge3(request) base = request.fetch(:base_source) ours = request.fetch(:ours_source) theirs = request.fetch(:theirs_source) return exact_merge3(request, :ours, ours, base, ours, theirs) if ours == theirs || base == theirs return exact_merge3(request, :theirs, theirs, base, ours, theirs) if base == ours conflicted_merge3(request, base, ours, theirs) end |
#provider_id ⇒ String
8 |
# File 'lib/binary/merge/provider.rb', line 8 def provider_id = 'ruby.binary' |