archimate 1.1.1 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -47
- data/lib/archimate.rb +0 -11
- data/lib/archimate/cli/archi.rb +0 -8
- data/lib/archimate/data_model/diffable_array.rb +64 -64
- data/lib/archimate/version.rb +1 -1
- metadata +2 -32
- data/exe/archidiff +0 -7
- data/exe/archidiff-summary +0 -7
- data/exe/archimerge +0 -7
- data/exe/fmtxml +0 -7
- data/lib/archimate/cli/conflict_resolver.rb +0 -39
- data/lib/archimate/cli/diff.rb +0 -31
- data/lib/archimate/cli/diff_summary.rb +0 -101
- data/lib/archimate/cli/merge.rb +0 -49
- data/lib/archimate/cli/merger.rb +0 -109
- data/lib/archimate/diff.rb +0 -17
- data/lib/archimate/diff/archimate_array_reference.rb +0 -113
- data/lib/archimate/diff/archimate_identified_node_reference.rb +0 -41
- data/lib/archimate/diff/archimate_node_attribute_reference.rb +0 -70
- data/lib/archimate/diff/archimate_node_reference.rb +0 -80
- data/lib/archimate/diff/change.rb +0 -49
- data/lib/archimate/diff/conflict.rb +0 -31
- data/lib/archimate/diff/conflicts.rb +0 -89
- data/lib/archimate/diff/conflicts/base_conflict.rb +0 -53
- data/lib/archimate/diff/conflicts/deleted_items_child_updated_conflict.rb +0 -30
- data/lib/archimate/diff/conflicts/deleted_items_referenced_conflict.rb +0 -63
- data/lib/archimate/diff/conflicts/path_conflict.rb +0 -51
- data/lib/archimate/diff/delete.rb +0 -41
- data/lib/archimate/diff/difference.rb +0 -113
- data/lib/archimate/diff/insert.rb +0 -43
- data/lib/archimate/diff/merge.rb +0 -70
- data/lib/archimate/diff/move.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb777d171110c638d84d1e51687d52cde0fa7270
|
4
|
+
data.tar.gz: 262cdd92904cbe280e73f21cf55082221621f4da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b432f2cf362430029f3a15446e0173ebcbedf7d6aac18ffde1b4ef9d280eba8f454e283a2ad511eeb4724b15501a0a1c8c831034cab80328c31b6fdcc8b780d
|
7
|
+
data.tar.gz: 29d7c8bf731ea8bc755b15e3282efadfd38ec14ca1d1a8bdde9b649ce15e5326c5f90e21a64742d03f01e1c1e1d20f9181a34a0c78c00bc3663bf5b8e72ec24f
|
data/README.md
CHANGED
@@ -32,57 +32,10 @@ command | description
|
|
32
32
|
`archimate convert ARCHIFILE` | Convert the incoming file to the desired type
|
33
33
|
`archimate dedupe ARCHIFILE` | de-duplicate elements in Archi file
|
34
34
|
`archimate map ARCHIFILE` | *EXPERIMENTAL:* Produce a map of diagram links to a diagram
|
35
|
-
`archimate merge ARCHIFILE1 ARCHIFILE2` | *EXPERIMENTAL:*Merge two archimate files
|
36
35
|
`archimate project ARCHIFILE PROJECTFILE` | *EXPERIMENTAL:*Synchronize an Archi file and an MSProject XML file
|
37
36
|
`archimate svg ARCHIFILE` | Produce semantically meaningful SVG files from an Archi file
|
38
37
|
`archimate lint ARCHIFILE` | Produce a report of warnings and issues in the Archi file
|
39
38
|
|
40
|
-
### archidiff & archimerge
|
41
|
-
|
42
|
-
Archidiff is a set of tools to help with versioning an `.archimate` file from Archi in a version control system (like git). Eventually I want to provide diff and (3-way) merge tools that understand how *Archi* files are structured and avoid problems that happen when multiple people collaborate on a model.
|
43
|
-
|
44
|
-
To enable using these from the command line git, add these lines to your `~/.gitconfig` replacing `{PATH_TO_ARCHIDIFF}` with the path to the archidiff binaries.
|
45
|
-
|
46
|
-
```
|
47
|
-
[difftool "archidiff"]
|
48
|
-
cmd = {PATH_TO_ARCHIDIFF}/archidiff $LOCAL $REMOTE
|
49
|
-
|
50
|
-
[difftool "archidiff-summary"]
|
51
|
-
cmd = {PATH_TO_ARCHIDIFF}/archidiff-summary $LOCAL $REMOTE
|
52
|
-
|
53
|
-
[mergetool "archimerge"]
|
54
|
-
cmd = {PATH_TO_ARCHIDIFF}/archimerge $PWD/$BASE $PWD/$REMOTE $PWD/$LOCAL $PWD/$MERGED
|
55
|
-
trustExitCode = false
|
56
|
-
```
|
57
|
-
|
58
|
-
Then to use the tool for diffing you can do this:
|
59
|
-
|
60
|
-
```sh
|
61
|
-
git difftool --tool archidiff 833cbb7 HEAD -- path_to/my.archimate
|
62
|
-
```
|
63
|
-
|
64
|
-
or to see a summary of what changed between versions:
|
65
|
-
|
66
|
-
```sh
|
67
|
-
git difftool --tool archidiff-summary 833cbb7 HEAD -- path_to/my.archimate
|
68
|
-
```
|
69
|
-
|
70
|
-
Finally, if you have a merge conflict, you can use archimerge to help make the merge sane:
|
71
|
-
|
72
|
-
```sh
|
73
|
-
git mergetool --tool archimerge -- path_to/my.archimate
|
74
|
-
```
|
75
|
-
|
76
|
-
### fmtxml
|
77
|
-
|
78
|
-
Can be used as a `textconv` filter in .gitconfig to pre-format files for better diff use (for visual scanning). You'd set this up in your `$HOME/.gitconfig` file like this.
|
79
|
-
|
80
|
-
```
|
81
|
-
[diff "archimate"]
|
82
|
-
textconv = fmtxml
|
83
|
-
cachetextconv = true
|
84
|
-
```
|
85
|
-
|
86
39
|
## Development
|
87
40
|
|
88
41
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/archimate.rb
CHANGED
@@ -19,15 +19,10 @@ module Archimate
|
|
19
19
|
module Cli
|
20
20
|
autoload :Archi, 'archimate/cli/archi'
|
21
21
|
autoload :Cleanup, 'archimate/cli/cleanup'
|
22
|
-
autoload :ConflictResolver, 'archimate/cli/conflict_resolver'
|
23
22
|
autoload :Convert, 'archimate/cli/convert'
|
24
|
-
autoload :Diff, 'archimate/cli/diff'
|
25
|
-
autoload :DiffSummary, 'archimate/cli/diff_summary'
|
26
23
|
autoload :Duper, 'archimate/cli/duper'
|
27
24
|
autoload :Lint, 'archimate/cli/lint'
|
28
25
|
autoload :Mapper, 'archimate/cli/mapper'
|
29
|
-
autoload :Merge, 'archimate/cli/merge'
|
30
|
-
autoload :Merger, 'archimate/cli/merger'
|
31
26
|
autoload :Stats, 'archimate/cli/stats'
|
32
27
|
autoload :Svger, 'archimate/cli/svger'
|
33
28
|
end
|
@@ -86,12 +81,6 @@ module Archimate
|
|
86
81
|
require "archimate/logging"
|
87
82
|
require "archimate/color"
|
88
83
|
require 'archimate/data_model'
|
89
|
-
require 'archimate/diff'
|
90
|
-
|
91
|
-
# Computes the set of differences between base and remote models
|
92
|
-
def self.diff(base, remote)
|
93
|
-
base.diff(remote)
|
94
|
-
end
|
95
84
|
|
96
85
|
# Reads the given file and returns the Archimate model
|
97
86
|
#
|
data/lib/archimate/cli/archi.rb
CHANGED
@@ -47,14 +47,6 @@ module Archimate
|
|
47
47
|
).map
|
48
48
|
end
|
49
49
|
|
50
|
-
desc "merge ARCHIFILE1 ARCHIFILE2", "EXPERIMENTAL: Merge two archimate files"
|
51
|
-
option :output,
|
52
|
-
aliases: :o,
|
53
|
-
desc: "Write output to FILE instead of stdout."
|
54
|
-
def merge(archifile1, archifile2)
|
55
|
-
Archimate::Cli::Merger.new.merge_files(archifile1, archifile2)
|
56
|
-
end
|
57
|
-
|
58
50
|
desc "svg -o OUTPUTDIR ARCHIFILE", "IN DEVELOPMENT: Produce semantically meaningful SVG files from an Archi file"
|
59
51
|
option :output,
|
60
52
|
aliases: :o,
|
@@ -32,72 +32,72 @@ module Archimate
|
|
32
32
|
false
|
33
33
|
end
|
34
34
|
|
35
|
-
def diff(other)
|
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
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
35
|
+
# def diff(other)
|
36
|
+
# raise TypeError, "Expected other #{other.class} to be of type #{self.class}" unless other.is_a?(self.class)
|
37
|
+
# raise "Well Hell other #{other.path} in_model is nil" if other.in_model.nil?
|
38
|
+
# raise "Well Hell my path `#{path}` in_model is nil" if in_model.nil?
|
39
|
+
|
40
|
+
# result = []
|
41
|
+
# remaining_content = Array.new(self) # TODO: I want a copy of the array, not a deep clone
|
42
|
+
# other_enum = other.each_with_index
|
43
|
+
|
44
|
+
# loop do
|
45
|
+
# if other_enum.peek[0] == remaining_content[0]
|
46
|
+
# other_enum.next
|
47
|
+
# remaining_content.shift
|
48
|
+
# elsif items_are_changed?(other, other_enum, remaining_content)
|
49
|
+
# result.concat(compute_item_changes(other, other_enum, self, remaining_content[0]))
|
50
|
+
# remaining_content.shift
|
51
|
+
# other_enum.next
|
52
|
+
# elsif !remaining_content.empty? && !other.smart_include?(remaining_content[0])
|
53
|
+
# result << Diff::Delete.new(Diff::ArchimateArrayReference.new(self, smart_find(remaining_content[0])))
|
54
|
+
# remaining_content.shift
|
55
|
+
# elsif !smart_include?(other_enum.peek[0])
|
56
|
+
# result << Diff::Insert.new(Diff::ArchimateArrayReference.new(other, other_enum.next[1]))
|
57
|
+
# elsif smart_include?(other_enum.peek[0])
|
58
|
+
# result << Diff::Move.new(
|
59
|
+
# Diff::ArchimateArrayReference.new(other, other_enum.peek[1]),
|
60
|
+
# Diff::ArchimateArrayReference.new(self, smart_find(other_enum.peek[0]))
|
61
|
+
# )
|
62
|
+
# remaining_item_idx = remaining_content.smart_find(other_enum.peek[0])
|
63
|
+
# if remaining_item_idx
|
64
|
+
# result.concat(compute_item_changes(other, other_enum, self, remaining_content[remaining_item_idx]))
|
65
|
+
# remaining_content.delete_at(remaining_item_idx) if remaining_content.smart_include?(other_enum.peek[0])
|
66
|
+
# end
|
67
|
+
# other_enum.next
|
68
|
+
# else
|
69
|
+
# raise "Unhandled diff case for remaining_content: #{remaining_content[0]} and #{other_enum.peek[0]}"
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
|
73
|
+
# result.concat(
|
74
|
+
# remaining_content
|
75
|
+
# .reject { |item| other.include?(item) }
|
76
|
+
# .map do |item|
|
77
|
+
# Diff::Delete.new(Diff::ArchimateArrayReference.new(self, find_index(item)))
|
78
|
+
# end
|
79
|
+
# )
|
80
|
+
# end
|
81
81
|
|
82
82
|
# TODO: This may not continue to live here. Only used by testing.
|
83
|
-
def patch(diffs)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
end
|
83
|
+
# def patch(diffs)
|
84
|
+
# # TODO: Beware, order of diffs could break patching at the moment.
|
85
|
+
# Array(diffs).each do |diff|
|
86
|
+
# case diff
|
87
|
+
# when Diff::Delete
|
88
|
+
# delete_at(smart_find(diff.target.value))
|
89
|
+
# when Diff::Insert
|
90
|
+
# insert(diff.target.array_index, diff.target.value)
|
91
|
+
# when Diff::Change
|
92
|
+
# self[smart_find(diff.changed_from.value)] = diff.target.value
|
93
|
+
# when Diff::Move
|
94
|
+
# insert(diff.target.array_index, delete_at(smart_find(diff.target.value)))
|
95
|
+
# else
|
96
|
+
# raise "Unexpected diff type: #{diff.class}"
|
97
|
+
# end
|
98
|
+
# end
|
99
|
+
# self
|
100
|
+
# end
|
101
101
|
|
102
102
|
def items_are_changed?(other, other_enum, remaining)
|
103
103
|
!remaining.empty? &&
|
data/lib/archimate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: archimate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Morga
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -379,11 +379,7 @@ email:
|
|
379
379
|
- markmorga@gmail.com
|
380
380
|
- mmorga@rackspace.com
|
381
381
|
executables:
|
382
|
-
- archidiff
|
383
|
-
- archidiff-summary
|
384
382
|
- archimate
|
385
|
-
- archimerge
|
386
|
-
- fmtxml
|
387
383
|
extensions: []
|
388
384
|
extra_rdoc_files: []
|
389
385
|
files:
|
@@ -402,23 +398,14 @@ files:
|
|
402
398
|
- bin/archimate
|
403
399
|
- bin/console
|
404
400
|
- bin/setup
|
405
|
-
- exe/archidiff
|
406
|
-
- exe/archidiff-summary
|
407
401
|
- exe/archimate
|
408
|
-
- exe/archimerge
|
409
|
-
- exe/fmtxml
|
410
402
|
- lib/archimate.rb
|
411
403
|
- lib/archimate/cli/archi.rb
|
412
404
|
- lib/archimate/cli/cleanup.rb
|
413
|
-
- lib/archimate/cli/conflict_resolver.rb
|
414
405
|
- lib/archimate/cli/convert.rb
|
415
|
-
- lib/archimate/cli/diff.rb
|
416
|
-
- lib/archimate/cli/diff_summary.rb
|
417
406
|
- lib/archimate/cli/duper.rb
|
418
407
|
- lib/archimate/cli/lint.rb
|
419
408
|
- lib/archimate/cli/mapper.rb
|
420
|
-
- lib/archimate/cli/merge.rb
|
421
|
-
- lib/archimate/cli/merger.rb
|
422
409
|
- lib/archimate/cli/stats.rb
|
423
410
|
- lib/archimate/cli/svger.rb
|
424
411
|
- lib/archimate/color.rb
|
@@ -458,23 +445,6 @@ files:
|
|
458
445
|
- lib/archimate/data_model/view_concept.rb
|
459
446
|
- lib/archimate/data_model/view_node.rb
|
460
447
|
- lib/archimate/data_model/viewpoint.rb
|
461
|
-
- lib/archimate/diff.rb
|
462
|
-
- lib/archimate/diff/archimate_array_reference.rb
|
463
|
-
- lib/archimate/diff/archimate_identified_node_reference.rb
|
464
|
-
- lib/archimate/diff/archimate_node_attribute_reference.rb
|
465
|
-
- lib/archimate/diff/archimate_node_reference.rb
|
466
|
-
- lib/archimate/diff/change.rb
|
467
|
-
- lib/archimate/diff/conflict.rb
|
468
|
-
- lib/archimate/diff/conflicts.rb
|
469
|
-
- lib/archimate/diff/conflicts/base_conflict.rb
|
470
|
-
- lib/archimate/diff/conflicts/deleted_items_child_updated_conflict.rb
|
471
|
-
- lib/archimate/diff/conflicts/deleted_items_referenced_conflict.rb
|
472
|
-
- lib/archimate/diff/conflicts/path_conflict.rb
|
473
|
-
- lib/archimate/diff/delete.rb
|
474
|
-
- lib/archimate/diff/difference.rb
|
475
|
-
- lib/archimate/diff/insert.rb
|
476
|
-
- lib/archimate/diff/merge.rb
|
477
|
-
- lib/archimate/diff/move.rb
|
478
448
|
- lib/archimate/export/csv_export.rb
|
479
449
|
- lib/archimate/export/cypher.rb
|
480
450
|
- lib/archimate/export/graph_ml.rb
|
data/exe/archidiff
DELETED
data/exe/archidiff-summary
DELETED
data/exe/archimerge
DELETED
data/exe/fmtxml
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "highline"
|
4
|
-
|
5
|
-
module Archimate
|
6
|
-
module Cli
|
7
|
-
class ConflictResolver
|
8
|
-
def initialize
|
9
|
-
@config = Config.instance
|
10
|
-
# TODO: pull the stdin/stdout from the app config
|
11
|
-
@hl = HighLine.new(STDIN, STDOUT)
|
12
|
-
end
|
13
|
-
|
14
|
-
# TODO: this implementation has much to be written
|
15
|
-
def resolve(conflict)
|
16
|
-
return [] unless @config.interactive
|
17
|
-
base_local_diffs = conflict.base_local_diffs
|
18
|
-
base_remote_diffs = conflict.base_remote_diffs
|
19
|
-
choice = @hl.choose do |menu|
|
20
|
-
menu.prompt = conflict
|
21
|
-
menu.choice(:local, text: base_local_diffs.map(&:to_s).join("\n\t\t"))
|
22
|
-
menu.choice(:remote, text: base_remote_diffs.map(&:to_s).join("\n\t\t"))
|
23
|
-
# menu.choice(:neither, help: "Don't choose either set of diffs")
|
24
|
-
# menu.choice(:edit, help: "Edit the diffs (coming soon)")
|
25
|
-
# menu.choice(:quit, help: "I'm in over my head. Just stop!")
|
26
|
-
menu.select_by = :index_or_name
|
27
|
-
end
|
28
|
-
case choice
|
29
|
-
when :local
|
30
|
-
base_local_diffs
|
31
|
-
when :remote
|
32
|
-
base_remote_diffs
|
33
|
-
else
|
34
|
-
error "Unexpected choice #{choice.inspect}."
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/lib/archimate/cli/diff.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Archimate
|
3
|
-
module Cli
|
4
|
-
class Diff
|
5
|
-
attr_reader :local, :remote
|
6
|
-
|
7
|
-
def self.diff(local_file, remote_file)
|
8
|
-
local = Archimate.read(local_file)
|
9
|
-
remote = Archimate.read(remote_file)
|
10
|
-
|
11
|
-
my_diff = Diff.new(local, remote)
|
12
|
-
my_diff.diff
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize(local, remote)
|
16
|
-
@local = local
|
17
|
-
@remote = remote
|
18
|
-
end
|
19
|
-
|
20
|
-
def diff
|
21
|
-
diffs = Archimate.diff(local, remote)
|
22
|
-
|
23
|
-
diffs.each { |d| puts d }
|
24
|
-
|
25
|
-
puts "\n\n#{diffs.size} Differences"
|
26
|
-
|
27
|
-
diffs
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'forwardable'
|
3
|
-
|
4
|
-
module Archimate
|
5
|
-
module Cli
|
6
|
-
class DiffSummary
|
7
|
-
using DataModel::DiffableArray
|
8
|
-
using DataModel::DiffablePrimitive
|
9
|
-
|
10
|
-
DIFF_KINDS = %w(Delete Change Insert).freeze
|
11
|
-
|
12
|
-
attr_reader :local, :remote
|
13
|
-
|
14
|
-
def self.diff(local_file, remote_file, options = { verbose: true })
|
15
|
-
logger.info "Reading #{local_file}"
|
16
|
-
local = Archimate.read(local_file)
|
17
|
-
logger.info "Reading #{remote_file}"
|
18
|
-
remote = Archimate.read(remote_file)
|
19
|
-
|
20
|
-
my_diff = DiffSummary.new(local, remote)
|
21
|
-
my_diff.diff
|
22
|
-
end
|
23
|
-
|
24
|
-
def initialize(local, remote)
|
25
|
-
@local = local
|
26
|
-
@remote = remote
|
27
|
-
@summary = Hash.new { |hash, key| hash[key] = Hash.new { |k_hash, k_key| k_hash[k_key] = 0 } }
|
28
|
-
end
|
29
|
-
|
30
|
-
def diff
|
31
|
-
logger.info "Calculating differences"
|
32
|
-
diffs = Archimate.diff(local, remote)
|
33
|
-
|
34
|
-
puts Color.color("Summary of differences", :headline)
|
35
|
-
puts "\n"
|
36
|
-
|
37
|
-
summary_element_diffs = diffs.group_by { |diff| diff.summary_element.class.to_s.split("::").last }
|
38
|
-
summarize_elements summary_element_diffs["Element"]
|
39
|
-
summarize "Organization", summary_element_diffs["Organization"]
|
40
|
-
summarize "Relationship", summary_element_diffs["Relationship"]
|
41
|
-
summarize_diagrams summary_element_diffs["Diagram"]
|
42
|
-
|
43
|
-
puts "Total Diffs: #{diffs.size}"
|
44
|
-
end
|
45
|
-
|
46
|
-
def summarize(title, diffs)
|
47
|
-
return if diffs.nil? || diffs.empty?
|
48
|
-
by_kind = diffs_by_kind(diffs)
|
49
|
-
|
50
|
-
puts color(title)
|
51
|
-
DIFF_KINDS.each do |kind|
|
52
|
-
puts format(" #{color(kind)}: #{by_kind[kind]&.size}") if by_kind.key?(kind)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def diffs_by_kind(diffs)
|
57
|
-
diffs
|
58
|
-
.group_by(&:summary_element)
|
59
|
-
.each_with_object(Hash.new { |hash, key| hash[key] = [] }) do |(summary_element, element_diffs), a|
|
60
|
-
top_level_diff = element_diffs.find { |diff| summary_element == diff.target.value }
|
61
|
-
if top_level_diff
|
62
|
-
a[top_level_diff.kind] << summary_element
|
63
|
-
else
|
64
|
-
a["Change"] << summary_element
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def summarize_elements(diffs)
|
70
|
-
return if diffs.nil? || diffs.empty?
|
71
|
-
puts Color.color("Elements", :headline)
|
72
|
-
by_layer = diffs.group_by { |diff| diff.summary_element.layer }
|
73
|
-
summarize "Business", by_layer["Business"]
|
74
|
-
summarize "Application", by_layer["Application"]
|
75
|
-
summarize "Technology", by_layer["Technology"]
|
76
|
-
summarize "Motivation", by_layer["Motivation"]
|
77
|
-
summarize "Implementation and Migration", by_layer["Implementation and Migration"]
|
78
|
-
summarize "Connectors", by_layer["Connectors"]
|
79
|
-
end
|
80
|
-
|
81
|
-
def summarize_diagrams(diffs)
|
82
|
-
return if diffs.nil? || diffs.empty?
|
83
|
-
puts Color.color("Diagrams", :headline)
|
84
|
-
|
85
|
-
by_kind = diffs_by_kind(diffs)
|
86
|
-
%w(Delete Change Insert).each do |kind|
|
87
|
-
next unless by_kind.key?(kind)
|
88
|
-
diagram_names = by_kind[kind].uniq.map(&:name)
|
89
|
-
puts " #{color(kind)}"
|
90
|
-
# TODO: make this magic number an option
|
91
|
-
diagram_names[0..14].each { |diagram_name| puts " #{diagram_name}" }
|
92
|
-
puts " ... and #{diagram_names.size - 15} more" if diagram_names.size > 15
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def color(kind)
|
97
|
-
Color.color(kind, kind)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|