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