Sha256: 5bac75239ef8b71dd250a8aa2d5ef05633784b1c9e5061a156324ab891e28af0
Contents?: true
Size: 1.43 KB
Versions: 3
Compression:
Stored size: 1.43 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true # # Script to convert plantuml files into LutaML syntax # Usage: bin/plantuml2lutaml /path/to/plantuml.wsd file_path = ARGV[0] FILE_NAME = File.basename(file_path, '.wsd') wsd_file = File.new(ARGV[0]) def sync_puts(line, level = 0) $stdout.puts("#{''.rjust(level)}#{line}") $stdout.flush end SKIPPED_LINES_REGEXP = /^(@startuml|'\*{7}|note|@enduml|\!|'\/)/ COMMENT_START = /\/'/ COMMENT_END = /'\// ASSOCIATION_MAPPINGS = { /-\|>/ => ',inheritance', /<\|-/ => 'inheritance,', /->/ => ',direct', /<-/ => 'direct,' } in_comment_block = false def transform_line(line) return sync_puts(line, 2) if ASSOCIATION_MAPPINGS.keys.none? { |key| line =~ key } owner_type, member_type = ASSOCIATION_MAPPINGS.find { |(key,value)| line =~ key }.last.split(',') blocks = line.split(' ') owner = blocks.first member = blocks.last sync_puts("association {", 2) sync_puts("owner #{owner}", 4) sync_puts("member #{member}", 4) sync_puts("owner_type #{owner_type}", 4) if owner_type.to_s.length > 0 sync_puts("member_type #{member_type}", 4) if member_type.to_s.length > 0 sync_puts("}", 2) end sync_puts("diagram #{FILE_NAME} {") wsd_file.readlines.each do |line| if line =~ COMMENT_START in_comment_block = true end if line =~ COMMENT_END in_comment_block = false end next if in_comment_block || line =~ SKIPPED_LINES_REGEXP transform_line(line) end sync_puts("}")
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lutaml-uml-0.2.3 | bin/plantuml2lutaml |
lutaml-uml-0.2.2 | bin/plantuml2lutaml |
lutaml-uml-0.2.1 | bin/plantuml2lutaml |