jekyll-archimate 0.2.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1390d11ccf52bae0ba50f6f22bd1dec103f2465e
4
- data.tar.gz: 792d680dea4b6dbb6a95f91276d14d7df09ee373
3
+ metadata.gz: 28f21df623d8b7517b7cb96f6afa8d2447a70d20
4
+ data.tar.gz: 723393f13b2337fbc0ff24e4e743fd132735c7b3
5
5
  SHA512:
6
- metadata.gz: aa6f9b4030f007efb4ca456029abb00721af40180c67ea6ca96ebc81814ec10115c7c8261e8cd4cef66601ae2ae509d9aa46f608c175ed34f2f5378774171df4
7
- data.tar.gz: 0730d88c6bd3b3067b1d797cb913a19dc8cecab7307ba9695a06b79ed66b02ad05f76ef423084e314a1826c7822fa3f62cf6f7f11d14867651dca99ecf453960
6
+ metadata.gz: 3d4dfa4d1e4ab5ac8dad5bb6290369053af032950183cf53cbf5a1727180ebe413b1572777da64ac65b21f7d87afa8edaf9c09016ee9e0e36e1efc4f17f8d088
7
+ data.tar.gz: 256ae8198b5cd36510c13351f3fb30be571f0cd06be3513e24f59f784dc388e5b809ca71ba382f5d0de11bab22c5ff2f2064d17bf7b4dd3276976a1a2cbc4639
@@ -4,5 +4,5 @@ require "jekyll/archimate/version"
4
4
  require "jekyll/archimate/archimate_cache"
5
5
  require "jekyll/archimate/archimate_diagram_tag"
6
6
  require "jekyll/archimate/catalog_tag"
7
- require "jekyll/archimate/matrix_tag"
7
+ require "jekyll/archimate/application_interaction_matrix_tag"
8
8
  require "jekyll/archimate/archimate_hook"
@@ -0,0 +1,150 @@
1
+ module Jekyll
2
+ module Archimate
3
+ # Insert a diagram from the ArchiMate model.
4
+ #
5
+ # {% application_interaction_matrix plateau:"Today" | caption: "Today's Application Interaction" }
6
+ #
7
+ class ApplicationInteractionMatrixTag < Liquid::Tag
8
+ attr_reader :context
9
+ attr_reader :markup
10
+ attr_reader :caption
11
+ attr_reader :plateau
12
+
13
+
14
+ def initialize(tag_name, markup, tokens)
15
+ @markup = markup
16
+ @context = nil
17
+ @caption = nil
18
+ @plateau = nil
19
+ super
20
+ end
21
+
22
+ def render(context)
23
+ @context = context
24
+ scan_attributes(context)
25
+ application_interaction
26
+ render_table
27
+ end
28
+
29
+ # Here I want all of the Serving relationships between 2 app components
30
+ # included or derived.
31
+ #
32
+ # attrs:
33
+ # source_selector: Element selector for source elements
34
+ # target_selector: Element selector for target elements
35
+ # relationship_selector
36
+ def application_interaction
37
+ model = site.data["archimate_model"]
38
+ dr_engine = ::Archimate::DerivedRelations.new(model)
39
+
40
+ relationship_filter = lambda { |rel| rel.weight >= ::Archimate::DataModel::Serving::WEIGHT }
41
+
42
+ plateau_today = dr_engine.element_by_name(plateau)
43
+ today_rels = model.relationships.select do |rel|
44
+ rel.source.id == plateau_today.id &&
45
+ %w{CompositionRelationship AggregationRelationship}.include?(rel.type) &&
46
+ rel.target.type == "ApplicationComponent"
47
+ end
48
+ today_apps = today_rels.map { |rel| rel.target }
49
+ source_filter = lambda { |el| }
50
+ target_filter = lambda { |el| today_apps.map(&:id).include?(el.id) }
51
+ stop_filter = lambda { |el| el.type == "ApplicationComponent" }
52
+
53
+ concrete_rels = model.relationships.select { |rel|
54
+ rel.type == "ServingRelationship" &&
55
+ today_apps.include?(rel.source.id) &&
56
+ today_apps.include?(rel.target.id)
57
+ }
58
+
59
+ derived_rels = dr_engine.derived_relations(
60
+ today_apps,
61
+ relationship_filter,
62
+ target_filter,
63
+ stop_filter
64
+ )
65
+
66
+ @all_rels = [concrete_rels, derived_rels].flatten
67
+
68
+ @callers = @all_rels.map(&:source).uniq.sort { |a, b| a.name.to_s <=> b.name.to_s }
69
+ @callees = @all_rels.map(&:target).uniq.sort { |a, b| a.name.to_s <=> b.name.to_s }
70
+ end
71
+
72
+ def matrix_data
73
+ model = site.data["archimate_model"]
74
+ dr_engine = ::Archimate::DerivedRelations.new(model)
75
+
76
+ end
77
+
78
+ def render_table
79
+ <<~END
80
+ <table class="table table-condensed table-hover table-striped">
81
+ <caption>#{caption}</caption>
82
+ <thead>
83
+ <tr>
84
+ <th>&nbsp;</th>
85
+ <th class="success" scope="col" colspan="#{@callers.size}">Callers</th>
86
+ </tr>
87
+ <tr>
88
+ <th class="info" scope="col">Callees</th>
89
+ #{@callers.map { |ac| "<th class=\"success\" scope=\"col\" style=\"text-transform: capitalize\">#{ac.name}</th>" }.join("\n")}
90
+ </tr>
91
+ </thead>
92
+ <tbody>
93
+ #{render_rows.strip}
94
+ </tbody>
95
+ </table>
96
+ END
97
+ end
98
+
99
+ def render_rows
100
+ return "<tr><td>No Items</td></tr>" if @callees.empty?
101
+ @callees.map do |callee|
102
+ <<~END
103
+ <tr>
104
+ <th class="info" scope="row">#{callee.name}</th>
105
+ #{@callers.map { |caller| cell_content(caller, callee) }.join("")}
106
+ </tr>
107
+ END
108
+ end.join("")
109
+ end
110
+
111
+ def cell_content(caller, callee)
112
+ rels = @all_rels.select { |rel| rel.source == caller && rel.target == callee }
113
+ if rels.empty?
114
+ "<td></td>"
115
+ else
116
+ derived = rels.all? { |rel| rel.derived }
117
+ span_class = derived ? "text-danger" : "text-primary"
118
+ tooltip = "#{caller.name} &rarr; #{}#{callee.name} #{"(derived)" if derived}"
119
+ cell = <<~END
120
+ <td>
121
+ <a href="#" data-toggle="tooltip" data-placement="top" title="#{tooltip}">
122
+ <span class="#{span_class}">&crarr; calls</span>
123
+ </a>
124
+ </td>
125
+ END
126
+ end
127
+ end
128
+
129
+ def scan_attributes(context)
130
+ # Render any liquid variables
131
+ markup = Liquid::Template.parse(@markup).render(context)
132
+
133
+ # Extract tag attributes
134
+ attributes = {}
135
+ markup.scan(Liquid::TagAttributes) do |key, value|
136
+ attributes[key] = value
137
+ end
138
+ @caption = attributes['caption']&.gsub!(/\A"|"\Z/, '')
139
+ @plateau = attributes['plateau']&.gsub!(/\A"|"\Z/, '')
140
+ end
141
+
142
+ def site
143
+ @site ||= context.registers[:site]
144
+ end
145
+ end
146
+ end
147
+ end
148
+
149
+ Liquid::Template.register_tag("application_interaction_matrix", Jekyll::Archimate::ApplicationInteractionMatrixTag)
150
+
@@ -52,7 +52,7 @@ module Jekyll
52
52
  <<-END
53
53
  <tr>
54
54
  <td><span class="badge badge-primary">#{element["type"]}</span> #{element["name"]}</td>
55
- <td>#{element["documentation"]}</td>
55
+ <td>#{@converter.convert(element["documentation"]).gsub(/<\/?p[^>]*>/, '').chomp if element["documentation"]}</td>
56
56
  <td>#{render_properties(element["properties"])}</td>
57
57
  </tr>
58
58
  END
@@ -76,7 +76,9 @@ module Jekyll
76
76
  markup.scan(Liquid::TagAttributes) do |key, value|
77
77
  attributes[key] = value
78
78
  end
79
- @caption = attributes['caption']&.gsub!(/\A"|"\Z/, '')
79
+
80
+ caption = attributes['caption']&.gsub!(/\A"|"\Z/, '')
81
+ @caption = @converter.convert(caption).gsub(/<\/?p[^>]*>/, '').chomp if @caption
80
82
  element_type = attributes['type']
81
83
  element_type = element_type.gsub!(/\A"|"\Z/, '') if element_type
82
84
  @element_types = element_type.split(",").map(&:strip)
@@ -2,8 +2,7 @@ module Jekyll
2
2
  module Archimate
3
3
  # Insert a diagram from the ArchiMate model.
4
4
  #
5
- # {% matrix type:"Principle" | caption:"Principles Catalog" %}
6
- # {% matrix source:"ApplicationComponent" | target:"ApplicationComponent" | }
5
+ # {% matrix plateau:"Today" | caption: "Today's Application Interaction" }
7
6
  #
8
7
  class MatrixTag < Liquid::Tag
9
8
  attr_reader :context
@@ -16,7 +15,7 @@ module Jekyll
16
15
  @markup = markup
17
16
  @context = nil
18
17
  @caption = nil
19
- @element_types = []
18
+ @plateau = []
20
19
  super
21
20
  end
22
21
 
@@ -36,19 +35,32 @@ module Jekyll
36
35
  # relationship_selector
37
36
  def application_interaction
38
37
  model = site.data["archimate_model"]
39
- derived_relations_engine = ::Archimate::DerivedRelations.new(model)
38
+ dr_engine = ::Archimate::DerivedRelations.new(model)
39
+
40
+ relationship_filter = lambda { |rel| rel.weight >= ::Archimate::DataModel::Serving::WEIGHT }
41
+
42
+ plateau_today = dr_engine.element_by_name("Today")
43
+ today_rels = model.relationships.select do |rel|
44
+ rel.source.id == plateau_today.id &&
45
+ %w{CompositionRelationship AggregationRelationship}.include?(rel.type) &&
46
+ rel.target.type == "ApplicationComponent"
47
+ end
48
+ today_apps = today_rels.map { |rel| rel.target }
49
+ source_filter = lambda { |el| }
50
+ target_filter = lambda { |el| today_apps.map(&:id).include?(el.id) }
51
+ stop_filter = lambda { |el| el.type == "ApplicationComponent" }
40
52
 
41
53
  concrete_rels = model.relationships.select { |rel|
42
54
  rel.type == "ServingRelationship" &&
43
- rel.source.type == "ApplicationComponent" &&
44
- rel.target.type == "ApplicationComponent"
55
+ today_apps.include?(rel.source.id) &&
56
+ today_apps.include?(rel.target.id)
45
57
  }
46
58
 
47
- derived_rels = derived_relations_engine.derived_relations(
48
- model.elements.select { |el| el.type == "ApplicationComponent" },
49
- lambda { |rel| rel.weight >= ::Archimate::DataModel::Serving::WEIGHT },
50
- lambda { |el| el.type == "ApplicationComponent" },
51
- lambda { |el| el.type == "ApplicationComponent" }
59
+ derived_rels = dr_engine.derived_relations(
60
+ today_apps,
61
+ relationship_filter,
62
+ target_filter,
63
+ stop_filter
52
64
  )
53
65
 
54
66
  @all_rels = [concrete_rels, derived_rels].flatten
@@ -59,7 +71,7 @@ module Jekyll
59
71
 
60
72
  def matrix_data
61
73
  model = site.data["archimate_model"]
62
- derived_relations_engine = ::Archimate::DerivedRelations.new(model)
74
+ dr_engine = ::Archimate::DerivedRelations.new(model)
63
75
 
64
76
  end
65
77
 
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Archimate
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-archimate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Morga
@@ -98,6 +98,7 @@ files:
98
98
  - bin/setup
99
99
  - jekyll-archimate.gemspec
100
100
  - lib/jekyll-archimate.rb
101
+ - lib/jekyll/archimate/application_interaction_matrix_tag.rb
101
102
  - lib/jekyll/archimate/archimate_cache.rb
102
103
  - lib/jekyll/archimate/archimate_diagram_tag.rb
103
104
  - lib/jekyll/archimate/archimate_hook.rb