Developer-Dashboard

 view release on metacpan or  search on metacpan

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

    my ($self) = @_;
    my $cfg = $self->merged;
    my @providers = ();
    push @providers, @{ $cfg->{providers} } if ref( $cfg->{providers} ) eq 'ARRAY';
    return \@providers;
}

# _global_config_file()
# Returns the writable global configuration file path for the effective runtime root.
# Input: none.
# Output: writable configuration file path string.
sub _global_config_file {
    my ($self) = @_;
    return File::Spec->catfile( $self->{paths}->config_root, 'config.json' );
}

# _global_api_file()
# Returns the writable runtime-layer config/api.json path.
# Input: none.
# Output: writable API config file path string.
sub _global_api_file {
    my ($self) = @_;
    return File::Spec->catfile( $self->{paths}->config_root, 'api.json' );
}

# _global_config_files()
# Returns the global configuration file candidates in effective lookup order.
# Input: none.
# Output: ordered list of configuration file path strings.
sub _global_config_files {
    my ($self) = @_;
    return map { File::Spec->catfile( $_, 'config.json' ) } $self->{paths}->config_roots;
}

# _global_api_files()
# Returns the layered config/api.json candidates in effective lookup order.
# Input: none.
# Output: ordered list of configuration file path strings.
sub _global_api_files {
    my ($self) = @_;
    return map { File::Spec->catfile( $_, 'api.json' ) } $self->{paths}->config_roots;
}

# _load_writable_global()
# Loads only the writable runtime layer configuration file without merging
# inherited parent-layer settings into the returned hash.
# Input: none.
# Output: configuration hash reference for the writable layer only.
sub _load_writable_global {
    my ($self) = @_;
    my $file = $self->_global_config_file;
    return {} if !-f $file;
    open my $fh, '<:raw', $file or die "Unable to read $file: $!";
    local $/;
    return json_decode(<$fh>);
}

# _load_writable_api_registry()
# Loads only the writable runtime-layer config/api.json payload.
# Input: none.
# Output: decoded API config hash reference for the writable layer only.
sub _load_writable_api_registry {
    my ($self) = @_;
    my $file = $self->_global_api_file;
    return {} if !-f $file;
    return $self->_load_json_hash_file($file);
}

# _load_json_hash_file($file)
# Reads one JSON config file and requires it to decode to a hash reference.
# Input: readable filesystem path string.
# Output: decoded hash reference.
sub _load_json_hash_file {
    my ( $self, $file ) = @_;
    open my $fh, '<:raw', $file or die "Unable to read $file: $!";
    local $/;
    my $decoded = json_decode(<$fh>);
    die "Expected JSON object in $file\n" if ref($decoded) ne 'HASH';
    return $decoded;
}

# _skill_config_fragments()
# Loads installed skill config/config.json payloads as underscored runtime config fragments.
# Input: none.
# Output: ordered list of hash refs such as { _skill_name => { ... } }.
sub _skill_config_fragments {
    my ($self) = @_;
    my @fragments;
    for my $entry ( $self->_skill_config_entries ) {
        push @fragments, { '_' . $entry->{skill_name} => $entry->{config} };
    }
    return @fragments;
}

# _skill_config_entries()
# Enumerates installed skill config payloads together with the skill name and installed root.
# Input: none.
# Output: ordered list of hash refs with skill_name, skill_root, and config.
sub _skill_config_entries {
    my ($self) = @_;
    my @entries;
    for my $skill_root ( $self->{paths}->installed_skill_roots ) {
        my ($skill_name) = $skill_root =~ m{/([^/]+)\z};
        next if !defined $skill_name || $skill_name eq '';
        my $config = $self->_skill_config_hash($skill_name);
        next if ref($config) ne 'HASH' || !%{$config};
        push @entries,
          {
            skill_name => $skill_name,
            skill_root => $skill_root,
            config     => $config,
          };
    }
    return @entries;
}

# _skill_api_fragments()
# Loads installed skill config/api.json payloads as layered API auth fragments.
# Input: none.
# Output: ordered list of api-key hash refs.
sub _skill_api_fragments {
    my ($self) = @_;
    my @fragments;
    for my $entry ( $self->_skill_api_entries ) {
        push @fragments, $entry->{api};
    }
    return @fragments;
}

# _skill_api_entries()
# Enumerates installed skill API auth payloads together with their skill names.
# Input: none.
# Output: ordered list of hash refs with skill_name, skill_root, and api.
sub _skill_api_entries {
    my ($self) = @_;
    my @entries;
    for my $skill_root ( $self->{paths}->installed_skill_roots ) {
        my ($skill_name) = $skill_root =~ m{/([^/]+)\z};
        next if !defined $skill_name || $skill_name eq '';



( run in 0.526 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )