Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add short_name() Accessor #78

Open
theory opened this issue May 23, 2021 · 0 comments
Open

Feature Request: Add short_name() Accessor #78

theory opened this issue May 23, 2021 · 0 comments

Comments

@theory
Copy link
Contributor

theory commented May 23, 2021

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant