Class: Marmerdo::Cli
- Inherits:
-
Thor
- Object
- Thor
- Marmerdo::Cli
- Defined in:
- lib/marmerdo/cli.rb
Defined Under Namespace
Classes: ArgumentError
Instance Method Summary collapse
Instance Method Details
#generate(source_glob, output_path) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/marmerdo/cli.rb', line 13 def generate(source_glob, output_path) raise ArgumentError, "You must provide a source glob and an output file" if source_glob.nil? || output_path.nil? enable_link_extension = [:link_extension] nodes = Dir[source_glob].map do |source_path| content = File.read(source_path) node = Marmerdo::MarkdownParser.new(source_path, content).parse puts "Loaded #{node.name}." if node node end.compact puts "Writing domain diagram to #{output_path}." domain_diagram = Marmerdo::DomainDiagramGenerator.new( output_path: output_path, nodes: nodes, enable_link_extension: enable_link_extension ).generate output_content = OutputGenerator.new(output_path, domain_diagram).generate File.write(output_path, output_content) puts "Done!" end |