Class: Asciidoctor::Diagram::PlantUMLPreprocessedSource
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Asciidoctor::Diagram::PlantUMLPreprocessedSource
- Defined in:
- lib/asciidoctor-diagram/plantuml/converter.rb
Instance Method Summary collapse
- #code ⇒ Object
-
#initialize(source, tag) ⇒ PlantUMLPreprocessedSource
constructor
A new instance of PlantUMLPreprocessedSource.
- #load_code ⇒ Object
Constructor Details
#initialize(source, tag) ⇒ PlantUMLPreprocessedSource
Returns a new instance of PlantUMLPreprocessedSource.
100 101 102 103 |
# File 'lib/asciidoctor-diagram/plantuml/converter.rb', line 100 def initialize(source, tag) super(source) @tag = tag end |
Instance Method Details
#code ⇒ Object
105 106 107 |
# File 'lib/asciidoctor-diagram/plantuml/converter.rb', line 105 def code @code ||= load_code end |
#load_code ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/asciidoctor-diagram/plantuml/converter.rb', line 109 def load_code Java.load code = __getobj__.code code = "@start#{@tag}\n#{code}\n@end#{@tag}" unless code.index("@start") && code.index("@end") headers = {} config_file = attr('plantumlconfig', nil, true) || attr('config') if config_file headers['X-PlantUML-Config'] = File.(config_file, base_dir) end headers['X-PlantUML-Basedir'] = Platform.native_path(File.(base_dir)) response = Java.send_request( :url => '/plantumlpreprocessor', :body => code, :headers => headers ) unless response[:code] == 200 raise Java.create_error("PlantUML preprocessing failed", response) end code = response[:body] code.force_encoding(Encoding::UTF_8) code end |