Perl-Toolchain-Gang / Software-License

perl representation of common software licenses

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Add short_name() Accessor

theory opened this issue · comments

As originally described in RT-67706, it's a short display name, something like:

--- a/lib/Software/License.pm
+++ b/lib/Software/License.pm
@@ -52,6 +52,21 @@ sub holder { $_[0]->{holder}     }
 This method returns the name of the license, suitable for shoving in the middle
 of a sentence, generally with a leading capitalized "The."
 
+=method short_name
+
+This method returns the short name of the license, suitable for link text,
+for example.
+
+=cut
+
+sub short_name {
+    my $class = ref $_[0] || $_[0];
+    my ($name) = $class =~ /([^:]+)$/; # Grab the package name.
+    $name =~ s/(\d)_(\d)/$1.$2/g;      # Use dots in versions.
+    $name =~ s/_/ /g;                  # Use spaces everywhere else.
+    return $name;
+}
+
 =method url