| 1 | package Bot::Cobalt::Conf; | ||
| 2 | $Bot::Cobalt::Conf::VERSION = '0.021001'; | ||
| 3 | 3 | ▶ | use strictures 2; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 3 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 3 | ▶ | use Bot::Cobalt::Common ':types'; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 7 | |||
| 8 | use Bot::Cobalt::Conf::File::Core; | ||
| 9 | use Bot::Cobalt::Conf::File::Channels; | ||
| 10 | use Bot::Cobalt::Conf::File::Plugins; | ||
| 11 | |||
| 12 | use Path::Tiny; | ||
| 13 | use Types::Path::Tiny -types; | ||
| 14 | |||
| 15 | use Scalar::Util 'blessed'; | ||
| 16 | |||
| 17 | |||
| 18 | use Moo; | ||
| 19 | |||
| 20 | has etc => ( | ||
| 21 | required => 1, | ||
| 22 | is => 'rw', | ||
| 23 | isa => Path, | ||
| 24 | coerce => 1, | ||
| 25 | ); | ||
| 26 | |||
| 27 | has debug => ( | ||
| 28 | is => 'rw', | ||
| 29 | isa => Bool, | ||
| 30 | builder => sub { 0 } | ||
| 31 | ); | ||
| 32 | |||
| 33 | has path_to_core_cf => ( | ||
| 34 | lazy => 1, | ||
| 35 | is => 'rwp', | ||
| 36 | isa => Path, | ||
| 37 | coerce => 1, | ||
| 38 | builder => sub { | ||
| 39 | path( shift->etc .'/cobalt.conf' ) | ||
| 40 | }, | ||
| 41 | ); | ||
| 42 | |||
| 43 | has path_to_channels_cf => ( | ||
| 44 | lazy => 1, | ||
| 45 | is => 'rwp', | ||
| 46 | isa => Path, | ||
| 47 | coerce => 1, | ||
| 48 | builder => sub { | ||
| 49 | path( shift->etc .'/channels.conf' ) | ||
| 50 | }, | ||
| 51 | ); | ||
| 52 | |||
| 53 | has path_to_plugins_cf => ( | ||
| 54 | lazy => 1, | ||
| 55 | is => 'rwp', | ||
| 56 | isa => Path, | ||
| 57 | coerce => 1, | ||
| 58 | builder => sub { | ||
| 59 | path( shift->etc .'/plugins.conf' ) | ||
| 60 | }, | ||
| 61 | ); | ||
| 62 | |||
| 63 | |||
| 64 | has core => ( | ||
| 65 | lazy => 1, | ||
| 66 | is => 'ro', | ||
| 67 | predicate => 'has_core', | ||
| 68 | writer => 'set_core', | ||
| 69 | isa => InstanceOf['Bot::Cobalt::Conf::File::Core'], | ||
| 70 | builder => sub { | ||
| 71 | my ($self) = @_; | ||
| 72 | Bot::Cobalt::Conf::File::Core->new( | ||
| 73 | debug => $self->debug, | ||
| 74 | cfg_path => $self->path_to_core_cf, | ||
| 75 | ) | ||
| 76 | }, | ||
| 77 | ); | ||
| 78 | |||
| 79 | has channels => ( | ||
| 80 | lazy => 1, | ||
| 81 | is => 'ro', | ||
| 82 | predicate => 'has_channels', | ||
| 83 | writer => 'set_channels', | ||
| 84 | isa => InstanceOf['Bot::Cobalt::Conf::File::Channels'], | ||
| 85 | builder => sub { | ||
| 86 | my ($self) = @_; | ||
| 87 | Bot::Cobalt::Conf::File::Channels->new( | ||
| 88 | debug => $self->debug, | ||
| 89 | cfg_path => $self->path_to_channels_cf, | ||
| 90 | ) | ||
| 91 | }, | ||
| 92 | ); | ||
| 93 | |||
| 94 | has plugins => ( | ||
| 95 | lazy => 1, | ||
| 96 | is => 'ro', | ||
| 97 | predicate => 'has_plugins', | ||
| 98 | writer => 'set_plugins', | ||
| 99 | isa => InstanceOf['Bot::Cobalt::Conf::File::Plugins'], | ||
| 100 | builder => sub { | ||
| 101 | my ($self) = @_; | ||
| 102 | Bot::Cobalt::Conf::File::Plugins->new( | ||
| 103 | debug => $self->debug, | ||
| 104 | cfg_path => $self->path_to_plugins_cf, | ||
| 105 | etcdir => $self->etc, | ||
| 106 | ) | ||
| 107 | }, | ||
| 108 | ); | ||
| 109 | |||
| 110 | |||
| 111 | 1; | ||
| 112 | __END__ | ||