Developer-Dashboard

 view release on metacpan or  search on metacpan

lib/Developer/Dashboard/PathRegistry.pm  view on Meta::CPAN

    my $identity = $self->_path_identity($runtime_root);
    return md5_hex( defined $identity ? $identity : '' );
}

# _state_root_user()
# Returns a sanitized username used to namespace runtime state roots in the shared temp area.
# Input: none.
# Output: username string.
sub _state_root_user {
    my ($self) = @_;
    my $raw = $ENV{DD_STATE_ROOT_USER} || $ENV{USER} || $ENV{LOGNAME} || getpwuid($<) || 'user';
    $raw =~ s{[^A-Za-z0-9._-]}{_}g;
    return $raw || 'user';
}

# _state_root_for_layer($runtime_root)
# Returns the full state root for a runtime layer.
# Input: runtime layer path string.
# Output: directory path string.
sub _state_root_for_layer {
    my ( $self, $runtime_root ) = @_;

lib/Developer/Dashboard/SkillManager.pm  view on Meta::CPAN

use Developer::Dashboard::PathRegistry;

# new()
# Creates a SkillManager instance to handle skill installation, updates, uninstalls.
# Input: none.
# Output: SkillManager object.
sub new {
    my ( $class, %args ) = @_;
    my $paths = $args{paths}
      || Developer::Dashboard::PathRegistry->new(
        home            => ( $ENV{HOME} || (getpwuid($>))[7] || $ENV{USERPROFILE} || die 'Missing home directory' ),
        workspace_roots => [],
        project_roots   => [],
      );

    return bless {
        paths    => $paths,
        progress => $args{progress},
    }, $class;
}

lib/Developer/Dashboard/Web/App.pm  view on Meta::CPAN


# _top_context_html($page)
# Builds the old-style top-right user, host, and date context line for browser chrome.
# Input: page document object.
# Output: HTML snippet string.
sub _top_context_html {
    my ( $self, $page ) = @_;
    my $ctx = $page->{meta}{request_context} || {};
    my $user = (
        ( $ctx->{tier} || '' ) eq 'helper' && ( $ctx->{username} || '' ) ne ''
    ) ? $ctx->{username} : ( $ENV{USER} || eval { getpwuid($<) } || 'user' );
    my $host = $ctx->{host} || '';
    $host =~ s/^https?:\/\///;
    $host =~ s/\/.*$//;
    my ( $host_only, $port ) = split /:/, $host, 2;
    my $machine_ip = $self->_machine_ip || $host_only || $ctx->{remote_addr} || '127.0.0.1';
    my $host_href = 'http://' . $machine_ip . ( defined $port && $port ne '' ? ':' . $port : '' );
    my $now = strftime '%Y-%m-%d %H:%M:%S', localtime;
    return sprintf q{<span class="user-name-and-icon">&#128129;&#127996; %s</span> <span id="status-server">&#128187; <a href="%s">%s</a></span> &#128467; <span id="status-datetime">%s</span><br>},
      _escape_html($user),
      _escape_html($host_href),

t/07-core-units.t  view on Meta::CPAN

ok( !-e File::Spec->catdir( $home, '.developer-dashboard', 'state' ), 'state is not created under home runtime root by default' );
is( _mode_octal( File::Spec->catdir( $home, '.developer-dashboard', 'logs' ) ), '0700', 'home runtime logs root is owner-only' );
is( _mode_octal( File::Spec->catdir( $home, '.developer-dashboard', 'dashboards' ) ), '0700', 'home runtime dashboards root is owner-only' );
is( _mode_octal( File::Spec->catdir( $home, '.developer-dashboard', 'config' ) ), '0700', 'home runtime config root is owner-only' );
is( _mode_octal( File::Spec->catdir( $home, '.developer-dashboard', 'config', 'auth' ) ), '0700', 'home runtime auth root is owner-only' );
is( _mode_octal( File::Spec->catdir( $home, '.developer-dashboard', 'config', 'auth', 'users' ) ), '0700', 'home runtime users root is owner-only' );

{
    local $ENV{DEVELOPER_DASHBOARD_STATE_ROOT};
    local $ENV{XDG_RUNTIME_DIR} = tempdir( CLEANUP => 1 );
    my $state_user = $ENV{DD_STATE_ROOT_USER} || $ENV{USER} || $ENV{LOGNAME} || ( getpwuid($<) || 'user' );
    $state_user =~ s{[^A-Za-z0-9._-]}{_}g;
    my $fallback_paths = Developer::Dashboard::PathRegistry->new(
        home            => $home,
        app_name        => 'dashboard-test',
        workspace_roots => [ $workspace, $projects ],
        project_roots   => [$projects],
    );
    is( index( $fallback_paths->state_root, File::Spec->tmpdir ) == 0, 1, 'state root defaults to the temp runtime directory when state root override is missing' );
    like( $fallback_paths->state_root, qr/\Q$state_user\E/, 'state root is namespaced by current username by default' );
    is( _mode_octal( $fallback_paths->state_root ), '0700', 'defaulted state root remains owner-only' );



( run in 2.993 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )