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