WSST.pm untested

filter: Statementstmt 0.0% 0 / 79 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 118 CC 8 SCAR 21.5
CC
8
Cov
0%
generate
20.0
version
12.0
dumpschema
12.0
CRAP 8.6
1 package WSST;
2  
3 use strict;
4 use base qw(Exporter);
5 use vars qw($VERSION @EXPORT);
6 use Getopt::Long qw(:config no_ignore_case);
7 use Pod::Usage;
8 use WSST::SchemaParserManager;
9 use WSST::Generator;
10  
11 $VERSION = '0.1.1';
12  
13 @EXPORT = qw(generate help version dumpschema);
14  
15 sub generate {
16 my $opts = {};
17 GetOptions($opts,
18 "outdir|o=s",
19 "lang|l=s@",
20 "var|v=s@");
21  
22 my $path = shift(@ARGV);
23 die "not specified schema" unless $path;
24 die "cannot read schema: '$path'" unless -r $path;
25
26 my $odir = $opts->{outdir} || 'output';
27 die "invalid output dir: '$odir'" unless -d $odir;
28
29 my $spm = WSST::SchemaParserManager->instance;
30 my $sp = $spm->get_schema_parser($path);
31 my $schema = $sp->parse($path);
32
33 my $g = WSST::Generator->new();
34
35 $opts->{lang} ||= $g->generator_names;
36
37 foreach my $gn (@{$opts->{lang}}) {
38 print "[$gn]\n";
39 my $paths = $g->generate($gn, $schema, $opts);
40 print join("\n", @$paths), "\n\n";
41 }
42 }
43  
44 sub help {
45 pod2usage(input=>$INC{'WSST.pm'});
46 }
47  
48 sub version {
49 print "WSST $WSST::VERSION\n";
50 print "Copyright 2008 WSS Project Team\n";
51 print "\n";
52  
53 no strict 'refs';
54 my $list = [map {$WSST::{$_}} sort grep {/::$/} keys %WSST::];
55 while (my $ent = shift(@$list)) {
56 my $cls = "$ent";
57 next if $cls =~ /ISA::CACHE::$/;
58 $cls =~ s/^\*//;
59 $cls =~ s/::$//;
60 print "${cls}: ";
61 if (${$ent}{VERSION}) {
62 print ${${$ent}{VERSION}}, "\n";
63 } else {
64 print "(NO VERSION)\n";
65 }
66 push(@$list, map {${$ent}{$_}} sort grep {/::$/} keys %{$ent});
67 }
68 }
69  
70 sub dumpschema {
71 my $path = shift(@ARGV);
72 die "not specified schema" unless $path;
73 die "cannot read schema: '$path'" unless -r $path;
74
75 my $spm = WSST::SchemaParserManager->instance;
76 my $sp = $spm->get_schema_parser($path);
77 my $schema = $sp->parse($path);
78  
79 require Data::Dumper;
80 print Data::Dumper::Dumper($schema);
81 }
82  
83 =head1 NAME
84  
85 WSST - WebService Specification Schema Tool(WSST)
86  
87 =head1 SYNOPSIS
88  
89 perl -MWSST -e command [wss_file] [options]
90  
91 Commands:
92 generate generate modules
93 help print help message
94 version print version message
95 dumpschema dump schema object
96  
97 Options of generate command:
98 -o --outdir=dir set the output directory
99 -l --lang=lang specify a generate language
100 -v --var="name=val" set a variable
101  
102 =head1 OPTIONS
103  
104 =over 8
105  
106 =item B<-o,--outdir>
107  
108 Set the output directory. (default="output")
109  
110 =item B<-l,--lang>
111  
112 Specify a generate language.
113  
114 =item B<-v,--var>
115  
116 Set a variable.
117 This variable can be used from Template.
118  
119 =back
120  
121 =head1 DESCRIPTION
122  
123 WSST is a tool to generate libraries which manipulate web service.
124  
125 =head1 SEE ALSO
126  
127 http://code.google.com/p/wsst/
128  
129 =head1 AUTHORS
130  
131 Mitsuhisa Oshikawa <mitsuhisa [at] gmail.com>
132 Yusuke Kawasaki <u-suke [at] kawa.net>
133  
134 =head1 COPYRIGHT AND LICENSE
135  
136 Copyright 2008 WSS Project Team
137  
138 =cut
139 1;