From bd19438546b845e8936408c0b2536b3ca93e509f Mon Sep 17 00:00:00 2001 From: Arian Weber Date: Tue, 19 Mar 2024 10:33:43 +0100 Subject: [PATCH] Fix bug in PNG command and expand integration test --- lib/pg-verify/cli/cli.rb | 3 +-- lib/pg-verify/cli/cli_utils.rb | 2 +- lib/pg-verify/interpret/pg_script.rb | 1 + vscript.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pg-verify/cli/cli.rb b/lib/pg-verify/cli/cli.rb index af5bdf5..54ef79b 100644 --- a/lib/pg-verify/cli/cli.rb +++ b/lib/pg-verify/cli/cli.rb @@ -42,8 +42,7 @@ def png() components = self.class.select_components(options[:only], options[:hide], model) puml = Transform::PumlTransformation.new(render_labels: !hide_labels).transform_graph(model, only: components) png = PlantumlBuilder::Formats::PNG.new(puml).load - out_name = File.basename(script_file, '.*') - out_name += "-" + model.name.to_s.gsub(/\W+/, '_').downcase + ".png" + out_name = model.name.to_s.gsub(/\W+/, '_').downcase + ".png" out_path = File.expand_path(out_name, Settings.outdir) FileUtils.mkdir_p(Settings.outdir) File.binwrite(out_path, png) diff --git a/lib/pg-verify/cli/cli_utils.rb b/lib/pg-verify/cli/cli_utils.rb index 51850fc..8e5fb92 100644 --- a/lib/pg-verify/cli/cli_utils.rb +++ b/lib/pg-verify/cli/cli_utils.rb @@ -27,7 +27,7 @@ def self.load_models(options) end raise NoDefaultFileError.new(default_script_file) unless File.file?(default_script_file) - return Interpret::PgScript.new.interpret(dsl_script_file) + return Interpret::PgScript.new.interpret(default_script_file) end end diff --git a/lib/pg-verify/interpret/pg_script.rb b/lib/pg-verify/interpret/pg_script.rb index c300113..f60f46b 100644 --- a/lib/pg-verify/interpret/pg_script.rb +++ b/lib/pg-verify/interpret/pg_script.rb @@ -15,6 +15,7 @@ def initialize() end def interpret(file, validate: true) + raise "Not a file path string: '#{file}'::#{file.class}" unless file.is_a?(String) file = File.expand_path(file) raise NoSuchScriptError.new(file) unless File.file?(file) @script_file ||= file diff --git a/vscript.rb b/vscript.rb index ed55d82..6eb0654 100644 --- a/vscript.rb +++ b/vscript.rb @@ -51,7 +51,7 @@ "script" => source, "json-file" => File.join(work_dir, File.basename(source, '.rb') + ".json"), } - commands = [ "show puml", "test", "dcca" ] + commands = [ "show puml", "test", "dcca", "show png", "simulate" ] args.each { |argument, file| commands.each { |command| log "pgv #{command} #{argument} | #{File.basename(file)}"