line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WSST::Schema::Method; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
26
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
180
|
|
4
|
5
|
|
|
5
|
|
25
|
use base qw(WSST::Schema::Base); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
464
|
|
5
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(name title desc url params params_footnotes return |
6
|
|
|
|
|
|
|
return_footnotes error error_footnotes tests |
7
|
|
|
|
|
|
|
sample_response)); |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
2639
|
use WSST::Schema::Param; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
42
|
|
10
|
5
|
|
|
5
|
|
2923
|
use WSST::Schema::Return; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
44
|
|
11
|
5
|
|
|
5
|
|
2653
|
use WSST::Schema::Error; |
|
5
|
|
|
|
|
23
|
|
|
5
|
|
|
|
|
44
|
|
12
|
5
|
|
|
5
|
|
3502
|
use WSST::Schema::Test; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
58
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.1.1'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
3
|
|
|
3
|
1
|
7
|
my $class = shift; |
18
|
3
|
|
|
|
|
31
|
my $self = $class->SUPER::new(@_); |
19
|
3
|
100
|
|
|
|
34
|
if ($self->{params}) { |
20
|
1
|
|
|
|
|
2
|
foreach my $param (@{$self->{params}}) { |
|
1
|
|
|
|
|
4
|
|
21
|
2
|
|
|
|
|
15
|
$param = WSST::Schema::Param->new($param); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
3
|
|
|
|
|
37
|
$self->{return} = WSST::Schema::Return->new($self->{return}); |
25
|
3
|
|
|
|
|
45
|
$self->{error} = WSST::Schema::Error->new($self->{error}); |
26
|
3
|
100
|
|
|
|
25
|
if ($self->tests) { |
27
|
1
|
|
|
|
|
8
|
foreach my $test (@{$self->{tests}}) { |
|
1
|
|
|
|
|
4
|
|
28
|
3
|
|
|
|
|
18
|
$test = WSST::Schema::Test->new($test); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
3
|
|
|
|
|
18
|
foreach my $fld_base (qw(params return error)) { |
32
|
9
|
|
|
|
|
17
|
my $fld = "${fld_base}_footnotes"; |
33
|
9
|
50
|
|
|
|
34
|
next unless defined $self->{$fld}; |
34
|
0
|
|
|
|
|
0
|
my $ref = ref $self->{$fld}; |
35
|
0
|
0
|
|
|
|
0
|
if ($ref eq 'ARRAY') { |
|
|
0
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
my $n = 1; |
37
|
0
|
|
|
|
|
0
|
$self->{$fld} = [map {{name=>$n++, value=>$_}} @{$self->{$fld}}]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
38
|
|
|
|
|
|
|
} elsif ($ref eq 'HASH') { |
39
|
0
|
|
|
|
|
0
|
$self->{$fld} = [map {{name=>$_, value=>$self->{$fld}->{$_}}} |
|
0
|
|
|
|
|
0
|
|
40
|
0
|
|
|
|
|
0
|
sort keys %{$self->{$fld}}]; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
3
|
|
|
|
|
17
|
return $self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub sample_query { |
47
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
48
|
0
|
0
|
|
|
|
|
$self->{sample_query} = $_[0] if scalar(@_); |
49
|
0
|
0
|
|
|
|
|
return $self->{sample_query} if defined $self->{sample_query}; |
50
|
0
|
|
0
|
|
|
|
my $good_test = $self->first_good_test || return; |
51
|
0
|
|
|
|
|
|
require URI; |
52
|
0
|
|
|
|
|
|
my $url = URI->new($self->url); |
53
|
0
|
|
|
|
|
|
my $params = {%{$good_test->params}}; |
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
foreach my $key (keys %$params) { |
55
|
0
|
0
|
|
|
|
|
$params->{$key} =~ s/^\$(.*)$/$ENV{$1}||'XXXXXXXX'/e; |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
|
$url->query_form(%$params); |
58
|
0
|
|
|
|
|
|
my $sample_query = { |
59
|
|
|
|
|
|
|
url => $url->as_string, |
60
|
|
|
|
|
|
|
}; |
61
|
0
|
|
|
|
|
|
return $sample_query; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub first_good_test { |
65
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
66
|
0
|
0
|
|
|
|
|
return unless defined $self->tests; |
67
|
0
|
|
|
|
|
|
foreach my $test (@{$self->tests}) { |
|
0
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
return $test if $test->type eq 'good'; |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
|
|
|
return undef; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 NAME |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
WSST::Schema::Method - Schema::Method class of WSST |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 DESCRIPTION |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This class represents the method element of schema. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 METHODS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 new |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Constructor. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 name |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Accessor for the name. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 title |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Accessor for the title. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 desc |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Accessor for the desc. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 url |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Accessor for the url. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 params |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Accessor for the params. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 params_footnotes |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Accessor for the params_footnotes. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 return |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Accessor for the return. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 return_footnotes |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Accessor for the return_footnotes. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 error |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Accessor for the error. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 error_footnotes |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Accessor for the error_footnotes. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 tests |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Accessor for the tests. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 sample_response |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Accessor for the sample_response. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 first_good_test |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Returns the first good test or undef. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SEE ALSO |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
http://code.google.com/p/wsst/ |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHORS |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Mitsuhisa Oshikawa |
146
|
|
|
|
|
|
|
Yusuke Kawasaki |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Copyright 2008 WSS Project Team |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |
153
|
|
|
|
|
|
|
1; |