Skip Menu |

This queue is for tickets about the URI-tel CPAN distribution.

Report information
The Basics
Id: 51634
Status: resolved
Priority: 0/
Queue: URI-tel

People
Owner: thiago.rondon [...] gmail.com
Requestors: DOUGDUDE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Add _init function to be compatible with URI
The URI package automatically detects URI::* modules installed on a system and will try to use them if the * matches the scheme. The URI package will then called a method called _init on your package and fail. I recommend you add: sub _init { my ($class, $uri, $scheme) = @_; $uri = "$scheme:$uri" unless $uri =~ m{\A $scheme}x; return $class->new(telephone_uri => $uri); } This will allow people who have URI::tel installed to call URI->new('tel:+1-201-555-0123') and automatically get back an instance of your package instead of their code dying. Here is also a corresponding test: isa_ok(URI->new('tel:+1-201-555-0123'), 'URI::tel');
Douglas, Thanks in advanced for your warning! I'll send URI::tel-0.02 with your recommend. -Thiago Rondon Em Ter. Nov. 17 23:39:22 2009, DOUGDUDE escreveu: Show quoted text
> The URI package automatically detects URI::* modules installed on a > system and will try to use them if the * matches the scheme. The URI > package will then called a method called _init on your package and fail. > I recommend you add: > > sub _init { > my ($class, $uri, $scheme) = @_; > > $uri = "$scheme:$uri" unless $uri =~ m{\A $scheme}x; > > return $class->new(telephone_uri => $uri); > } > > This will allow people who have URI::tel installed to call > URI->new('tel:+1-201-555-0123') and automatically get back an instance > of your package instead of their code dying. Here is also a > corresponding test: > > isa_ok(URI->new('tel:+1-201-555-0123'), 'URI::tel');