jekyll-archimate 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 142de02153a0494436277f16cd06f6177554a0ad
|
4
|
+
data.tar.gz: cc4e2f718973f490c3c150ef54bd88ecde3e1202
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26af99552195c8c13c62fcd818c973a26c77f27ab2e089cd852ddfac39662b7a6bf7f436ab7c3f755bf6c863bffac265cd2ba0c9857b502583d91293329e95d3
|
7
|
+
data.tar.gz: c2ad65fbb18154b7ae1f86a7458366417a4615f5d77673551204ce30ef4252bacf9518f2703d03c573361e7798530c822f92513642f4ecf83f28118be8956585
|
data/lib/jekyll-archimate.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "archimate"
|
3
|
+
require "yaml"
|
3
4
|
|
4
5
|
module Jekyll
|
5
6
|
module Archimate
|
@@ -186,6 +187,7 @@ module Jekyll
|
|
186
187
|
def generate
|
187
188
|
export_svgs
|
188
189
|
export_unified_json
|
190
|
+
export_catalogs
|
189
191
|
end
|
190
192
|
|
191
193
|
def export_unified_json
|
@@ -211,6 +213,40 @@ module Jekyll
|
|
211
213
|
SvgFile.new(File.join(svg_dest_dir, "#{diagram.id}.svg")).write(diagram)
|
212
214
|
end
|
213
215
|
end
|
216
|
+
|
217
|
+
def export_catalogs
|
218
|
+
data = File.join(site.source, "_data")
|
219
|
+
Dir.mkdir(data) unless Dir.exist?(data)
|
220
|
+
archimate = File.join(data, "archimate")
|
221
|
+
Dir.mkdir(archimate) unless Dir.exist?(archimate)
|
222
|
+
catalog = File.join(archimate, "catalog.yml")
|
223
|
+
File.open(catalog, "wb") do |file|
|
224
|
+
file.write(
|
225
|
+
model
|
226
|
+
.elements
|
227
|
+
.chunk { |el| el.type }
|
228
|
+
.each_with_object({}) { |(type, els), hash|
|
229
|
+
hash[type] = els.map { |el| catalog_element(el) }
|
230
|
+
}
|
231
|
+
.to_yaml
|
232
|
+
)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def catalog_element(el)
|
237
|
+
[:id, :name, :documentation, :type, :properties].each_with_object({}) do |sym, hash|
|
238
|
+
hash[sym] = el.send(sym)
|
239
|
+
end
|
240
|
+
{
|
241
|
+
"id" => el.id,
|
242
|
+
"name" => el.name.to_s,
|
243
|
+
"documentation" => el.documentation.first.to_s,
|
244
|
+
"type" => el.type,
|
245
|
+
"properties" => el.properties.each_with_object({}) do |property, hash|
|
246
|
+
hash[property.key.to_s] = property.value.to_s
|
247
|
+
end
|
248
|
+
}
|
249
|
+
end
|
214
250
|
end
|
215
251
|
end
|
216
252
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Archimate
|
3
|
+
# Insert a diagram from the ArchiMate model.
|
4
|
+
#
|
5
|
+
# {% element_catalog type:"Principle" | caption:"Principles Catalog" %}
|
6
|
+
#
|
7
|
+
class ElementCatalogTag < Liquid::Tag
|
8
|
+
attr_reader :context
|
9
|
+
attr_reader :caption
|
10
|
+
attr_reader :element_types
|
11
|
+
attr_reader :markup
|
12
|
+
|
13
|
+
def initialize(tag_name, markup, tokens)
|
14
|
+
@markup = markup
|
15
|
+
@context = nil
|
16
|
+
@caption = nil
|
17
|
+
@element_types = []
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def render(context)
|
22
|
+
@context = context
|
23
|
+
scan_attributes(context)
|
24
|
+
render_table
|
25
|
+
end
|
26
|
+
|
27
|
+
def render_table
|
28
|
+
<<-END.gsub(/^ {6}/, '')
|
29
|
+
<table>
|
30
|
+
<caption>#{caption}</caption>
|
31
|
+
<thead>
|
32
|
+
<tr>
|
33
|
+
<th>Name</th>
|
34
|
+
<th>Documentation</th>
|
35
|
+
<th>Properties</th>
|
36
|
+
</tr>
|
37
|
+
</thead>
|
38
|
+
<tbody>
|
39
|
+
#{render_rows(elements(site.data["archimate"]["catalog"]))}
|
40
|
+
</tbody>
|
41
|
+
</table>
|
42
|
+
END
|
43
|
+
end
|
44
|
+
|
45
|
+
def elements(catalog)
|
46
|
+
@element_types.map { |element_type| catalog[element_type] }.flatten.compact
|
47
|
+
end
|
48
|
+
|
49
|
+
def render_rows(elements)
|
50
|
+
return "<tr><td colspan=\"3\">No Items</td></tr>" if elements.empty?
|
51
|
+
elements.map do |element|
|
52
|
+
<<-END
|
53
|
+
<tr>
|
54
|
+
<td><span class="badge badge-primary">#{element["type"]}</span> #{element["name"]}</td>
|
55
|
+
<td>#{element["documentation"]}</td>
|
56
|
+
<td>#{render_properties(element["properties"])}</td>
|
57
|
+
</tr>
|
58
|
+
END
|
59
|
+
end.join("")
|
60
|
+
end
|
61
|
+
|
62
|
+
def render_properties(props)
|
63
|
+
return "" if props.empty?
|
64
|
+
|
65
|
+
"<dl>" + props.map { |k, v| "<dt>#{k}</dt><dd>#{v}</dd>" }.join("") + "</dl>"
|
66
|
+
end
|
67
|
+
|
68
|
+
def scan_attributes(context)
|
69
|
+
@converter = converter(context)
|
70
|
+
|
71
|
+
# Render any liquid variables
|
72
|
+
markup = Liquid::Template.parse(@markup).render(context)
|
73
|
+
|
74
|
+
# Extract tag attributes
|
75
|
+
attributes = {}
|
76
|
+
markup.scan(Liquid::TagAttributes) do |key, value|
|
77
|
+
attributes[key] = value
|
78
|
+
end
|
79
|
+
@caption = attributes['caption']&.gsub!(/\A"|"\Z/, '')
|
80
|
+
element_type = attributes['type']
|
81
|
+
element_type = element_type.gsub!(/\A"|"\Z/, '') if element_type
|
82
|
+
@element_types = element_type.split(",").map(&:strip)
|
83
|
+
end
|
84
|
+
|
85
|
+
def converter(context)
|
86
|
+
# Gather settings
|
87
|
+
site = context.registers[:site]
|
88
|
+
site.find_converter_instance(::Jekyll::Converters::Markdown)
|
89
|
+
end
|
90
|
+
|
91
|
+
def site
|
92
|
+
@site ||= context.registers[:site]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
Liquid::Template.register_tag("element_catalog", Jekyll::Archimate::ElementCatalogTag)
|
99
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-archimate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- lib/jekyll/archimate/archimate_cache.rb
|
102
102
|
- lib/jekyll/archimate/archimate_diagram_tag.rb
|
103
103
|
- lib/jekyll/archimate/archimate_hook.rb
|
104
|
+
- lib/jekyll/archimate/element_catalog_tag.rb
|
104
105
|
- lib/jekyll/archimate/version.rb
|
105
106
|
homepage: https://github.com/mmorga/jekyll-archimate
|
106
107
|
licenses: []
|