1 package DBIx::Class::Optional::Dependencies;
8 # NO EXTERNAL NON-5.8.1 CORE DEPENDENCIES EVER (e.g. C::A::G)
9 # This module is to be loaded by Makefile.PM on a pristine system
11 # POD is generated automatically by calling _gen_pod from the
12 # Makefile.PL in $AUTHOR mode
16 'MooseX::Types' => '0.21',
21 #'Module::Install::Pod::Inherit' => '0.01',
27 'namespace::clean' => '0.11',
28 'Hash::Merge' => '0.11',
31 title => 'Storage::Replicated',
32 desc => 'Modules required for L<DBIx::Class::Storage::DBI::Replicated>',
39 'MooseX::Types::Path::Class'=> '0.05',
40 'MooseX::Types::JSON' => '0.02',
41 'Try::Tiny' => '0.02',
42 'namespace::autoclean' => '0.09',
44 'Getopt::Long::Descriptive' => '0.081',
45 'JSON::Any' => '1.22',
46 'Text::CSV' => '1.16',
52 'SQL::Translator' => '0.11002',
55 title => 'Storage::DBI::deploy()',
56 desc => 'Modules required for L<DBIx::Class::Storage::DBI/deploy> and L<DBIx::Class::Storage::DBI/deploymen_statements>',
62 'Test::Pod' => '1.26',
63 'Test::Pod::Coverage' => '1.08',
64 'Pod::Coverage' => '0.20',
65 #'Test::NoTabs' => '0.9',
66 #'Test::EOL' => '0.6',
73 'Test::Memory::Cycle' => '0',
74 'Devel::Cycle' => '1.10',
78 'DateTime::Format::SQLite' => '0',
80 # t/96_is_deteministic_value.t
81 'DateTime::Format::Strptime'=> '0',
87 'DBIx::ContextualFetch' => '0',
88 'Class::DBI::Plugin::DeepAbstractSearch' => '0',
89 'Class::Trigger' => '0',
90 'Time::Piece::MySQL' => '0',
92 'Date::Simple' => '3.03',
100 'Sys::SigAction' => '0',
101 'DBD::Pg' => '2.009002',
102 'DateTime::Format::Pg' => '0',
109 $ENV{DBICTEST_MYSQL_DSN}
111 'DateTime::Format::MySQL' => '0',
119 $ENV{DBICTEST_ORA_DSN}
121 'DateTime::Format::Oracle' => '0',
128 $ENV{DBICTEST_SYBASE_DSN}
130 'DateTime::Format::Sybase' => 0,
137 grep $_, @ENV{qw/DBICTEST_SYBASE_ASA_DSN DBICTEST_SYBASE_ASA_ODBC_DSN/}
139 'DateTime::Format::Strptime' => 0,
146 sub _all_optional_requirements {
147 return { map { %{ $reqs->{$_}{req} || {} } } (keys %$reqs) };
151 my ($class, $group) = @_;
153 croak "req_list_for() expects a requirement group name"
156 my $deps = $reqs->{$group}{req}
157 or croak "Requirement group '$group' does not exist";
163 our %req_availability_cache;
165 my ($class, $group) = @_;
167 croak "req_ok_for() expects a requirement group name"
170 $class->_check_deps ($group) unless $req_availability_cache{$group};
172 return $req_availability_cache{$group}{status};
175 sub req_missing_for {
176 my ($class, $group) = @_;
178 croak "req_missing_for() expects a requirement group name"
181 $class->_check_deps ($group) unless $req_availability_cache{$group};
183 return $req_availability_cache{$group}{missing};
186 sub req_errorlist_for {
187 my ($class, $group) = @_;
189 croak "req_errorlist_for() expects a requirement group name"
192 $class->_check_deps ($group) unless $req_availability_cache{$group};
194 return $req_availability_cache{$group}{errorlist};
198 my ($class, $group) = @_;
200 my $deps = $class->req_list_for ($group);
203 for my $mod (keys %$deps) {
204 if (my $ver = $deps->{$mod}) {
205 eval "use $mod $ver ()";
211 $errors{$mod} = $@ if $@;
215 my $missing = join (', ', map { $deps->{$_} ? "$_ >= $deps->{$_}" : $_ } (sort keys %errors) );
216 $missing .= " (see $class for details)" if $reqs->{$group}{pod};
217 $req_availability_cache{$group} = {
219 errorlist => { %errors },
224 $req_availability_cache{$group} = {
237 "$class - Optional module dependency specifications",
238 '=head1 DESCRIPTION',
240 Some of the less-frequently used features of L<DBIx::Class> have external
241 module dependencies on their own. In order not to burden the average user
242 with modules he will never use, these optional dependencies are not included
243 in the base Makefile.PL. Instead an exception with a descriptive message is
244 thrown when a specific feature is missing one or several modules required for
245 its operation. This module is the central holding place for the current list
246 of such dependencies.
248 '=head1 CURRENT REQUIREMENT GROUPS',
250 Dependencies are organized in C<groups> and each group can list one or more
251 required modules, with an optional minimum version (or 0 for any version).
252 The group name can be used in the
256 for my $group (sort keys %$reqs) {
257 my $p = $reqs->{$group}{pod}
260 my $modlist = $reqs->{$group}{req}
263 next unless keys %$modlist;
266 "=head2 $p->{title}",
269 ( map { "=item * $_" . ($modlist->{$_} ? " >= $modlist->{$_}" : '') } (sort keys %$modlist) ),
271 "Requirement group: B<$group>",
277 '=head2 req_list_for',
279 '=item Arguments: $group_name',
280 '=item Returns: \%list_of_module_version_pairs',
283 This method should be used by DBIx::Class extension authors, to determine the
284 version of modules which a specific feature requires in the current version of
285 DBIx::Class. For example if you write a module/extension that requires
286 DBIx::Class and also requires the availability of
287 L<DBIx::Class::Storage::DBI/deploy>, you can do the following in your
288 C<Makefile.PL> or C<Build.PL>
291 my \$dep_list = $class->req_list_for ('deploy');
293 Which will give you a list of module/version pairs necessary for the particular
294 feature to function with this version of DBIx::Class.
299 '=item Arguments: $group_name',
300 '=item Returns: 1|0',
302 'Returns true or false depending on whether all modules required by $group_name are present on the system and loadable',
304 '=head2 req_missing_for',
306 '=item Arguments: $group_name',
307 '=item Returns: $error_message_string',
310 Returns a single line string suitable for inclusion in larger error messages.
311 This method would normally be used by DBIx::Class core-module author, to
312 indicate to the user that he needs to install specific modules before he will
313 be able to use a specific feature.
315 For example if the requirements for C<replicated> are not available, the
316 returned string would look like:
318 Moose >= 0.98, MooseX::Types >= 0.21, namespace::clean (see $class for details)
320 The author is expected to prepend the necessary text to this message before
321 returning the actual error seen by the user.
324 '=head2 req_errorlist_for',
326 '=item Arguments: $group_name',
327 '=item Returns: \%list_of_loaderrors_per_module',
330 Returns a hashref containing the actual errors that occured while attempting
331 to load each module in the requirement group.
337 $fn =~ s/\.pm$/\.pod/;
339 open (my $fh, '>', $fn) or croak "Unable to write to $fn: $!";
340 print $fh join ("\n\n", @chunks);