Login
WARNING: Massive commit!
[gknop/Perl-Critic.git] / lib / Perl / Critic / Defaults.pm
CommitLineData
dc93df4f
JRT
1##############################################################################
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6# ex: set ts=8 sts=4 sw=4 expandtab
7##############################################################################
8
9package Perl::Critic::Defaults;
10
11use strict;
12use warnings;
13use Carp qw(cluck);
14use English qw(-no_match_vars);
15use Perl::Critic::Utils;
16
17our $VERSION = 0.21;
18
19#-----------------------------------------------------------------------------
20
21sub new {
22
23 my ($class, %args) = @_;
24 my $self = bless {}, $class;
25 $self->_init( %args );
26 return $self;
27}
28
29#-----------------------------------------------------------------------------
30
31sub _init {
32
33 my ( $self, %args ) = @_;
34
35 # Multi-value defaults
36 $self->{_exclude} = defined $args{-exclude} ?
37 [ split m/\s+/mx, $args{-exclude} ] : [];
38 $self->{_include} = defined $args{-include} ?
39 [ split m/\s+/mx, $args{-include} ] : [];
40 # Single-value defaults
41 $self->{_severity} = $args{-severity} || $SEVERITY_HIGHEST;
42 $self->{_theme} = $args{-theme} || $EMPTY;
43 $self->{_top} = $args{-top} || $FALSE;
44 $self->{_verbose} = $args{-verbose} || 3;
45
46 # Switch-like defaults
47 $self->{_force} = exists $args{-force} ? $TRUE : $FALSE;
48 $self->{_nocolor} = exists $args{-nocolor} ? $TRUE : $FALSE;
49 $self->{_only} = exists $args{-only} ? $TRUE : $FALSE;
50
51 return $self;
52}
53
54#-----------------------------------------------------------------------------
55
56sub severity {
57 my ($self) = @_;
58 return $self->{_severity};
59}
60
61#-----------------------------------------------------------------------------
62
63sub theme {
64 my ($self) = @_;
65 return $self->{_theme};
66}
67
68#-----------------------------------------------------------------------------
69
70sub exclude {
71 my ($self) = @_;
72 return $self->{_exclude};
73}
74
75#-----------------------------------------------------------------------------
76
77sub include {
78 my ($self) = @_;
79 return $self->{_include};
80}
81
82#-----------------------------------------------------------------------------
83
84sub only {
85 my ($self) = @_;
86 return $self->{_only};
87}
88
89#-----------------------------------------------------------------------------
90
91sub verbose {
92 my ($self) = @_;
93 return $self->{_verbose};
94}
95
96#-----------------------------------------------------------------------------
97
98sub nocolor {
99 my ($self) = @_;
100 return $self->{_nocolor};
101}
102
103#-----------------------------------------------------------------------------
104
105sub force {
106 my ($self) = @_;
107 return $self->{_force};
108}
109
110#-----------------------------------------------------------------------------
111
112sub top {
113 my ($self) = @_;
114 return $self->{_top};
115}
116
117
1181;
119
120__END__
121
122#-----------------------------------------------------------------------------
123
124=pod
125
126=head1 NAME
127
128Perl::Critic::Config::Defaults - Manage default settings for Perl::Critic
129
130=head1 DESCRIPTION
131
132This is a helper class that encapsulates the default parameters for
133constructing a L<Perl::Critic::Config> object. There are no
134user-serviceable parts here.
135
136=head1 CONSTRUCTOR
137
138=over 8
139
140=item C< new( %DEFAULT_PARAMS ) >
141
142=back
143
144=head1 METHODS
145
146=over 8
147
148=item C< exclude() >
149
150=item C< force() >
151
152=item C< include() >
153
154=item C< nocolor() >
155
156=item C< only() >
157
158=item C< severity() >
159
160=item C< theme() >
161
162=item C< top() >
163
164=item C< verbose() >
165
166=back
167
168=head1 AUTHOR
169
170Jeffrey Ryan Thalhammer <thaljef@cpan.org>
171
172=head1 COPYRIGHT
173
174Copyright (c) 2005-2006 Jeffrey Ryan Thalhammer. All rights reserved.
175
176This program is free software; you can redistribute it and/or modify
177it under the same terms as Perl itself. The full text of this license
178can be found in the LICENSE file included with this module.
179
180=cut