lib/drawio_dsl/configuration.rb in drawio_dsl-0.8.9 vs lib/drawio_dsl/configuration.rb in drawio_dsl-0.8.10
- old
+ new
@@ -8,10 +8,13 @@
include DrawioDsl::ConfigurationThemes
include KLog::Logging
BaseStyle = Struct.new(:white_space, :html, :rounded, :shadow, :sketch, :glass, keyword_init: true)
+ Element = Struct.new(:type, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
+ Line = Struct.new(:type, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
+ Text = Struct.new(:type, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
attr_accessor :base_style
attr_accessor :shapes
@@ -41,9 +44,53 @@
source_config['strokes'].each do |stroke|
@strokes[stroke['type'].to_sym] = stroke['style']
end
@strokes
+ end
+
+ def element(type)
+ elements[type] || ''
+ end
+
+ def elements
+ return @elements if defined? @elements
+
+ @elements = {}
+ source_config['shapes'].select { |shape| shape['category'] == 'element' }.each do |element|
+ @elements[element['type'].to_sym] = Element.new(
+ type: element['type'].to_sym,
+ x: element['x'].to_i,
+ y: element['y'].to_i,
+ w: element['w'].to_i,
+ h: element['h'].to_i,
+ style_modifiers: element['style_modifiers']
+ )
+ end
+
+ @elements
+ end
+
+ def line(type)
+ lines[type] || ''
+ end
+
+ def lines
+ return @lines if defined? @lines
+
+ @lines = {}
+ source_config['shapes'].select { |shape| shape['category'] == 'line' }.each do |line|
+ @lines[line['type'].to_sym] = Line.new(
+ type: line['type'].to_sym,
+ x: line['x'].to_i,
+ y: line['y'].to_i,
+ w: line['w'].to_i,
+ h: line['h'].to_i,
+ style_modifiers: line['style_modifiers']
+ )
+ end
+
+ @lines
end
def connector
@connector ||= Connector.new(source_config['connector'])
end