File Coverage: lib/Yukki/Settings.pm

# File Coverage

File: | lib/Yukki/Settings.pm
Coverage: | 100.0%

line | stmt | bran | cond | sub | pod | time | code
--- | --- | --- | --- | --- | --- | --- | ---
1 |  |  |  |  |  |  | package Yukki::Settings;
2 |
3 | 4 4 |  |  | 4 |  | 215 16 | use v5.24;
4 | 4 4 4 |  |  | 4 |  | 12 4 16 | use utf8;
5 | 4 4 4 |  |  | 4 |  | 40 8 17 | use Moo;
6 |
7 | 4 4 4 |  |  | 4 |  | 1564 165689 15 | use Types::Path::Tiny qw( Path );
8 | 4 4 4 |  |  | 4 |  | 941 7 12 | use Types::Standard qw( Str );
9 | 4 4 4 |  |  | 4 |  | 2645 10 88 | use Yukki::Settings::Repository;
10 | 4 4 4 |  |  | 4 |  | 16 5 20 | use Yukki::Types qw( PrivilegesMap RepositoryMap YukkiSettingsAnonymous );
11 |
12 | 4 4 4 |  |  | 4 |  | 1804 6 22 | use namespace::clean;
13 |
14 |  |  |  |  |  |  | # ABSTRACT: provides structure and validation to settings in yukki.conf
15 |
16 - 28 |  |
    =head1 DESCRIPTION

    This class provides structure for the main application configuration in L<Yukki>.

    Yukki may fail to start unless your configuration is correct.

    =head1 ATTRIBUTES

    =head2 root

    This is the wiki site directory. This should be the same folder that was given the F<yukki-setup> command. It works best if you make this an absolute path.

    =cut
29 |
30 |  |  |  |  |  |  | has root => (
31 |  |  |  |  |  |  | is => 'ro',
32 |  |  |  |  |  |  | isa => Path,
33 |  |  |  |  |  |  | required => 1,
34 |  |  |  |  |  |  | coerce => 1,
35 |  |  |  |  |  |  | default => '.',
36 |  |  |  |  |  |  | );
37 |
38 - 42 |  |
    =head2 repository_path

    This is the folder where Yukki will find the git repositories installed under C<root>. The default is F<root/repositories>.

    =cut
43 |
44 |  |  |  |  |  |  | has repository_path => (
45 |  |  |  |  |  |  | is => 'ro',
46 |  |  |  |  |  |  | isa => Path,
47 |  |  |  |  |  |  | required => 1,
48 |  |  |  |  |  |  | coerce => 1,
49 |  |  |  |  |  |  | default => 'repositories',
50 |  |  |  |  |  |  | );
51 |
52 - 56 |  |
    =head2 user_path

    This is the folder where the list of user files can be found.

    =cut
57 |
58 |  |  |  |  |  |  | has user_path => (
59 |  |  |  |  |  |  | is => 'ro',
60 |  |  |  |  |  |  | isa => Path,
61 |  |  |  |  |  |  | required => 1,
62 |  |  |  |  |  |  | coerce => 1,
63 |  |  |  |  |  |  | default => 'var/db/users',
64 |  |  |  |  |  |  | );
65 |
66 - 72 |  |
    =head2 digest

    This is the name of the digest algorithm to use to store passwords. See L<Digest> for more information. The default is "SHA-512".

    N.B. If you change digest algorithms, old passwords saved with the old digest algorithm will continue to work as long as the old digest algorithm class is still installed.

    =cut
73 |
74 |  |  |  |  |  |  | has digest => (
75 |  |  |  |  |  |  | is => 'ro',
76 |  |  |  |  |  |  | isa => Str,
77 |  |  |  |  |  |  | required => 1,
78 |  |  |  |  |  |  | default => 'SHA-512',
79 |  |  |  |  |  |  | );
80 |
81 - 97 |  |
    =head2 anonymous

    This is a section configuring anonymous user information.

    =over

    =item author_name

    This is the name to use when an anonymous user makes a change to a wiki repository.

    =item author_email

    This is the email address to use when an anonymous user makes a change to a wiki repository.

    =back

    =cut
98 |
99 |  |  |  |  |  |  | has anonymous => (
100 |  |  |  |  |  |  | is => 'ro',
101 |  |  |  |  |  |  | isa => YukkiSettingsAnonymous,
102 |  |  |  |  |  |  | required => 1,
103 |  |  |  |  |  |  | coerce => 1,
104 |  |  |  |  |  |  | default => sub { Yukki::Settings::Anonymous->new },
105 |  |  |  |  |  |  | );
106 |
107 - 111 |  |
    =head2 repo_path

    This is the folder where repository configuraiton files can be found. This path is intended for application managed repository configuration files. If you want to manage your repositories from the command-line instead, store the repository configurations under the C<repository> key in the main settings file.

    =cut
112 |
113 |  |  |  |  |  |  | has repo_path => (
114 |  |  |  |  |  |  | is => 'ro',
115 |  |  |  |  |  |  | isa => Path,
116 |  |  |  |  |  |  | required => 1,
117 |  |  |  |  |  |  | coerce => 1,
118 |  |  |  |  |  |  | default => 'var/db/repos',
119 |  |  |  |  |  |  | );
120 |
121 - 129 |  |
    =head2 repositories

    This is a section under which each repository is configured. The keys under here are the name found in the URL. It is also the name to use when running the F<yukki-git-init> and other repository-related commands.

    Repository configurations may be stored either in the main Yukki configuration file under the C<repositories> key or as individual files located in the directory named in the C<repo_path> key. If a configuration is named in both places, the one in the main settings file will always be used.

    Each repository configuration should provide the following configruation keys.

    =cut
130 |
131 |  |  |  |  |  |  | has repositories => (
132 |  |  |  |  |  |  | is => 'ro',
133 |  |  |  |  |  |  | isa => RepositoryMap,
134 |  |  |  |  |  |  | required => 1,
135 |  |  |  |  |  |  | coerce => 1,
136 |  |  |  |  |  |  | );
137 |
138 |  |  |  |  |  |  | {
139 |  |  |  |  |  |  | package Yukki::Settings::Anonymous;
140 |
141 | 4 4 4 |  |  | 4 |  | 1228 7 16 | use Moo;
142 | 4 4 4 |  |  | 4 |  | 806 7 18 | use Types::Standard qw( Str );
143 | 4 4 4 |  |  | 4 |  | 2000 6 10 | use Yukki::Types qw( EmailAddress );
144 |
145 |  |  |  |  |  |  | has author_name => (
146 |  |  |  |  |  |  | is => 'ro',
147 |  |  |  |  |  |  | isa => Str,
148 |  |  |  |  |  |  | required => 1,
149 |  |  |  |  |  |  | default => 'Anonymous',
150 |  |  |  |  |  |  | );
151 |
152 |  |  |  |  |  |  | has author_email => (
153 |  |  |  |  |  |  | is => 'ro',
154 |  |  |  |  |  |  | isa => EmailAddress,
155 |  |  |  |  |  |  | required => 1,
156 |  |  |  |  |  |  | coerce => 1,
157 |  |  |  |  |  |  | default => 'anonymous@localhost',
158 |  |  |  |  |  |  | );
159 |  |  |  |  |  |  | }
160 |
161 - 183 |  |
    =head2 special_privileges

    This section of the settings configures which groups grant special privileges. These special privileges grant access to view or change the configuration from within the application. By default, no one has these privileges, effectively disabling any in-app administrative features.

    The grants for each here are identical to that available to repositories:

    =over

    =item anonymous_access_level

    This names the access level anonymous users have. Obviously, it would generally be unwise for this to be anything but "none" for adminsitrative functions, but "read" and "write" are other possible values.

    =item read_groups

    Names the list of groups that are granted permission to perform read-only actions. This may also be set to "ANY" to specify that any logged user may perform this action or "NONE" to specify that no logged user may perform this action.

    =item write_groups

    Names the list of groups that are granted permission to perform read-write actions. As with read, this may be set to "ANY" and "NONE" with the same meaning.

    =back

    =cut
184 |
185 |  |  |  |  |  |  | has special_privileges => (
186 |  |  |  |  |  |  | is => 'ro',
187 |  |  |  |  |  |  | isa => PrivilegesMap,
188 |  |  |  |  |  |  | required => 1,
189 |  |  |  |  |  |  | coerce => 1,
190 |  |  |  |  |  |  | default => sub { +{} },
191 |  |  |  |  |  |  | );
192 |
193 |  |  |  |  |  |  | 1;