--- trunk/Estraier.pm 2006/01/16 21:34:14 77 +++ trunk/Estraier.pm 2006/01/26 01:53:58 91 @@ -157,12 +157,12 @@ } elsif ($line =~ m/^$/) { $in_text = 1; next; - } elsif ($line =~ m/^(.+)=(.+)$/) { + } elsif ($line =~ m/^(.+)=(.*)$/) { $self->{attrs}->{ $1 } = $2; next; } - warn "draft ignored: $line\n"; + warn "draft ignored: '$line'\n"; } } @@ -735,6 +735,18 @@ return $self->{hints}->{$key}; } +=head2 hints + +More perlish version of C. This one returns hash. + + my %hints = $rec->hints; + +=cut + +sub hints { + my $self = shift; + return $self->{hints}; +} package Search::Estraier::Node; @@ -754,6 +766,34 @@ my $node = new Search::HyperEstraier::Node( 'http://localhost:1978/node/test' ); +or in more verbose form + + my $node = new Search::HyperEstraier::Node( + url => 'http://localhost:1978/node/test', + debug => 1, + croak_on_error => 1 + ); + +with following arguments: + +=over 4 + +=item url + +URL to node + +=item debug + +dumps a B of debugging output + +=item croak_on_error + +very helpful during development. It will croak on all errors instead of +silently returning C<-1> (which is convention of Hyper Estraier API in other +languages). + +=back + =cut sub new { @@ -776,7 +816,8 @@ } else { my $args = {@_}; - $self->{debug} = $args->{debug}; + %$self = ( %$self, @_ ); + warn "## Node debug on\n" if ($self->{debug}); } @@ -1434,7 +1475,13 @@ ($self->{status}, $self->{status_message}) = split(/\s+/, $res->status_line, 2); - return -1 if (! $res->is_success); + if (! $res->is_success) { + if ($self->{croak_on_error}) { + croak("can't get $url: ",$res->status_line); + } else { + return -1; + } + } $$resbody .= $res->content;