/[Frey]/trunk/lib/Frey/CouchAPI.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/CouchAPI.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1115 by dpavlin, Fri May 15 20:43:17 2009 UTC revision 1116 by dpavlin, Mon Jun 29 18:50:27 2009 UTC
# Line 91  sub dispatch { Line 91  sub dispatch {
91          } elsif ( $url eq '/_all_dbs' ) {          } elsif ( $url eq '/_all_dbs' ) {
92                  $json = [                  $json = [
93                          map {                          map {
94                                  s{^\Q$path\E/*}{};                                  my $db = $_;
95                                  $_;                                  $db =~ s{^\Q$path\E/*}{};
96                                    $db;
97                          } glob $path . $config->{database}->{name_glob}                          } glob $path . $config->{database}->{name_glob}
98                  ];                  ];
99                  $status = 200;                  $status = 200;
# Line 110  sub dispatch { Line 111  sub dispatch {
111    
112                          # poor man's transaction :-)                          # poor man's transaction :-)
113                          my $code = "\$config->{'$part'} = \$data;";                          my $code = "\$config->{'$part'} = \$data;";
114                          eval $code;                          eval $code; ## no critic
115                          if ( $@ ) {                          if ( $@ ) {
116                                  warn "ERROR: $code -> $@";                                  warn "ERROR: $code -> $@";
117                                  $status = 500;                                  $status = 500;
# Line 207  L<http://wiki.apache.org/couchdb/HTTP_Do Line 208  L<http://wiki.apache.org/couchdb/HTTP_Do
208                          my $total_rows = 0;                          my $total_rows = 0;
209                          my $collected_rows = 0;                          my $collected_rows = 0;
210    
211                          my @docs = grep { length $_ } map {                          my @docs = grep { length($_) > 0 } map {        ## no critic
212    
213                                    my $id = $_;
214                                  $total_rows++;                                  $total_rows++;
215                    
216                                  if ( $limit > 0 && $collected_rows == $limit ) {                                  if ( $limit > 0 && $collected_rows == $limit ) {
217                                          '';                                          '';
218                                  } else {                                  } else {
           
                                         s{^$path/$database/}{};  
219    
220                                          if ( defined $endkey && $_ gt $endkey ) {                                          $id = s{^$path/$database/}{};
221    
222                                            if ( defined $endkey && $id gt $endkey ) {
223                                                  '';                                                  '';
224                                          } elsif ( $startkey ) {                                          } elsif ( $startkey ) {
225                                                  if ( $_ ge $startkey ) {                                                  if ( $id ge $startkey ) {
226                                                          $collected_rows++;                                                          $collected_rows++;
227                                                          $_;                                                          $id;
228                                                  } else {                                                  } else {
229                                                          $offset++;                                                          $offset++;
230                                                          '';                                                          '';
231                                                  }                                                  }
232                                          } else {                                          } else {
233                                                  $collected_rows++;                                                  $collected_rows++;
234                                                  $_;                                                  $id;
235                                          }                                          }
236                                  }                                  }
237    

Legend:
Removed from v.1115  
changed lines
  Added in v.1116

  ViewVC Help
Powered by ViewVC 1.1.26