This file is indexed.

/usr/share/perl5/UR/Value/Text.pm is in libur-perl 0.430-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 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
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
package UR::Value::Text;

use strict;
use warnings;

require UR;
our $VERSION = "0.43"; # UR $VERSION;

UR::Object::Type->define(
    class_name => 'UR::Value::Text',
    is => ['UR::Value'],
);

use overload (
    '.' => \&concat,
    '""' => \&stringify,
    fallback => 1,
);

sub swap {
    my ($a, $b) = @_;
    return ($b, $a);
}

sub concat {
    my ($self, $other, $swap) = @_;
    my $class = ref $self;
    $self = $self->id;
    ($self, $other) = swap($self, $other) if $swap;
    return $class->get($self . $other);
}

sub stringify {
    my $self = shift;
    return $self->id;
}

sub capitalize {
    my $self = shift;
    my $seps = join('', ' ', @_); # allow other separators
    my $regexp = qr/[$seps]+/;
    my $capitalized_string = join(' ', map { ucfirst } split($regexp, $self->id));
    return $self->class->get($capitalized_string);
}

sub to_camel {
    my $self = shift;
    my $seps = join('', ( @_ ? @_ : ( ' ', '_' )));
    my $regexp = qr/[$seps]+/;
    my $camel_case = join('', map { ucfirst } split($regexp, $self->id));
    return $self->class->get($camel_case);
}

sub to_lemac { # camel backwards = undo camel case. This was nutters idea. Ignore 'git blame'
    my $self = shift;
    # Split on the first capital or the start of a number
    my @words = split( /(?=(?<![A-Z])[A-Z])|(?=(?<!\d)\d)/, $self->id);
    # Default join is a space
    my $join = ( defined $_[0] ) ? $_[0] : ' '; 
    return $self->class->get( join($join, map { lc } @words) );
}

sub to_hash {
    my ($self, $split) = @_; # split splits to value of a key into many values

    my $text = $self->id;
    if ( $text !~ m#^-# ) {
        $self->warning_message('Can not convert text object with id "' . $self->id . '" to hash. Text must start with a dash (-)');
        return;
    }

    my %hash;
    my @values = split(/\s?(\-{1,2}\D[\w\d\-]*)\s?/, $text);
    shift @values;
    for ( my $i = 0; $i < @values; $i += 2 ) {
        my $key = $values[$i];
        $key =~ s/^\-{1,2}//;
        if ( $key eq '' ) {
            $self->warning_message("Can not convert text ($text) to hash. Found empty dash (-).");
            return;
        }
        my $value = $values[$i + 1];
        if ( defined $value ){
            $value =~ s/\s*$//;
        }
        else {
            $value = '';
        }
        # FIXME What if the key exists? 
        if ( defined $split ) { 
            $hash{$key} = [ split($split, $value) ];
        }
        else {
            $hash{$key} = $value;
        }
    }

    #print Data::Dumper::Dumper(\@values, \%hash);
    return UR::Value::HASH->get(\%hash);
}

1;