Class: Archimate::Diff::Cli::Merge
- Inherits:
-
Object
- Object
- Archimate::Diff::Cli::Merge
- Includes:
- Logging
- Defined in:
- lib/archimate/diff/cli/merge.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#local ⇒ Object
readonly
Returns the value of attribute local.
-
#merged_file ⇒ Object
readonly
Returns the value of attribute merged_file.
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(base, local, remote, merged_file) ⇒ Merge
constructor
A new instance of Merge.
- #run_merge ⇒ Object
Constructor Details
#initialize(base, local, remote, merged_file) ⇒ Merge
Returns a new instance of Merge.
23 24 25 26 27 28 29 |
# File 'lib/archimate/diff/cli/merge.rb', line 23 def initialize(base, local, remote, merged_file) @base = base @local = local @remote = remote @merged_file = merged_file @merge = Archimate::Diff::Merge.new end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
11 12 13 |
# File 'lib/archimate/diff/cli/merge.rb', line 11 def base @base end |
#local ⇒ Object (readonly)
Returns the value of attribute local.
11 12 13 |
# File 'lib/archimate/diff/cli/merge.rb', line 11 def local @local end |
#merged_file ⇒ Object (readonly)
Returns the value of attribute merged_file.
11 12 13 |
# File 'lib/archimate/diff/cli/merge.rb', line 11 def merged_file @merged_file end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
11 12 13 |
# File 'lib/archimate/diff/cli/merge.rb', line 11 def remote @remote end |
Class Method Details
.merge(base_file, remote_file, local_file, merged_file) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/archimate/diff/cli/merge.rb', line 13 def self.merge(base_file, remote_file, local_file, merged_file) Logging.debug { "Reading base file: #{base_file}, local file: #{local_file}, remote file: #{remote_file}" } base, local, remote = Parallel.map([base_file, local_file, remote_file], in_processes: 3) do |file| Archimate.read(file) end Logging.debug { "Merged file is #{merged_file}" } Merge.new(base, local, remote, merged_file).run_merge end |
Instance Method Details
#run_merge ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/archimate/diff/cli/merge.rb', line 31 def run_merge debug { "Starting merging" } merged, conflicts = @merge.three_way(base, local, remote) # TODO: there should be no conflicts here debug do " Done merging\n \#{conflicts}\n MSG\n end\n\n File.open(merged_file, \"w\") do |file|\n # TODO: this should be controlled by the options and the defaulted to the read format\n debug { \"Serializing\" }\n Archimate::FileFormats::ArchiFileWriter.write(merged, file)\n end\nend\n" |