archimate 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/archimate.gemspec +2 -1
  3. data/lib/archimate/color.rb +2 -2
  4. data/lib/archimate/data_model/any_attribute.rb +4 -10
  5. data/lib/archimate/data_model/any_element.rb +9 -17
  6. data/lib/archimate/data_model/bounds.rb +6 -6
  7. data/lib/archimate/data_model/color.rb +6 -6
  8. data/lib/archimate/data_model/comparison.rb +101 -5
  9. data/lib/archimate/data_model/concern.rb +5 -13
  10. data/lib/archimate/data_model/connection.rb +39 -48
  11. data/lib/archimate/data_model/connector_type.rb +1 -0
  12. data/lib/archimate/data_model/diagram.rb +27 -42
  13. data/lib/archimate/data_model/diagram_type.rb +1 -0
  14. data/lib/archimate/data_model/element.rb +14 -35
  15. data/lib/archimate/data_model/elements.rb +681 -0
  16. data/lib/archimate/data_model/font.rb +8 -8
  17. data/lib/archimate/data_model/lang_string.rb +10 -36
  18. data/lib/archimate/data_model/layer.rb +4 -5
  19. data/lib/archimate/data_model/layers.rb +45 -49
  20. data/lib/archimate/data_model/location.rb +6 -6
  21. data/lib/archimate/data_model/metadata.rb +2 -6
  22. data/lib/archimate/data_model/model.rb +50 -62
  23. data/lib/archimate/data_model/modeling_note.rb +3 -8
  24. data/lib/archimate/data_model/organization.rb +18 -27
  25. data/lib/archimate/data_model/property.rb +9 -8
  26. data/lib/archimate/data_model/property_definition.rb +15 -21
  27. data/lib/archimate/data_model/referenceable.rb +14 -9
  28. data/lib/archimate/data_model/referenceable_list.rb +82 -0
  29. data/lib/archimate/data_model/relationship.rb +41 -152
  30. data/lib/archimate/data_model/relationship_references.rb +29 -0
  31. data/lib/archimate/data_model/relationships.rb +214 -0
  32. data/lib/archimate/data_model/schema_info.rb +6 -12
  33. data/lib/archimate/data_model/style.rb +14 -25
  34. data/lib/archimate/data_model/view_node.rb +38 -66
  35. data/lib/archimate/data_model/viewpoint.rb +23 -38
  36. data/lib/archimate/data_model/viewpoint_type.rb +347 -387
  37. data/lib/archimate/data_model.rb +7 -6
  38. data/lib/archimate/derived_relations.rb +106 -31
  39. data/lib/archimate/export/cypher.rb +0 -18
  40. data/lib/archimate/export/jsonl.rb +16 -45
  41. data/lib/archimate/export/n_quads.rb +1 -24
  42. data/lib/archimate/file_formats/archi_file_reader.rb +2 -1
  43. data/lib/archimate/file_formats/model_exchange_file_writer_21.rb +9 -1
  44. data/lib/archimate/file_formats/sax/archi/archi_handler_factory.rb +2 -2
  45. data/lib/archimate/file_formats/sax/archi/connection.rb +2 -1
  46. data/lib/archimate/file_formats/sax/archi/element.rb +7 -5
  47. data/lib/archimate/file_formats/sax/archi/relationship.rb +1 -1
  48. data/lib/archimate/file_formats/sax/model_exchange_file/connection.rb +2 -1
  49. data/lib/archimate/file_formats/sax/model_exchange_file/element.rb +1 -1
  50. data/lib/archimate/file_formats/sax/model_exchange_file/relationship.rb +1 -1
  51. data/lib/archimate/file_formats/sax/model_exchange_file/view_node.rb +0 -1
  52. data/lib/archimate/file_formats/serializer/archi/relationship.rb +1 -1
  53. data/lib/archimate/lint/duplicate_entities.rb +46 -42
  54. data/lib/archimate/svg/archimate.css +12 -2
  55. data/lib/archimate/svg/entity/base_entity.rb +6 -29
  56. data/lib/archimate/svg/entity/location.rb +1 -0
  57. data/lib/archimate/svg/entity_factory.rb +3 -3
  58. data/lib/archimate/svg/point.rb +3 -3
  59. data/lib/archimate/svg/svg_template.svg.erb +5 -5
  60. data/lib/archimate/version.rb +2 -1
  61. metadata +20 -6
  62. data/TODOs.org +0 -505
  63. data/lib/archimate/data_model/differentiable.rb +0 -142
  64. data/lib/archimate/data_model/element_type.rb +0 -89
  65. data/lib/archimate/data_model/relationship_type.rb +0 -45
@@ -4,16 +4,13 @@ module Archimate
4
4
  module DataModel
5
5
  # Enumeration of Influence Strength types. These are suggestions.
6
6
  # InfluenceStrengthEnum = String # Strict::String.enum(%w[+ ++ - -- 0 1 2 3 4 5 6 7 8 9 10])
7
-
7
+ require 'archimate/data_model/referenceable'
8
+ require 'archimate/data_model/referenceable_list'
8
9
  require 'archimate/data_model/connector_type'
9
10
  require 'archimate/data_model/diagram_type'
10
- require 'archimate/data_model/element_type'
11
- require 'archimate/data_model/relationship_type'
12
11
  require 'archimate/data_model/comparison'
13
- require 'archimate/data_model/differentiable'
14
12
  require 'archimate/data_model/layer'
15
13
  require 'archimate/data_model/layers'
16
- require 'archimate/data_model/viewpoint_type'
17
14
  require 'archimate/data_model/any_attribute'
18
15
  require 'archimate/data_model/any_element'
19
16
  require 'archimate/data_model/lang_string'
@@ -28,8 +25,12 @@ module Archimate
28
25
  require 'archimate/data_model/property_definition'
29
26
  require 'archimate/data_model/property'
30
27
  require 'archimate/data_model/organization'
31
- require 'archimate/data_model/element'
32
28
  require 'archimate/data_model/relationship'
29
+ require 'archimate/data_model/relationships'
30
+ require 'archimate/data_model/relationship_references'
31
+ require 'archimate/data_model/element'
32
+ require 'archimate/data_model/elements'
33
+ require 'archimate/data_model/viewpoint_type'
33
34
  require 'archimate/data_model/concern'
34
35
  require 'archimate/data_model/viewpoint'
35
36
  require 'archimate/data_model/location'
@@ -1,7 +1,60 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Archimate
4
+ # 5.6.1 Derivation Rule for Structural and Dependency Relationships
5
+ #
6
+ # The structural and dependency relationships can be ordered by 'strength'.
7
+ # Structural relationships are 'stronger' than dependency relationships, and
8
+ # the relationships within these categories can also be ordered by strength:
9
+ #
10
+ # * Influence (weakest)
11
+ # * Access
12
+ # * Serving
13
+ # * Realization
14
+ # * Assignment
15
+ # * Aggregation
16
+ # * Composition (strongest)
17
+ #
18
+ # Part of the language definition is an abstraction rule that states that two
19
+ # relationships that join at an intermediate element can be combined and
20
+ # replaced by the weaker of the two.
21
+ #
22
+ # 5.6.2 Derivation Rules for Dynamic Relationships
23
+ #
24
+ # For the two dynamic relationships, the following rules apply:
25
+ #
26
+ # * If there is a flow relationship r from element a to element b, and a
27
+ # structural relationship from element c to element a, a flow relationship
28
+ # r can be derived from element c to element b.
29
+ # * If there is a flow relationship r from element a to element b, and a
30
+ # structural relationship from element d to element b, a flow relationship
31
+ # r can be derived from element a to element d.
32
+ #
33
+ # These rules can be applied repeatedly. Informally, this means that the
34
+ # begin and/or endpoint of a flow relationship can be transferred 'backward'
35
+ # in a chain of elements connected by structural relationships. Example 16
36
+ # shows two of the possible flow relationships that can be derived with these
37
+ # rules, given a flow relationship between the two services.
38
+ #
39
+ # This rule also applies for a triggering relationship, but only in
40
+ # combination with an assignment relationship (not with other structural
41
+ # relationships):
42
+ #
43
+ # * If there is a triggering relationship r from element a to element b, and
44
+ # an assignment relationship from element c to element a, a triggering
45
+ # relationship r can be derived from element c to element b.
46
+ # * If there is a triggering relationship r from element a to element b, and
47
+ # an assignment relationship from element d to element b, a triggering
48
+ # relationship r can be derived from element a to element d.
49
+ #
50
+ # Moreover, triggering relationships are transitive:
51
+ #
52
+ # * If there is a triggering relationship from element a to element b, and a
53
+ # triggering relationship from element b to element c, a triggering
54
+ # relationship can be derived from element a to element c.
2
55
  class DerivedRelations
3
- PASS_ALL = lambda { |_item| true }
4
- FAIL_ALL = lambda { |_item| false }
56
+ PASS_ALL = ->(_item) { true }
57
+ FAIL_ALL = ->(_item) { false }
5
58
 
6
59
  def initialize(model)
7
60
  @model = model
@@ -30,26 +83,16 @@ module Archimate
30
83
  # below this element are not followed
31
84
  def derived_relations(start_elements, relationship_filter, target_filter, stop_filter = FAIL_ALL)
32
85
  traverse(start_elements, relationship_filter, stop_filter)
33
- .reject { |path| Array(path).size <= 1 } # See #2 above
34
- .select { |path| target_filter.call(path.last.target) }
35
- .map { |path|
36
- DataModel::Relationship.new(
37
- id: @model.make_unique_id,
38
- type: derived_relationship_type(path),
39
- source: path.first.source,
40
- target: path.last.target,
41
- derived: true
42
- )
43
- }
86
+ .reject(&single_relation_paths) # See #2 above
87
+ .select(&target_relations(target_filter))
88
+ .map(&create_relationship_for_path)
44
89
  .uniq { |rel| [rel.type, rel.source, rel.target] }
45
90
  end
46
91
 
47
92
  def derived_relationship_type(path)
48
- DataModel::Relationship::WEIGHTS.rassoc(
49
- path
50
- .map(&:weight)
51
- .min
52
- ).first
93
+ path
94
+ .min_by(&:weight)
95
+ .class
53
96
  end
54
97
 
55
98
  # traverse returns an Array of paths (Array<Relationship>)
@@ -65,19 +108,11 @@ module Archimate
65
108
  # returns true for.
66
109
  def traverse(start_elements, relation_filter, stop_filter, from_path = [])
67
110
  return [] if from_path.size > 100
68
- start_elements.each_with_object([]) do |el, result|
69
- immediate_rels = element_relationships(el)
70
- .select(&relation_filter)
71
- .reject { |rel| from_path.include?(rel) }
72
-
73
- result.concat(immediate_rels)
74
- result.concat(
75
- *immediate_rels
76
- .reject { |rel| rel.target.nil? || (stop_filter && stop_filter.call(rel)) }
77
- .map { |rel|
78
- traverse([rel.target], relation_filter, stop_filter, from_path + [rel])
79
- .map { |path| Array(path).unshift(rel) }
80
- }
111
+ start_elements.each_with_object([]) do |el, relations|
112
+ concrete_rels = concrete_relationships(el, relation_filter, from_path)
113
+ relations.concat(
114
+ concrete_rels,
115
+ *derived_relationship_paths(concrete_rels, relation_filter, stop_filter, from_path)
81
116
  )
82
117
  end
83
118
  end
@@ -91,5 +126,45 @@ module Archimate
91
126
  .relationships
92
127
  .select { |rel| rel.source.id == el.id }
93
128
  end
129
+
130
+ private
131
+
132
+ def concrete_relationships(el, relation_filter, from_path)
133
+ element_relationships(el)
134
+ .select(&relation_filter)
135
+ .reject { |rel| from_path.include?(rel) }
136
+ end
137
+
138
+ def derived_relationship_paths(concrete_rels, relation_filter, stop_filter, from_path)
139
+ concrete_rels
140
+ .reject { |rel| rel.target.nil? || (stop_filter&.call(rel)) }
141
+ .map do |rel|
142
+ traverse([rel.target], relation_filter, stop_filter, from_path + [rel])
143
+ .map { |path| Array(path).unshift(rel) }
144
+ end
145
+ end
146
+
147
+ def single_relation_paths
148
+ ->(path) { Array(path).size <= 1 }
149
+ end
150
+
151
+ def target_relations(target_filter)
152
+ ->(path) { target_filter.call(path.last.target) }
153
+ end
154
+
155
+ def create_relationship_for_path
156
+ lambda do |path|
157
+ derived_relationship_type(path).new(
158
+ id: @model.make_unique_id,
159
+ source: path.first.source,
160
+ target: path.last.target,
161
+ derived: true
162
+ )
163
+ end
164
+ end
165
+
166
+ def by_relation_uniq_attributes
167
+ ->(rel) { [rel.type, rel.source, rel.target] }
168
+ end
94
169
  end
95
170
  end
@@ -22,24 +22,6 @@
22
22
  # accessType: Relationship.access_type
23
23
  # Labels:
24
24
  # Relationship.type
25
- #
26
- # | Weight | Name |
27
- # |--------+----------------|
28
- # | 1 | Association |
29
- # | 2 | Access |
30
- # | 3 | Used by |
31
- # | 4 | Realization |
32
- # | 5 | Assignment |
33
- # | 6 | Aggregation |
34
- # | 7 | Composition |
35
- # | 8 | Flow |
36
- # | 9 | Triggering |
37
- # | 10 | Grouping |
38
- # | 11 | Junction |
39
- # | 12 | Specialization |
40
- # Structural stronger than Dependency Relationships
41
- # ServingRelationship == UsedByRelationship
42
-
43
25
 
44
26
  module Archimate
45
27
  module Export
@@ -45,7 +45,7 @@ require "json"
45
45
  module Archimate
46
46
  module Export
47
47
  def self.clean_json(hash)
48
- JSON.generate(hash.delete_if { |_k,v| v.nil? || (v.is_a?(String) && v.empty?) })
48
+ JSON.generate(hash.delete_if { |_k, v| v.nil? || (v.is_a?(String) && v.empty?) })
49
49
  end
50
50
 
51
51
  class PropertiesHash
@@ -75,35 +75,17 @@ module Archimate
75
75
  # `nodeId`: "d8e75068-df75-4c21-a2af-fab5c195687a"
76
76
  def to_jsonl
77
77
  Export.clean_json(
78
- {
79
- _key: element.id,
80
- name: element.name&.to_s,
81
- layer: element.layer&.delete(" "),
82
- type: element.type,
83
- documentation: element.documentation&.to_s,
84
- properties: PropertiesHash.new(element.properties).to_h
85
- }
78
+ _key: element.id,
79
+ name: element.name&.to_s,
80
+ layer: element.layer&.name&.to_s&.delete(" "),
81
+ type: element.type,
82
+ documentation: element.documentation&.to_s,
83
+ properties: PropertiesHash.new(element.properties).to_h
86
84
  )
87
85
  end
88
86
  end
89
87
 
90
88
  class JsonlEdge
91
- WEIGHTS = {
92
- 'GroupingRelationship' => 0,
93
- 'JunctionRelationship' => 0,
94
- 'AssociationRelationship' => 0,
95
- 'SpecialisationRelationship' => 1,
96
- 'FlowRelationship' => 2,
97
- 'TriggeringRelationship' => 3,
98
- 'InfluenceRelationship' => 4,
99
- 'AccessRelationship' => 5,
100
- 'UsedByRelationship' => 6,
101
- 'RealisationRelationship' => 7,
102
- 'AssignmentRelationship' => 8,
103
- 'AggregationRelationship' => 9,
104
- 'CompositionRelationship' => 10
105
- }
106
-
107
89
  attr_reader :relationship
108
90
 
109
91
  def initialize(relationship)
@@ -112,28 +94,17 @@ module Archimate
112
94
 
113
95
  def to_jsonl
114
96
  Export.clean_json(
115
- {
116
- _key: relationship.id,
117
- _from: relationship.source,
118
- _to: relationship.target,
119
- name: relationship.name&.to_s,
120
- type: relationship.type,
121
- accessType: relationship.access_type,
122
- documentation: relationship.documentation&.to_s,
123
- properties: PropertiesHash.new(relationship.properties).to_h,
124
- weight: weight
125
- }
97
+ _key: relationship.id,
98
+ _from: relationship.source,
99
+ _to: relationship.target,
100
+ name: relationship.name&.to_s,
101
+ type: relationship.type,
102
+ accessType: relationship.access_type,
103
+ documentation: relationship.documentation&.to_s,
104
+ properties: PropertiesHash.new(relationship.properties).to_h,
105
+ weight: relationship.weight
126
106
  )
127
107
  end
128
-
129
- private
130
- def weight
131
- unless WEIGHTS.include?(relationship.type)
132
- raise "Relationship type not found: \"#{relationship.type}\""
133
- return 0
134
- end
135
- WEIGHTS[relationship.type]
136
- end
137
108
  end
138
109
 
139
110
  class Jsonl
@@ -103,35 +103,12 @@ module Archimate
103
103
 
104
104
  def relationships(el)
105
105
  [
106
- make_quad(el.source.id, predicate(el.type), el.target.id),
106
+ make_quad(el.source.id, el.class::VERB, el.target.id),
107
107
  make_quad(el.id, "sources", el.source.id),
108
108
  make_quad(el.id, "target", el.target.id)
109
109
  ]
110
110
  end
111
111
 
112
- PREDICATES = {
113
- "AssociationRelationship" => %w(associated_with associated_with),
114
- "AccessRelationship" => %w(accesses accessed_by),
115
- "UsedByRelationship" => %w(used_by uses),
116
- "ServingRelationship" => %w(serving served_by),
117
- "RealisationRelationship" => %w(realizes realized_by),
118
- "RealizationRelationship" => %w(realizes realized_by),
119
- "AssignmentRelationship" => %w(assigned_to assigned_from),
120
- "AggregationRelationship" => %w(aggregates aggregated_by),
121
- "CompositionRelationship" => %w(composes composed_by),
122
- "FlowRelationship" => %w(flows_to flows_from),
123
- "TriggeringRelationship" => %w(triggers triggered_by),
124
- "GroupingRelationship" => %w(groups grouped_by),
125
- "SpecialisationRelationship" => %w(specializes specialized_by),
126
- "SpecializationRelationship" => %w(specializes specialized_by),
127
- "InfluenceRelationship" => %w(influences influenced)
128
- }.freeze
129
-
130
- def predicate(t)
131
- raise "Unexpected relationship name: '#{t}'" unless PREDICATES.include?(t)
132
- PREDICATES[t][0]
133
- end
134
-
135
112
  def make_quad(subject, predicate, object)
136
113
  if subject.nil? || predicate.nil? || object.nil?
137
114
  raise(
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "nokogiri"
3
4
 
4
5
  module Archimate
@@ -8,7 +9,7 @@ module Archimate
8
9
  @string_or_io = doc
9
10
  end
10
11
 
11
- def parse()
12
+ def parse
12
13
  handler_factory = Sax::Archi::ArchiHandlerFactory.new
13
14
  parser = Nokogiri::XML::SAX::Parser.new(Sax::Document.new(handler_factory))
14
15
  parser.parse(@string_or_io)
@@ -1,8 +1,15 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "nokogiri"
3
4
 
4
5
  module Archimate
5
6
  module FileFormats
7
+ REL_NAME_MAPPING = {
8
+ DataModel::Relationships::Realization => "Realisation",
9
+ DataModel::Relationships::Serving => "UsedBy",
10
+ DataModel::Relationships::Specialization => "Specialisation"
11
+ }.freeze
12
+
6
13
  # Archimate version 2.1 Model Exchange Format Writer
7
14
  class ModelExchangeFileWriter21 < Serializer::ModelExchangeFile::ModelExchangeFileWriter
8
15
  include Serializer::ModelExchangeFile::V21::Connection
@@ -25,11 +32,12 @@ module Archimate
25
32
  end
26
33
 
27
34
  def relationship_attributes(relationship)
35
+ rel_name = REL_NAME_MAPPING.fetch(relationship.class, relationship.type)
28
36
  {
29
37
  identifier: identifier(relationship.id),
30
38
  source: identifier(relationship.source.id),
31
39
  target: identifier(relationship.target.id),
32
- "xsi:type" => meff_type(relationship.type)
40
+ "xsi:type" => "#{rel_name}Relationship"
33
41
  }
34
42
  end
35
43
 
@@ -14,11 +14,11 @@ module Archimate
14
14
  when "element"
15
15
  element_type = Hash[attrs]["xsi:type"].sub(/archimate:/, '')
16
16
  case element_type
17
- when DataModel::ElementType, DataModel::ConnectorType
17
+ when DataModel::Elements
18
18
  Element
19
19
  when DataModel::DiagramType
20
20
  Diagram
21
- when DataModel::RelationshipType
21
+ when DataModel::Relationships
22
22
  Relationship
23
23
  else
24
24
  raise "Unexpected element_type #{element_type}"
@@ -25,7 +25,8 @@ module Archimate
25
25
  style: style,
26
26
  bendpoints: @bendpoints,
27
27
  documentation: documentation,
28
- properties: properties
28
+ properties: properties,
29
+ diagram: diagram
29
30
  )
30
31
  [
31
32
  event(:on_connection, connection),
@@ -23,11 +23,13 @@ module Archimate
23
23
  private
24
24
 
25
25
  def element
26
- @element ||= DataModel::Element.new(id: @attrs["id"],
27
- name: DataModel::LangString.string(process_text(@attrs["name"])),
28
- type: element_type,
29
- documentation: documentation,
30
- properties: properties)
26
+ @element ||= DataModel::Elements.create(
27
+ id: @attrs["id"],
28
+ name: DataModel::LangString.string(process_text(@attrs["name"])),
29
+ type: element_type,
30
+ documentation: documentation,
31
+ properties: properties
32
+ )
31
33
  end
32
34
  end
33
35
  end
@@ -25,7 +25,7 @@ module Archimate
25
25
  private
26
26
 
27
27
  def relationship
28
- @relationship ||= DataModel::Relationship.new(
28
+ @relationship ||= DataModel::Relationships.create(
29
29
  id: @attrs["id"],
30
30
  type: element_type,
31
31
  source: nil,
@@ -58,7 +58,8 @@ module Archimate
58
58
  style: @style,
59
59
  bendpoints: @bendpoints,
60
60
  documentation: documentation,
61
- properties: properties)
61
+ properties: properties,
62
+ diagram: diagram)
62
63
  end
63
64
  end
64
65
  end
@@ -28,7 +28,7 @@ module Archimate
28
28
  private
29
29
 
30
30
  def element
31
- @element ||= DataModel::Element.new(
31
+ @element ||= DataModel::Elements.create(
32
32
  id: attrs["identifier"],
33
33
  name: name,
34
34
  type: element_type,
@@ -31,7 +31,7 @@ module Archimate
31
31
  private
32
32
 
33
33
  def relationship
34
- @relationship ||= DataModel::Relationship.new(
34
+ @relationship ||= DataModel::Relationships.create(
35
35
  id: attrs["identifier"],
36
36
  type: attrs["xsi:type"],
37
37
  source: nil,
@@ -22,7 +22,6 @@ module Archimate
22
22
  def complete
23
23
  [
24
24
  event(:on_future,
25
- # Fiber.new { |index| view_node.view_refs = index[attrs["model"]] },
26
25
  Sax::FutureReference.new(view_node, :view_refs, attrs["model"])),
27
26
  event(:on_future,
28
27
  Sax::FutureReference.new(view_node,
@@ -8,7 +8,7 @@ module Archimate
8
8
  def serialize_relationship(xml, rel)
9
9
  xml.element(
10
10
  remove_nil_values(
11
- "xsi:type" => "archimate:#{rel.type}",
11
+ "xsi:type" => "archimate:#{rel.type}Relationship",
12
12
  "id" => rel.id,
13
13
  "name" => rel.name,
14
14
  "source" => rel.source.id,
@@ -1,42 +1,45 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Archimate
2
4
  module Lint
3
- STOP_WORDS = %w(
4
- a able about above according accordingly across actually after afterwards again against all allow allows
5
- almost alone along already also although always am among amongst amoungst amount an and another any anybody
6
- anyhow anyone anything anyway anyways anywhere apart appear appreciate appropriate are around as aside ask
7
- asking associated at available away awfully back be became because become becomes becoming been before
8
- beforehand behind being believe below beside besides best better between beyond bill both bottom brief but
9
- by call came can can't cannot cant cause causes certain certainly changes clearly co com come comes computer
10
- con concerning consequently consider considering contain containing contains corresponding could couldn't
11
- couldnt course cry currently de dear definitely describe described despite detail did didn't different do
12
- does doesn't doing don't done down downwards due during each edu eg eight either eleven else elsewhere empty
13
- enough entirely especially et etc even ever every everybody everyone everything everywhere ex exactly example
14
- except far few fifteen fifth fify fill find fire first five followed following follows for former formerly
15
- forth forty found four from front full further furthermore get gets getting give given gives go goes going
16
- gone got gotten greetings had hadn't happens hardly has hasn't hasnt have haven't having he he's hello help
17
- hence her here here's hereafter hereby herein hereupon hers herself hi him himself his hither hopefully how
18
- howbeit however hundred i i'd i'll i'm i've ie if ignored immediate in inasmuch inc indeed indicate indicated
19
- indicates inner insofar instead interest into inward is isn't it it'd it'll it's its itself just keep keeps
20
- kept know known knows last lately later latter latterly least less lest let let's like liked likely little
21
- look looking looks ltd made mainly many may maybe me mean meanwhile merely might mill mine more moreover most
22
- mostly move much must my myself name namely nd near nearly necessary need needs neither never nevertheless
23
- new next nine no nobody non none noone nor normally not nothing novel now nowhere obviously of off often oh
24
- ok okay old on once one ones only onto or other others otherwise ought our ours ourselves out outside over
25
- overall own part particular particularly per perhaps placed please plus possible presumably probably provides
26
- put que quite qv rather rd re really reasonably regarding regardless regards relatively respectively right
27
- said same saw say saying says second secondly see seeing seem seemed seeming seems seen self selves sensible
28
- sent serious seriously seven several shall she should shouldn't show side since sincere six sixty so some
29
- somebody somehow someone something sometime sometimes somewhat somewhere soon sorry specified specify
30
- specifying still sub such sup sure system take taken tell ten tends th than thank thanks thanx that that's
31
- thats the their theirs them themselves then thence there there's thereafter thereby therefore therein theres
32
- thereupon these they they'd they'll they're they've thick thin think third this thorough thoroughly those
33
- though three through throughout thru thus tis to together too took top toward towards tried tries truly try
34
- trying twas twelve twenty twice two un under unfortunately unless unlikely until unto up upon us use used
35
- useful uses using usually value various very via viz vs want wants was wasn't way we we'd we'll we're we've
36
- welcome well went were weren't what what's whatever when whence whenever where where's whereafter whereas
37
- whereby wherein whereupon wherever whether which while whither who who's whoever whole whom whose why will
38
- willing wish with within without won't wonder would wouldn't yes yet you you'd you'll you're you've your
39
- yours yourself yourselves zero).freeze
5
+ STOP_WORDS = %w[
6
+ a able about above according accordingly across actually after afterwards again against all allow allows
7
+ almost alone along already also although always am among amongst amoungst amount an and another any anybody
8
+ anyhow anyone anything anyway anyways anywhere apart appear appreciate appropriate are around as aside ask
9
+ asking associated at available away awfully back be became because become becomes becoming been before
10
+ beforehand behind being believe below beside besides best better between beyond bill both bottom brief but
11
+ by call came can can't cannot cant cause causes certain certainly changes clearly co com come comes computer
12
+ con concerning consequently consider considering contain containing contains corresponding could couldn't
13
+ couldnt course cry currently de dear definitely describe described despite detail did didn't different do
14
+ does doesn't doing don't done down downwards due during each edu eg eight either eleven else elsewhere empty
15
+ enough entirely especially et etc even ever every everybody everyone everything everywhere ex exactly example
16
+ except far few fifteen fifth fify fill find fire first five followed following follows for former formerly
17
+ forth forty found four from front full further furthermore get gets getting give given gives go goes going
18
+ gone got gotten greetings had hadn't happens hardly has hasn't hasnt have haven't having he he's hello help
19
+ hence her here here's hereafter hereby herein hereupon hers herself hi him himself his hither hopefully how
20
+ howbeit however hundred i i'd i'll i'm i've ie if ignored immediate in inasmuch inc indeed indicate indicated
21
+ indicates inner insofar instead interest into inward is isn't it it'd it'll it's its itself just keep keeps
22
+ kept know known knows last lately later latter latterly least less lest let let's like liked likely little
23
+ look looking looks ltd made mainly many may maybe me mean meanwhile merely might mill mine more moreover most
24
+ mostly move much must my myself name namely nd near nearly necessary need needs neither never nevertheless
25
+ new next nine no nobody non none noone nor normally not nothing novel now nowhere obviously of off often oh
26
+ ok okay old on once one ones only onto or other others otherwise ought our ours ourselves out outside over
27
+ overall own part particular particularly per perhaps placed please plus possible presumably probably provides
28
+ put que quite qv rather rd re really reasonably regarding regardless regards relatively respectively right
29
+ said same saw say saying says second secondly see seeing seem seemed seeming seems seen self selves sensible
30
+ sent serious seriously seven several shall she should shouldn't show side since sincere six sixty so some
31
+ somebody somehow someone something sometime sometimes somewhat somewhere soon sorry specified specify
32
+ specifying still sub such sup sure system take taken tell ten tends th than thank thanks thanx that that's
33
+ thats the their theirs them themselves then thence there there's thereafter thereby therefore therein theres
34
+ thereupon these they they'd they'll they're they've thick thin think third this thorough thoroughly those
35
+ though three through throughout thru thus tis to together too took top toward towards tried tries truly try
36
+ trying twas twelve twenty twice two un under unfortunately unless unlikely until unto up upon us use used
37
+ useful uses using usually value various very via viz vs want wants was wasn't way we we'd we'll we're we've
38
+ welcome well went were weren't what what's whatever when whence whenever where where's whereafter whereas
39
+ whereby wherein whereupon wherever whether which while whither who who's whoever whole whom whose why will
40
+ willing wish with within without won't wonder would wouldn't yes yet you you'd you'll you're you've your
41
+ yours yourself yourselves zero
42
+ ].freeze
40
43
 
41
44
  class DuplicateEntities
42
45
  attr_reader :word_count
@@ -47,7 +50,7 @@ module Archimate
47
50
  @dupes = nil
48
51
  @count = nil
49
52
  @word_count = {}
50
- @ignored_entity_types = %w(Junction AndJunction OrJunction)
53
+ @ignored_entity_types = %w[Junction AndJunction OrJunction]
51
54
  dupe_list
52
55
  end
53
56
 
@@ -59,15 +62,16 @@ module Archimate
59
62
  count.zero?
60
63
  end
61
64
 
62
- def each(&block)
65
+ def each
63
66
  @dupes.keys.sort.each do |name|
64
67
  ary = @dupes[name]
65
68
  element_type = ary.first.type
66
- block.call(element_type, name, ary)
69
+ yield(element_type, name, ary)
67
70
  end
68
71
  end
69
72
 
70
73
  protected
74
+
71
75
  def candidate_entities
72
76
  @model.entities.select do |entity|
73
77
  (entity.is_a?(DataModel::Element) || entity.is_a?(DataModel::Relationship)) &&
@@ -86,7 +90,7 @@ module Archimate
86
90
  end
87
91
 
88
92
  def entity_hash_name(entity)
89
- layer = DataModel::Layers.for_element(entity.type)
93
+ layer = entity.layer
90
94
  layer_sort_order = layer ? DataModel::Layers.find_index(layer) : 9
91
95
  [
92
96
  entity.class.name, # Taking advantage of Element being before Relationship
@@ -105,7 +109,7 @@ module Archimate
105
109
  # 5. names differ only by stop-words (list of words such as "the", "api", etc.)
106
110
  def simplify(entity)
107
111
  name = entity.name&.dup.to_s || ""
108
- name.sub!("(copy)", "") # (copy) is a special case inserted by the Archi tool
112
+ name = name.sub("(copy)", "") # (copy) is a special case inserted by the Archi tool
109
113
  name.downcase!
110
114
  name.gsub!(/[[:punct:]]/, "") unless entity.is_a?(DataModel::Relationship)
111
115
  name.strip!