File Coverage

blib/lib/Diamond.pm
Criterion Covered Total %
statement 12 49 24.4
branch 0 10 0.0
condition n/a
subroutine 4 12 33.3
pod 0 6 0.0
total 16 77 20.7


line stmt bran cond sub pod time code
1             package Diamond;
2              
3 1     1   22606 use strict;
  1         2  
  1         33  
4 1     1   19 use 5.008_001;
  1         3  
  1         45  
5             our $VERSION = '0.25';
6 1     1   7107 use ExtUtils::MakeMaker;
  1         144068  
  1         158  
7              
8 1     1   10 use base qw(Exporter);
  1         2  
  1         1068  
9             our @EXPORT = qw(git_clone);
10              
11             sub dependencies {
12             return (
13 0     0 0   'FastCGI daemon and dispatcher', 1, [
14             [ 'FCGI' ],
15             [ 'FCGI::Client' ],
16             [ 'FCGI::ProcManager' ],
17             [ 'Net::FastCGI' ],
18             ],
19             'Stacktrace with lexical variables', 0, [
20             [ 'Devel::StackTrace::WithLexicals' ],
21             ],
22             'Utility to create IO::Handle-ish objects', 1, [
23             [ 'IO::Handle::Util' ],
24             ],
25             'Core and Essential Tools', 1, [
26             [ 'PSGI', 'git://github.com/miyagawa/psgi-specs.git' ],
27             [ 'Plack', 'git://github.com/miyagawa/Plack.git' ],
28             [ 'CGI::PSGI', 'git://github.com/miyagawa/CGI-PSGI.git' ],
29             [ 'CGI::Emulate::PSGI', 'git://github.com/tokuhirom/p5-cgi-emulate-psgi.git' ],
30             [ 'CGI::Compile', 'git://github.com/miyagawa/CGI-Compile.git' ],
31             ],
32             'Recommended PSGI Servers and Plack handlers', 1, [
33             [ 'HTTP::Server::Simple::PSGI', 'git://github.com/miyagawa/HTTP-Server-Simple-PSGI.git' ],
34             [ 'Starman', 'git://github.com/miyagawa/Starman.git' ],
35             [ 'Twiggy', 'git://github.com/miyagawa/Twiggy.git' ],
36             [ 'Starlet', 'git://github.com/kazuho/Starlet.git' ],
37             [ 'Corona', 'git://github.com/miyagawa/Corona.git' ],
38             ],
39             'Extra PSGI servers and Plack handlers', 0, [
40             [ 'POE::Component::Server::PSGI', 'git://github.com/frodwith/Plack-Server-POE.git' ],
41             [ 'Plack::Handler::AnyEvent::ReverseHTTP', 'git://github.com/miyagawa/Plack-Handler-AnyEvent-ReverseHTTP.git' ],
42             [ 'Plack::Handler::SCGI', 'git://github.com/miyagawa/Plack-Handler-SCGI.git' ],
43             [ 'Plack::Handler::AnyEvent::SCGI', 'git://github.com/miyagawa/Plack-Handler-AnyEvent-SCGI.git' ],
44             [ 'Plack::Handler::AnyEvent::HTTPD', 'git://github.com/miyagawa/Plack-Handler-AnyEvent-HTTPD.git' ],
45             [ 'Plack::Handler::Mongrel2', 'git://github.com/lestrrat/Plack-Handler-Mongrel2.git' ],
46             [ 'Perlbal::Plugin::PSGI', 'git://github.com/miyagawa/Perlbal-Plugin-PSGI.git' ],
47             ],
48             'In-Development PSGI Servers', 0, [
49             [ undef, 'Plack::Server::Danga::Socket', 'git://github.com/typester/Plack-Server-Danga-Socket.git' ],
50             [ undef, 'Plack::Server::FCGI::EV', 'git://github.com/mala/Plack-Server-FCGI-EV.git' ],
51             [ undef, 'mod_psgi', 'git://github.com/spiritloose/mod_psgi.git' ],
52             [ undef, 'evpsgi', 'git://github.com/sekimura/evpsgi.git' ],
53             [ undef, 'nginx', 'git://github.com/yappo/nginx-psgi-patchs.git' ],
54             ],
55             'Recommended middleware components', 1, [
56             [ 'Plack::Middleware::Deflater', 'git://github.com/miyagawa/Plack-Middleware-Deflater.git' ],
57             [ 'Plack::Middleware::Session', 'git://github.com/stevan/plack-middleware-session.git' ],
58             [ 'Plack::Middleware::Debug', 'git://github.com/miyagawa/Plack-Middleware-Debug.git' ],
59             [ 'Plack::Middleware::Header', 'git://github.com/nihen/Plack-Middleware-Header.git' ],
60             [ 'Plack::Middleware::Auth::Digest', 'git://github.com/miyagawa/Plack-Middleware-Auth-Digest.git' ],
61             [ 'Plack::App::Proxy', 'git://github.com/leedo/Plack-App-Proxy.git' ],
62             [ 'Plack::Middleware::ReverseProxy', 'git://github.com/lopnor/Plack-Middleware-ReverseProxy.git' ],
63             [ 'Plack::Middleware::ConsoleLogger', 'git://github.com/miyagawa/Plack-Middleware-ConsoleLogger.git' ],
64             ],
65             'Extra Middleware Components', 0, [
66             [ 'Plack::Middleware::JSConcat', 'git://github.com/clkao/Plack-Middleware-JSConcat.git' ],
67             [ 'Plack::Middleware::Throttle', 'git://github.com/franckcuny/plack--middleware--throttle.git' ],
68             [ 'Plack::Middleware::Status', 'git://github.com/pdonelan/Plack-Middleware-Status.git' ],
69             [ 'Plack::Middleware::AutoRefresh', 'git://github.com/mvgrimes/Plack-Middleware-AutoRefresh.git' ],
70             [ undef, 'Plack::Middleware::Rewrite', 'git://github.com/snark/Plack-Middleware-Rewrite.git' ],
71             [ undef, 'Plack::Middleware::MobileDetector', 'git://github.com/snark/Plack-Middleware-MobileDetector.git' ],
72             [ undef, 'Plack::Middleware::FirePHP', 'git://github.com/fhelmberger/Plack-Middleware-FirePHP.git' ],
73             [ 'Plack::Middleware::File::Sass', 'git://github.com/miyagawa/Plack-Middleware-File-Sass.git' ],
74             [ undef, 'Plack::Middleware::ForgeryProtection', 'git://github.com/jyotty/Plack-Middleware-ForgeryProtection.git' ],
75             ],
76             'Tools', 0, [
77             [ 'Test::WWW::Mechanize::PSGI', 'git://github.com/acme/test-www-mechanize-psgi.git' ],
78             [ 'Flea', 'git://github.com/frodwith/flea.git' ],
79             ],
80             'Catalyst Engine', 0, [
81             [ 'Catalyst::Engine::PSGI', 'git://github.com/miyagawa/Catalyst-Engine-PSGI.git' ],
82             ],
83             'Squatting::On', 0, [
84             [ 'Squatting::On::PSGI', 'git://github.com/beppu/Squatting-On-PSGI.git' ],
85             ],
86             'Sledge', 0, [
87             [ undef, 'Sledge::PSGI', 'git://github.com/mala/Sledge-PSGI.git' ],
88             ],
89             'CGI::Application::PSGI', 0, [
90             [ 'CGI::Application::PSGI', 'git://github.com/markstos/CGI-Application-PSGI.git' ],
91             ],
92             'Maypole::PSGI', 0, [
93             [ undef, 'Maypole::PSGI', 'git://github.com/miyagawa/Maypole-PSGI.git' ],
94             ],
95             'Mason PSGI handler', 0, [
96             [ undef, 'HTML::Mason::PSGIHandler', 'git://github.com/rjbs/HTML-Mason-PSGIHandler.git' ],
97             ],
98             );
99             }
100              
101             sub has_module {
102 0     0 0   my $file = shift;
103 0           $file =~ s!::!/!g;
104 0           scalar grep -e "$_/$file.pm", @INC;
105             }
106              
107             sub iter_deps {
108 0     0 0   my($class, $cb) = @_;
109 0           my @deps = $class->dependencies;
110 0           while (my($name, $cond, $deps) = splice @deps, 0, 3) {
111 0           $cb->($name, $cond, $deps);
112             }
113             }
114              
115             sub makefile_pl {
116 0     0 0   my $class = shift;
117 0           my $fh = shift;
118              
119             $class->iter_deps(sub {
120 0     0     my($name, $cond, $deps) = @_;
121 0           my @modules = grep defined, map $_->[0], @$deps;
122 0           $fh->print("feature '$name', -default => $cond,\n");
123 0           for my $module (@modules) {
124 0           $fh->print(" '$module', '", version_for($module), "',\n");
125             }
126 0           $fh->print(";\n");
127 0           });
128             }
129              
130             sub version_for {
131 0     0 0   my $dist = shift;
132              
133 0           (my $module = $dist) =~ s/-/::/g;
134 0 0         my $info = `cpanm --info $module ` or return;
135 0           return ($info =~ /-([\d\.]+)\.tar\.gz/)[0];
136             }
137              
138             sub git_clone {
139 0     0 0   my @clone;
140             __PACKAGE__->iter_deps(sub {
141 0     0     my($name, $cond, $deps) = @_;
142 0 0         my @repos = map { shift @$_ unless $_->[0]; $_ } @$deps;
  0            
  0            
143              
144 0           print "[$name]\n";
145 0           for my $repo (@repos) {
146 0 0         next unless $repo->[1];
147 0           print "- $repo->[0] ($repo->[1])\n";
148             }
149              
150 0 0         my $prompt = ExtUtils::MakeMaker::prompt("Want to git clone them? ", $cond ? 'y' : 'n');
151 0 0         if (lc $prompt eq 'y') {
152 0           for my $repo (@repos) {
153 0           push @clone, $repo->[1];
154             }
155             }
156 0           });
157              
158 0           for my $repo (@clone) {
159 0           system "git", "clone", $repo;
160             }
161             }
162              
163             1;
164             __END__