Commit 9776f7df authored by Jonas Smedegaard's avatar Jonas Smedegaard

Generalize file names.

parent 09b6db91
......@@ -95,14 +95,18 @@ filter not exists {?re a puml:NoReify}}
SPARQL
## $RE_SPARQL;
my $fname = shift or die "perl rdfpuml <file>: read <file>.ttl, write <file>.puml\n";
$fname =~ s{\.ttl$}{};
die "perl rdfpuml <file>: read <file>.ttl, write <file>.puml\n"
unless (@ARGV);
my $prefixes = -e "prefixes.ttl" ? slurp("prefixes.ttl") : "";
my $data = slurp("$fname.ttl");
my $infile = $ARGV[0];
my $outfile = $infile =~ s{(?:\.ttl)?$}{.puml};
  • If it doesn't end in .ttl what would it be? Add a TODO to support other RDF formats, but for now it's all Turtle (because of concating prefixes)

  • File content must be Turtle format, but file name can be anything - including "data.turtle" and "iamnota.bat".

    That said, above patch should not change functionality, only tidy functionally identical code.

Please register or sign in to reply
my $prefixfile = 'prefixes.ttl';
my $prefixes = -e $prefixfile ? slurp($prefixfile) : "";
my $data = slurp($infile);
my $turtle = decode_utf8 "$PREFIXES_TURTLE\n$prefixes\n$data";
my $prefixes_all = decode_utf8 "$PREFIXES_TURTLE\n$prefixes";
open (STDOUT, ">:encoding(UTF-8)", "$fname.puml");
open (STDOUT, ">:encoding(UTF-8)", $outfile);
  • I've often had troubles with unicode in source files and passing it appropriately to puml.. Keep that in mind when you review my code (I have a stupid myprint() sub). And could you add TODO to add some tests with non-ASCII chars (I got some BG turtles somewhere)...

  • Quoting Vladimir Alexiev (2018-12-06 16:24:54)

    Vladimir Alexiev started a new discussion on bin/rdfpuml.pl:

    -$fname =~ s{.ttl$}{}; +die "perl rdfpuml : read .ttl, write .puml\n"

    • unless (@ARGV);

    -my $prefixes = -e "prefixes.ttl" ? slurp("prefixes.ttl") : ""; -my $data = slurp("$fname.ttl"); +my $infile = $ARGV[0]; +my $outfile = $infile =~ s{(?:.ttl)?$}{.puml}; +my $prefixfile = 'prefixes.ttl'; + +my $prefixes = -e $prefixfile ? slurp($prefixfile) : ""; +my $data = slurp($infile); my $turtle = decode_utf8 "$PREFIXES_TURTLE\n$prefixes\n$data"; my $prefixes_all = decode_utf8 "$PREFIXES_TURTLE\n$prefixes"; -open (STDOUT, ">:encoding(UTF-8)", "$fname.puml"); +open (STDOUT, ">:encoding(UTF-8)", $outfile);

    I've often had troubles with unicode in source files and passing it appropriately to puml.. Keep that in mind when you review my code (I have a stupid myprint() sub).

    Yes, I noticed you have struggled with UTF-8 decoding.

    This commit specifically should not change anything regarding Unicode, however (that was carefully isolated in separate subsequent commit).

    And could you add TODO to add some tests with non-ASCII chars (I got some BG turtles somewhere)...

    Makes good sense to include in testsuite some tests related to Unicode handling. But that's unrelated to this commit (and involves another issue of TODOs currently being embedded in an org-mode file...)

    signature.asc

Please register or sign in to reply
binmode STDERR, ":encoding(UTF-8)";
#print STDERR $turtle; die;
......
  • Yes we should test Unicode input (and Unicode in prefixfile). First we should establish proper Perl-style testsuite, however - and fix code to emit a stable ordered output usable for testing.

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment