Commit | Line | Data |
8057ed01 |
1 | package DBIx::Class::Optional::Dependencies; |
2 | |
3 | use warnings; |
4 | use strict; |
5 | |
9c1700e3 |
6 | use Carp (); |
fb39747c |
7 | |
8 | # NO EXTERNAL NON-5.8.1 CORE DEPENDENCIES EVER (e.g. C::A::G) |
8057ed01 |
9 | # This module is to be loaded by Makefile.PM on a pristine system |
10 | |
f6b26571 |
11 | # POD is generated automatically by calling _gen_pod from the |
12 | # Makefile.PL in $AUTHOR mode |
13 | |
2a2a7b23 |
14 | my $json_any = { |
15 | 'JSON::Any' => '1.22', |
16 | }; |
17 | |
2b48ebff |
18 | my $moose_basic = { |
68de9438 |
19 | 'Moose' => '0.98', |
20 | 'MooseX::Types' => '0.21', |
21 | }; |
22 | |
23 | my $replicated = { |
24 | %$moose_basic, |
2b48ebff |
25 | }; |
26 | |
ebcd0e4f |
27 | my $admin_basic = { |
28 | %$moose_basic, |
2a2a7b23 |
29 | %$json_any, |
68de9438 |
30 | 'MooseX::Types::Path::Class' => '0.05', |
31 | 'MooseX::Types::JSON' => '0.02', |
68de9438 |
32 | 'namespace::autoclean' => '0.09', |
33 | }; |
34 | |
a0361822 |
35 | my $admin_script = { |
36 | %$moose_basic, |
37 | %$admin_basic, |
38 | 'Getopt::Long::Descriptive' => '0.081', |
39 | 'Text::CSV' => '1.16', |
40 | }; |
41 | |
68de9438 |
42 | my $datetime_basic = { |
43 | 'DateTime' => '0.55', |
44 | 'DateTime::Format::Strptime' => '1.2', |
ebcd0e4f |
45 | }; |
46 | |
c7d50a7d |
47 | my $id_shortener = { |
26022fb5 |
48 | 'Math::BigInt' => '1.80', |
c7d50a7d |
49 | 'Math::Base36' => '0.07', |
50 | }; |
51 | |
be68095d |
52 | my $rdbms_sqlite = { |
53 | 'DBD::SQLite' => '0', |
54 | }; |
55 | my $rdbms_pg = { |
56 | 'DBD::Pg' => '0', |
57 | }; |
58 | my $rdbms_mssql_odbc = { |
59 | 'DBD::ODBC' => '0', |
60 | }; |
61 | my $rdbms_mssql_sybase = { |
62 | 'DBD::Sybase' => '0', |
63 | }; |
56dca25f |
64 | my $rdbms_mssql_ado = { |
65 | 'DBD::ADO' => '0', |
66 | }; |
726c8f65 |
67 | my $rdbms_msaccess_odbc = { |
68 | 'DBD::ODBC' => '0', |
69 | }; |
70 | my $rdbms_msaccess_ado = { |
71 | 'DBD::ADO' => '0', |
72 | }; |
be68095d |
73 | my $rdbms_mysql = { |
74 | 'DBD::mysql' => '0', |
75 | }; |
76 | my $rdbms_oracle = { |
77 | 'DBD::Oracle' => '0', |
78 | %$id_shortener, |
79 | }; |
80 | my $rdbms_ase = { |
81 | 'DBD::Sybase' => '0', |
82 | }; |
83 | my $rdbms_db2 = { |
84 | 'DBD::DB2' => '0', |
85 | }; |
199fbc45 |
86 | my $rdbms_db2_400 = { |
87 | 'DBD::ODBC' => '0', |
88 | }; |
89 | my $rdbms_informix = { |
90 | 'DBD::Informix' => '0', |
91 | }; |
92 | my $rdbms_sqlanywhere = { |
93 | 'DBD::SQLAnywhere' => '0', |
94 | }; |
95 | my $rdbms_sqlanywhere_odbc = { |
96 | 'DBD::ODBC' => '0', |
97 | }; |
98 | my $rdbms_firebird = { |
99 | 'DBD::Firebird' => '0', |
100 | }; |
101 | my $rdbms_firebird_interbase = { |
102 | 'DBD::InterBase' => '0', |
103 | }; |
e02b39b4 |
104 | my $rdbms_firebird_odbc = { |
105 | 'DBD::ODBC' => '0', |
106 | }; |
be68095d |
107 | |
8057ed01 |
108 | my $reqs = { |
109 | dist => { |
110 | #'Module::Install::Pod::Inherit' => '0.01', |
111 | }, |
112 | |
113 | replicated => { |
68de9438 |
114 | req => $replicated, |
f6b26571 |
115 | pod => { |
116 | title => 'Storage::Replicated', |
117 | desc => 'Modules required for L<DBIx::Class::Storage::DBI::Replicated>', |
118 | }, |
8057ed01 |
119 | }, |
120 | |
68de9438 |
121 | test_replicated => { |
122 | req => { |
123 | %$replicated, |
124 | 'Test::Moose' => '0', |
125 | }, |
126 | }, |
127 | |
128 | |
8057ed01 |
129 | admin => { |
2b48ebff |
130 | req => { |
ebcd0e4f |
131 | %$admin_basic, |
132 | }, |
133 | pod => { |
134 | title => 'DBIx::Class::Admin', |
135 | desc => 'Modules required for the DBIx::Class administrative library', |
136 | }, |
137 | }, |
138 | |
a4a02f15 |
139 | admin_script => { |
ebcd0e4f |
140 | req => { |
a0361822 |
141 | %$admin_script, |
2b48ebff |
142 | }, |
e144415f |
143 | pod => { |
144 | title => 'dbicadmin', |
145 | desc => 'Modules required for the CLI DBIx::Class interface dbicadmin', |
146 | }, |
8057ed01 |
147 | }, |
148 | |
a0361822 |
149 | test_admin_script => { |
150 | req => { |
151 | %$admin_script, |
152 | ($^O eq 'MSWin32' ? ('Win32::ShellQuote' => 0) : ()), |
153 | } |
154 | }, |
155 | |
8057ed01 |
156 | deploy => { |
f6b26571 |
157 | req => { |
9e34d554 |
158 | 'SQL::Translator' => '0.11006', |
f6b26571 |
159 | }, |
160 | pod => { |
161 | title => 'Storage::DBI::deploy()', |
c7d50a7d |
162 | desc => 'Modules required for L<DBIx::Class::Storage::DBI/deploy> and L<DBIx::Class::Storage::DBI/deployment_statements>', |
f6b26571 |
163 | }, |
8057ed01 |
164 | }, |
165 | |
c7d50a7d |
166 | id_shortener => { |
167 | req => $id_shortener, |
168 | }, |
169 | |
0d374214 |
170 | test_component_accessor => { |
171 | req => { |
172 | 'Class::Unload' => '0.07', |
173 | }, |
174 | }, |
175 | |
a109c954 |
176 | test_pod => { |
f6b26571 |
177 | req => { |
14d17d71 |
178 | 'Test::Pod' => '1.41', |
a109c954 |
179 | }, |
180 | }, |
181 | |
182 | test_podcoverage => { |
183 | req => { |
f6b26571 |
184 | 'Test::Pod::Coverage' => '1.08', |
185 | 'Pod::Coverage' => '0.20', |
a109c954 |
186 | }, |
187 | }, |
188 | |
189 | test_notabs => { |
190 | req => { |
d146b340 |
191 | 'Test::NoTabs' => '0.9', |
a109c954 |
192 | }, |
193 | }, |
194 | |
195 | test_eol => { |
196 | req => { |
8273e845 |
197 | 'Test::EOL' => '1.0', |
f6b26571 |
198 | }, |
8057ed01 |
199 | }, |
200 | |
2a2a7b23 |
201 | test_prettydebug => { |
202 | req => $json_any, |
203 | }, |
204 | |
226d1c35 |
205 | test_leaks => { |
f6b26571 |
206 | req => { |
f6b26571 |
207 | 'Test::Memory::Cycle' => '0', |
208 | 'Devel::Cycle' => '1.10', |
a109c954 |
209 | }, |
210 | }, |
f6b26571 |
211 | |
68de9438 |
212 | test_dt => { |
213 | req => $datetime_basic, |
214 | }, |
215 | |
216 | test_dt_sqlite => { |
a109c954 |
217 | req => { |
68de9438 |
218 | %$datetime_basic, |
f6b26571 |
219 | # t/36datetime.t |
220 | # t/60core.t |
221 | 'DateTime::Format::SQLite' => '0', |
68de9438 |
222 | }, |
223 | }, |
f6b26571 |
224 | |
68de9438 |
225 | test_dt_mysql => { |
226 | req => { |
227 | %$datetime_basic, |
9c92bb1c |
228 | # t/inflate/datetime_mysql.t |
229 | # (doesn't need Mysql itself) |
68de9438 |
230 | 'DateTime::Format::MySQL' => '0', |
231 | }, |
232 | }, |
9c92bb1c |
233 | |
68de9438 |
234 | test_dt_pg => { |
235 | req => { |
236 | %$datetime_basic, |
9c92bb1c |
237 | # t/inflate/datetime_pg.t |
238 | # (doesn't need PG itself) |
ab35aeab |
239 | 'DateTime::Format::Pg' => '0.16004', |
f6b26571 |
240 | }, |
8057ed01 |
241 | }, |
242 | |
68de9438 |
243 | test_cdbicompat => { |
f6b26571 |
244 | req => { |
d9bd5195 |
245 | 'Class::DBI' => 0, |
f6b26571 |
246 | 'Class::DBI::Plugin::DeepAbstractSearch' => '0', |
d9bd5195 |
247 | %$datetime_basic, |
f6b26571 |
248 | 'Time::Piece::MySQL' => '0', |
f6b26571 |
249 | 'Date::Simple' => '3.03', |
250 | }, |
8057ed01 |
251 | }, |
252 | |
be68095d |
253 | # this is just for completeness as SQLite |
254 | # is a core dep of DBIC for testing |
255 | rdbms_sqlite => { |
256 | req => { |
257 | %$rdbms_sqlite, |
258 | }, |
259 | pod => { |
260 | title => 'SQLite support', |
261 | desc => 'Modules required to connect to SQLite', |
262 | }, |
263 | }, |
264 | |
265 | rdbms_pg => { |
266 | req => { |
a4fc1239 |
267 | # when changing this list make sure to adjust xt/optional_deps.t |
be68095d |
268 | %$rdbms_pg, |
269 | }, |
270 | pod => { |
271 | title => 'PostgreSQL support', |
272 | desc => 'Modules required to connect to PostgreSQL', |
273 | }, |
274 | }, |
275 | |
276 | rdbms_mssql_odbc => { |
277 | req => { |
278 | %$rdbms_mssql_odbc, |
279 | }, |
280 | pod => { |
281 | title => 'MSSQL support via DBD::ODBC', |
282 | desc => 'Modules required to connect to MSSQL via DBD::ODBC', |
283 | }, |
284 | }, |
285 | |
286 | rdbms_mssql_sybase => { |
287 | req => { |
288 | %$rdbms_mssql_sybase, |
289 | }, |
290 | pod => { |
291 | title => 'MSSQL support via DBD::Sybase', |
56dca25f |
292 | desc => 'Modules required to connect to MSSQL via DBD::Sybase', |
293 | }, |
294 | }, |
295 | |
296 | rdbms_mssql_ado => { |
297 | req => { |
298 | %$rdbms_mssql_ado, |
299 | }, |
300 | pod => { |
301 | title => 'MSSQL support via DBD::ADO (Windows only)', |
302 | desc => 'Modules required to connect to MSSQL via DBD::ADO. This particular DBD is available on Windows only', |
be68095d |
303 | }, |
304 | }, |
305 | |
726c8f65 |
306 | rdbms_msaccess_odbc => { |
307 | req => { |
308 | %$rdbms_msaccess_odbc, |
309 | }, |
310 | pod => { |
311 | title => 'MS Access support via DBD::ODBC', |
312 | desc => 'Modules required to connect to MS Access via DBD::ODBC', |
313 | }, |
314 | }, |
315 | |
316 | rdbms_msaccess_ado => { |
317 | req => { |
318 | %$rdbms_msaccess_ado, |
319 | }, |
320 | pod => { |
321 | title => 'MS Access support via DBD::ADO (Windows only)', |
322 | desc => 'Modules required to connect to MS Access via DBD::ADO. This particular DBD is available on Windows only', |
323 | }, |
324 | }, |
325 | |
be68095d |
326 | rdbms_mysql => { |
327 | req => { |
328 | %$rdbms_mysql, |
329 | }, |
330 | pod => { |
331 | title => 'MySQL support', |
332 | desc => 'Modules required to connect to MySQL', |
333 | }, |
334 | }, |
335 | |
336 | rdbms_oracle => { |
337 | req => { |
338 | %$rdbms_oracle, |
339 | }, |
340 | pod => { |
341 | title => 'Oracle support', |
342 | desc => 'Modules required to connect to Oracle', |
343 | }, |
344 | }, |
345 | |
346 | rdbms_ase => { |
347 | req => { |
348 | %$rdbms_ase, |
349 | }, |
350 | pod => { |
351 | title => 'Sybase ASE support', |
352 | desc => 'Modules required to connect to Sybase ASE', |
353 | }, |
354 | }, |
355 | |
356 | rdbms_db2 => { |
357 | req => { |
358 | %$rdbms_db2, |
359 | }, |
360 | pod => { |
361 | title => 'DB2 support', |
362 | desc => 'Modules required to connect to DB2', |
363 | }, |
364 | }, |
365 | |
199fbc45 |
366 | rdbms_db2_400 => { |
367 | req => { |
368 | %$rdbms_db2_400, |
369 | }, |
370 | pod => { |
371 | title => 'DB2 on AS/400 support', |
372 | desc => 'Modules required to connect to DB2 on AS/400', |
373 | }, |
374 | }, |
375 | |
376 | rdbms_informix => { |
377 | req => { |
378 | %$rdbms_informix, |
379 | }, |
380 | pod => { |
381 | title => 'Informix support', |
382 | desc => 'Modules required to connect to Informix', |
383 | }, |
8273e845 |
384 | }, |
199fbc45 |
385 | |
386 | rdbms_sqlanywhere => { |
387 | req => { |
388 | %$rdbms_sqlanywhere, |
389 | }, |
390 | pod => { |
391 | title => 'SQLAnywhere support', |
392 | desc => 'Modules required to connect to SQLAnywhere', |
393 | }, |
8273e845 |
394 | }, |
199fbc45 |
395 | |
396 | rdbms_sqlanywhere_odbc => { |
397 | req => { |
398 | %$rdbms_sqlanywhere_odbc, |
399 | }, |
400 | pod => { |
401 | title => 'SQLAnywhere support via DBD::ODBC', |
402 | desc => 'Modules required to connect to SQLAnywhere via DBD::ODBC', |
403 | }, |
8273e845 |
404 | }, |
199fbc45 |
405 | |
406 | rdbms_firebird => { |
407 | req => { |
408 | %$rdbms_firebird, |
409 | }, |
410 | pod => { |
411 | title => 'Firebird support', |
412 | desc => 'Modules required to connect to Firebird', |
413 | }, |
8273e845 |
414 | }, |
199fbc45 |
415 | |
416 | rdbms_firebird_interbase => { |
417 | req => { |
418 | %$rdbms_firebird_interbase, |
419 | }, |
420 | pod => { |
421 | title => 'Firebird support via DBD::InterBase', |
422 | desc => 'Modules required to connect to Firebird via DBD::InterBase', |
423 | }, |
8273e845 |
424 | }, |
199fbc45 |
425 | |
426 | rdbms_firebird_odbc => { |
427 | req => { |
428 | %$rdbms_firebird_odbc, |
429 | }, |
430 | pod => { |
431 | title => 'Firebird support via DBD::ODBC', |
432 | desc => 'Modules required to connect to Firebird via DBD::ODBC', |
433 | }, |
8273e845 |
434 | }, |
199fbc45 |
435 | |
be68095d |
436 | # the order does matter because the rdbms support group might require |
437 | # a different version that the test group |
68de9438 |
438 | test_rdbms_pg => { |
f6b26571 |
439 | req => { |
440 | $ENV{DBICTEST_PG_DSN} |
441 | ? ( |
a4fc1239 |
442 | # when changing this list make sure to adjust xt/optional_deps.t |
be68095d |
443 | %$rdbms_pg, |
b9d84a2d |
444 | ($^O ne 'MSWin32' ? ('Sys::SigAction' => '0') : ()), |
f6b26571 |
445 | 'DBD::Pg' => '2.009002', |
f6b26571 |
446 | ) : () |
447 | }, |
8057ed01 |
448 | }, |
449 | |
afae8507 |
450 | test_rdbms_mssql_odbc => { |
451 | req => { |
452 | $ENV{DBICTEST_MSSQL_ODBC_DSN} |
453 | ? ( |
be68095d |
454 | %$rdbms_mssql_odbc, |
afae8507 |
455 | ) : () |
456 | }, |
457 | }, |
458 | |
56dca25f |
459 | test_rdbms_mssql_ado => { |
460 | req => { |
461 | $ENV{DBICTEST_MSSQL_ADO_DSN} |
462 | ? ( |
463 | %$rdbms_mssql_ado, |
464 | ) : () |
465 | }, |
466 | }, |
467 | |
afae8507 |
468 | test_rdbms_mssql_sybase => { |
469 | req => { |
470 | $ENV{DBICTEST_MSSQL_DSN} |
471 | ? ( |
be68095d |
472 | %$rdbms_mssql_sybase, |
afae8507 |
473 | ) : () |
474 | }, |
475 | }, |
476 | |
726c8f65 |
477 | test_rdbms_msaccess_odbc => { |
478 | req => { |
479 | $ENV{DBICTEST_MSACCESS_ODBC_DSN} |
480 | ? ( |
481 | %$rdbms_msaccess_odbc, |
482 | %$datetime_basic, |
483 | 'Data::GUID' => '0', |
484 | ) : () |
485 | }, |
486 | }, |
487 | |
488 | test_rdbms_msaccess_ado => { |
489 | req => { |
490 | $ENV{DBICTEST_MSACCESS_ADO_DSN} |
491 | ? ( |
492 | %$rdbms_msaccess_ado, |
493 | %$datetime_basic, |
494 | 'Data::GUID' => 0, |
495 | ) : () |
496 | }, |
497 | }, |
498 | |
68de9438 |
499 | test_rdbms_mysql => { |
f6b26571 |
500 | req => { |
501 | $ENV{DBICTEST_MYSQL_DSN} |
502 | ? ( |
be68095d |
503 | %$rdbms_mysql, |
f6b26571 |
504 | ) : () |
505 | }, |
8057ed01 |
506 | }, |
507 | |
68de9438 |
508 | test_rdbms_oracle => { |
f6b26571 |
509 | req => { |
510 | $ENV{DBICTEST_ORA_DSN} |
511 | ? ( |
be68095d |
512 | %$rdbms_oracle, |
f6b26571 |
513 | 'DateTime::Format::Oracle' => '0', |
e1b7e9b4 |
514 | 'DBD::Oracle' => '1.24', |
f6b26571 |
515 | ) : () |
516 | }, |
8057ed01 |
517 | }, |
518 | |
68de9438 |
519 | test_rdbms_ase => { |
f6b26571 |
520 | req => { |
521 | $ENV{DBICTEST_SYBASE_DSN} |
522 | ? ( |
be68095d |
523 | %$rdbms_ase, |
f6b26571 |
524 | ) : () |
525 | }, |
8057ed01 |
526 | }, |
527 | |
68de9438 |
528 | test_rdbms_db2 => { |
f58a165c |
529 | req => { |
530 | $ENV{DBICTEST_DB2_DSN} |
531 | ? ( |
be68095d |
532 | %$rdbms_db2, |
f58a165c |
533 | ) : () |
534 | }, |
535 | }, |
536 | |
199fbc45 |
537 | test_rdbms_db2_400 => { |
538 | req => { |
539 | $ENV{DBICTEST_DB2_400_DSN} |
540 | ? ( |
541 | %$rdbms_db2_400, |
542 | ) : () |
543 | }, |
544 | }, |
545 | |
546 | test_rdbms_informix => { |
547 | req => { |
548 | $ENV{DBICTEST_INFORMIX_DSN} |
549 | ? ( |
550 | %$rdbms_informix, |
551 | ) : () |
552 | }, |
553 | }, |
554 | |
555 | test_rdbms_sqlanywhere => { |
556 | req => { |
557 | $ENV{DBICTEST_SQLANYWHERE_DSN} |
558 | ? ( |
559 | %$rdbms_sqlanywhere, |
560 | ) : () |
561 | }, |
562 | }, |
563 | |
564 | test_rdbms_sqlanywhere_odbc => { |
565 | req => { |
566 | $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN} |
567 | ? ( |
568 | %$rdbms_sqlanywhere_odbc, |
569 | ) : () |
570 | }, |
571 | }, |
572 | |
573 | test_rdbms_firebird => { |
574 | req => { |
575 | $ENV{DBICTEST_FIREBIRD_DSN} |
576 | ? ( |
577 | %$rdbms_firebird, |
578 | ) : () |
579 | }, |
580 | }, |
581 | |
582 | test_rdbms_firebird_interbase => { |
583 | req => { |
584 | $ENV{DBICTEST_FIREBIRD_INTERBASE_DSN} |
585 | ? ( |
586 | %$rdbms_firebird_interbase, |
587 | ) : () |
588 | }, |
589 | }, |
590 | |
e02b39b4 |
591 | test_rdbms_firebird_odbc => { |
592 | req => { |
593 | $ENV{DBICTEST_FIREBIRD_ODBC_DSN} |
594 | ? ( |
595 | %$rdbms_firebird_odbc, |
596 | ) : () |
597 | }, |
598 | }, |
599 | |
42168332 |
600 | test_memcached => { |
601 | req => { |
602 | $ENV{DBICTEST_MEMCACHED} |
603 | ? ( |
604 | 'Cache::Memcached' => 0, |
605 | ) : () |
606 | }, |
607 | }, |
608 | |
8057ed01 |
609 | }; |
610 | |
f6b26571 |
611 | |
fb39747c |
612 | sub req_list_for { |
613 | my ($class, $group) = @_; |
614 | |
9c1700e3 |
615 | Carp::croak "req_list_for() expects a requirement group name" |
fb39747c |
616 | unless $group; |
617 | |
f6b26571 |
618 | my $deps = $reqs->{$group}{req} |
9c1700e3 |
619 | or Carp::croak "Requirement group '$group' does not exist"; |
fb39747c |
620 | |
621 | return { %$deps }; |
622 | } |
623 | |
624 | |
625 | our %req_availability_cache; |
626 | sub req_ok_for { |
627 | my ($class, $group) = @_; |
628 | |
9c1700e3 |
629 | Carp::croak "req_ok_for() expects a requirement group name" |
fb39747c |
630 | unless $group; |
631 | |
d8799bab |
632 | return $class->_check_deps($group)->{status}; |
fb39747c |
633 | } |
634 | |
635 | sub req_missing_for { |
636 | my ($class, $group) = @_; |
637 | |
9c1700e3 |
638 | Carp::croak "req_missing_for() expects a requirement group name" |
fb39747c |
639 | unless $group; |
640 | |
d8799bab |
641 | return $class->_check_deps($group)->{missing}; |
fb39747c |
642 | } |
643 | |
644 | sub req_errorlist_for { |
645 | my ($class, $group) = @_; |
646 | |
9c1700e3 |
647 | Carp::croak "req_errorlist_for() expects a requirement group name" |
fb39747c |
648 | unless $group; |
649 | |
d8799bab |
650 | return $class->_check_deps($group)->{errorlist}; |
fb39747c |
651 | } |
652 | |
653 | sub _check_deps { |
654 | my ($class, $group) = @_; |
655 | |
d8799bab |
656 | return $req_availability_cache{$group} ||= do { |
657 | |
658 | my $deps = $class->req_list_for ($group); |
659 | |
660 | my %errors; |
661 | for my $mod (keys %$deps) { |
662 | my $req_line = "require $mod;"; |
663 | if (my $ver = $deps->{$mod}) { |
664 | $req_line .= "$mod->VERSION($ver);"; |
665 | } |
666 | |
667 | eval $req_line; |
668 | |
669 | $errors{$mod} = $@ if $@; |
670 | } |
671 | |
672 | my $res; |
fb39747c |
673 | |
d8799bab |
674 | if (keys %errors) { |
675 | my $missing = join (', ', map { $deps->{$_} ? "$_ >= $deps->{$_}" : $_ } (sort keys %errors) ); |
676 | $missing .= " (see $class for details)" if $reqs->{$group}{pod}; |
677 | $res = { |
678 | status => 0, |
679 | errorlist => \%errors, |
680 | missing => $missing, |
681 | }; |
fb39747c |
682 | } |
683 | else { |
d8799bab |
684 | $res = { |
685 | status => 1, |
686 | errorlist => {}, |
687 | missing => '', |
688 | }; |
fb39747c |
689 | } |
690 | |
d8799bab |
691 | $res; |
692 | }; |
fb39747c |
693 | } |
694 | |
e3fc11e1 |
695 | sub req_group_list { |
696 | return { map { $_ => { %{ $reqs->{$_}{req} || {} } } } (keys %$reqs) }; |
697 | } |
698 | |
699 | # This is to be called by the author only (automatically in Makefile.PL) |
f6b26571 |
700 | sub _gen_pod { |
ccebe1f1 |
701 | my ($class, $distver) = @_; |
31fa1764 |
702 | |
af4ac504 |
703 | my $modfn = __PACKAGE__ . '.pm'; |
704 | $modfn =~ s/\:\:/\//g; |
f6b26571 |
705 | |
31fa1764 |
706 | my $podfn = __FILE__; |
707 | $podfn =~ s/\.pm$/\.pod/; |
708 | |
ccebe1f1 |
709 | $distver ||= |
31fa1764 |
710 | eval { require DBIx::Class; DBIx::Class->VERSION; } |
711 | || |
ccebe1f1 |
712 | die |
31fa1764 |
713 | "\n\n---------------------------------------------------------------------\n" . |
714 | 'Unable to load core DBIx::Class module to determine current version, '. |
715 | 'possibly due to missing dependencies. Author-mode autodocumentation ' . |
716 | "halted\n\n" . $@ . |
717 | "\n\n---------------------------------------------------------------------\n" |
31fa1764 |
718 | ; |
719 | |
e3fc11e1 |
720 | my $sqltver = $class->req_list_for ('deploy')->{'SQL::Translator'} |
721 | or die "Hrmm? No sqlt dep?"; |
7e3dc46f |
722 | |
f6b26571 |
723 | my @chunks = ( |
d8799bab |
724 | <<'EOC', |
af4ac504 |
725 | ######################################################################### |
726 | ##################### A U T O G E N E R A T E D ######################## |
727 | ######################################################################### |
728 | # |
729 | # The contents of this POD file are auto-generated. Any changes you make |
730 | # will be lost. If you need to change the generated text edit _gen_pod() |
731 | # at the end of $modfn |
732 | # |
733 | EOC |
f6b26571 |
734 | '=head1 NAME', |
7e3dc46f |
735 | "$class - Optional module dependency specifications (for module authors)", |
e3fc11e1 |
736 | '=head1 SYNOPSIS', |
d8799bab |
737 | <<"EOS", |
7e3dc46f |
738 | Somewhere in your build-file (e.g. L<Module::Install>'s Makefile.PL): |
739 | |
740 | ... |
741 | |
742 | configure_requires 'DBIx::Class' => '$distver'; |
743 | |
744 | require $class; |
745 | |
be68095d |
746 | my \$deploy_deps = $class->req_list_for('deploy'); |
7e3dc46f |
747 | |
748 | for (keys %\$deploy_deps) { |
749 | requires \$_ => \$deploy_deps->{\$_}; |
750 | } |
751 | |
752 | ... |
753 | |
754 | Note that there are some caveats regarding C<configure_requires()>, more info |
755 | can be found at L<Module::Install/configure_requires> |
756 | EOS |
f6b26571 |
757 | '=head1 DESCRIPTION', |
758 | <<'EOD', |
759 | Some of the less-frequently used features of L<DBIx::Class> have external |
760 | module dependencies on their own. In order not to burden the average user |
761 | with modules he will never use, these optional dependencies are not included |
762 | in the base Makefile.PL. Instead an exception with a descriptive message is |
763 | thrown when a specific feature is missing one or several modules required for |
764 | its operation. This module is the central holding place for the current list |
7e3dc46f |
765 | of such dependencies, for DBIx::Class core authors, and DBIx::Class extension |
766 | authors alike. |
f6b26571 |
767 | EOD |
768 | '=head1 CURRENT REQUIREMENT GROUPS', |
769 | <<'EOD', |
770 | Dependencies are organized in C<groups> and each group can list one or more |
771 | required modules, with an optional minimum version (or 0 for any version). |
ecb68746 |
772 | The group name can be used in the |
f6b26571 |
773 | EOD |
774 | ); |
775 | |
776 | for my $group (sort keys %$reqs) { |
777 | my $p = $reqs->{$group}{pod} |
778 | or next; |
779 | |
780 | my $modlist = $reqs->{$group}{req} |
781 | or next; |
782 | |
783 | next unless keys %$modlist; |
784 | |
785 | push @chunks, ( |
786 | "=head2 $p->{title}", |
787 | "$p->{desc}", |
788 | '=over', |
789 | ( map { "=item * $_" . ($modlist->{$_} ? " >= $modlist->{$_}" : '') } (sort keys %$modlist) ), |
790 | '=back', |
791 | "Requirement group: B<$group>", |
792 | ); |
793 | } |
794 | |
795 | push @chunks, ( |
796 | '=head1 METHODS', |
e3fc11e1 |
797 | '=head2 req_group_list', |
798 | '=over', |
d8799bab |
799 | '=item Arguments: none', |
e3fc11e1 |
800 | '=item Returns: \%list_of_requirement_groups', |
801 | '=back', |
d8799bab |
802 | <<'EOD', |
e3fc11e1 |
803 | This method should be used by DBIx::Class packagers, to get a hashref of all |
804 | dependencies keyed by dependency group. Each key (group name) can be supplied |
805 | to one of the group-specific methods below. |
806 | EOD |
807 | |
f6b26571 |
808 | '=head2 req_list_for', |
809 | '=over', |
810 | '=item Arguments: $group_name', |
811 | '=item Returns: \%list_of_module_version_pairs', |
812 | '=back', |
d8799bab |
813 | <<'EOD', |
f6b26571 |
814 | This method should be used by DBIx::Class extension authors, to determine the |
7e3dc46f |
815 | version of modules a specific feature requires in the B<current> version of |
e3fc11e1 |
816 | DBIx::Class. See the L</SYNOPSIS> for a real-world |
7e3dc46f |
817 | example. |
f6b26571 |
818 | EOD |
819 | |
820 | '=head2 req_ok_for', |
821 | '=over', |
822 | '=item Arguments: $group_name', |
823 | '=item Returns: 1|0', |
824 | '=back', |
d8799bab |
825 | <<'EOD', |
826 | Returns true or false depending on whether all modules required by |
827 | C<$group_name> are present on the system and loadable. |
828 | EOD |
f6b26571 |
829 | |
830 | '=head2 req_missing_for', |
831 | '=over', |
832 | '=item Arguments: $group_name', |
833 | '=item Returns: $error_message_string', |
834 | '=back', |
d8799bab |
835 | <<"EOD", |
f6b26571 |
836 | Returns a single line string suitable for inclusion in larger error messages. |
837 | This method would normally be used by DBIx::Class core-module author, to |
838 | indicate to the user that he needs to install specific modules before he will |
839 | be able to use a specific feature. |
840 | |
e3fc11e1 |
841 | For example if some of the requirements for C<deploy> are not available, |
842 | the returned string could look like: |
f6b26571 |
843 | |
e3fc11e1 |
844 | SQL::Translator >= $sqltver (see $class for details) |
f6b26571 |
845 | |
846 | The author is expected to prepend the necessary text to this message before |
847 | returning the actual error seen by the user. |
848 | EOD |
849 | |
850 | '=head2 req_errorlist_for', |
851 | '=over', |
852 | '=item Arguments: $group_name', |
853 | '=item Returns: \%list_of_loaderrors_per_module', |
854 | '=back', |
855 | <<'EOD', |
856 | Returns a hashref containing the actual errors that occured while attempting |
857 | to load each module in the requirement group. |
858 | EOD |
fb8ae353 |
859 | '=head1 AUTHOR', |
860 | 'See L<DBIx::Class/CONTRIBUTORS>.', |
861 | '=head1 LICENSE', |
862 | 'You may distribute this code under the same terms as Perl itself', |
f6b26571 |
863 | ); |
864 | |
9c1700e3 |
865 | open (my $fh, '>', $podfn) or Carp::croak "Unable to write to $podfn: $!"; |
f6b26571 |
866 | print $fh join ("\n\n", @chunks); |
867 | close ($fh); |
868 | } |
869 | |
8057ed01 |
870 | 1; |