Class: DrawioDsl::Configuration
- Inherits:
-
Object
- Object
- DrawioDsl::Configuration
show all
- Extended by:
- Forwardable
- Includes:
- KLog::Logging
- Defined in:
- lib/drawio_dsl/configuration.rb
Overview
Configuration container for the DrawIO DSL
Defined Under Namespace
Classes: BaseStyle, Connector, Shape, Theme
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Configuration.
17
18
19
|
# File 'lib/drawio_dsl/configuration.rb', line 17
def initialize
@base_style = BaseStyle.new(white_space: :wrap, html: 1, rounded: nil, shadow: nil, sketch: nil, glass: nil)
end
|
Instance Attribute Details
#base_style ⇒ Object
Returns the value of attribute base_style.
13
14
15
|
# File 'lib/drawio_dsl/configuration.rb', line 13
def base_style
@base_style
end
|
Instance Method Details
#connector ⇒ Object
52
53
54
|
# File 'lib/drawio_dsl/configuration.rb', line 52
def connector
@connector ||= Connector.new(source_config['connector'])
end
|
#get_item_by_category(key, category) ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/drawio_dsl/configuration.rb', line 37
def get_item_by_category(key, category)
case category
when :text
text(key)
when :line
line(key)
else
element(key)
end
end
|
#shape ⇒ Object
48
49
50
|
# File 'lib/drawio_dsl/configuration.rb', line 48
def shape
@shape ||= Shape.new(source_config['shape'])
end
|
#source_config ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'lib/drawio_dsl/configuration.rb', line 60
def source_config
return @source_config if defined? @source_config
@source_config = begin
file = File.join(DrawioDsl::ROOT_PATH, 'config/configuration.json')
JSON.parse(File.read(file))
end
end
|
#stroke(key) ⇒ Object
21
22
23
|
# File 'lib/drawio_dsl/configuration.rb', line 21
def stroke(key)
strokes[key] || ''
end
|
#strokes ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/drawio_dsl/configuration.rb', line 25
def strokes
return @strokes if defined? @strokes
@strokes = {}
source_config['strokes'].each do |stroke|
@strokes[stroke['key'].to_sym] = stroke['style']
end
@strokes
end
|
#theme ⇒ Object
56
57
58
|
# File 'lib/drawio_dsl/configuration.rb', line 56
def theme
@theme ||= Theme.new(source_config['theme'])
end
|