Changeset 26126 for lang/perl/WWW-Hatena-IconURL
- Timestamp:
- 12/08/08 21:08:15 (4 years ago)
- Location:
- lang/perl/WWW-Hatena-IconURL/trunk
- Files:
-
- 4 modified
-
Changes (modified) (1 diff)
-
META.yml (modified) (2 diffs)
-
lib/WWW/Hatena/IconURL.pm (modified) (4 diffs)
-
t/01.basic.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/WWW-Hatena-IconURL/trunk/Changes
r21302 r26126 1 1 Revision history for WWW-Hatena-IconURL 2 2 3 1.0.1 Mon DEC 08 20:55:55 2008 4 Initial release. 5 3 6 1.0.0 Mon Oct 14 14:14:14 2008 4 7 Initial release. -
lang/perl/WWW-Hatena-IconURL/trunk/META.yml
r21302 r26126 1 1 --- 2 2 name: WWW-Hatena-IconURL 3 version: 1.0. 03 version: 1.0.1 4 4 author: 5 5 - 'Dai Okabayashi <genkivogue@ybb.ne.jp>' … … 15 15 WWW::Hatena::IconURL: 16 16 file: lib/WWW/Hatena/IconURL.pm 17 version: 1.0. 017 version: 1.0.1 18 18 generated_by: Module::Build version 0.3 19 19 meta-spec: -
lang/perl/WWW-Hatena-IconURL/trunk/lib/WWW/Hatena/IconURL.pm
r21302 r26126 4 4 use strict; 5 5 6 use version; our $VERSION = qv('1.0. 0');6 use version; our $VERSION = qv('1.0.1'); 7 7 8 8 use URI; … … 10 10 sub new { 11 11 my $class = shift; 12 my $id = shift || return;12 my $id = shift; 13 13 return '' unless $class->_check_id($id); 14 14 return bless { 'id' => $id }, $class; … … 16 16 17 17 sub id { 18 my $self = shift || return;18 my $self = shift; 19 19 return $self->{id}; 20 20 } 21 21 22 22 sub icon { 23 my $self = shift || return;23 my $self = shift; 24 24 return URI->new( 25 25 "http://www.hatena.ne.jp/users/".substr($self->{id}, 0, 2)."/$self->{id}/profile.gif" 26 ) if $self and $self->{id};26 ) if $self->{id}; 27 27 return ''; 28 28 } 29 29 30 30 sub icon_s { 31 my $self = shift || return;31 my $self = shift; 32 32 return URI->new( 33 33 "http://www.hatena.ne.jp/users/".substr($self->{id}, 0, 2)."/$self->{id}/profile_s.gif" 34 ) if $self and $self->{id};34 ) if $self->{id}; 35 35 return ''; 36 36 } … … 39 39 my $self = shift; 40 40 my $id = shift; 41 return 1 if $id =~ /^[a-zA-Z0-9 \_\-]+[a-zA-Z0-9]$/41 return 1 if $id =~ /^[a-zA-Z0-9][a-zA-Z0-9\_\-]*[a-zA-Z0-9]$/; 42 42 } 43 43 -
lang/perl/WWW-Hatena-IconURL/trunk/t/01.basic.t
r21302 r26126 1 use Test::More tests => 3; 1 use strict; 2 use warnings; 3 4 use Test::More tests => 9; 2 5 3 6 use WWW::Hatena::IconURL; 4 7 5 my $id2url = WWW::Hatena::IconURL->new("genkivogue"); # genkivogue is author's id ;-) 8 9 my $no_id = WWW::Hatena::IconURL->new(''); 10 is($no_id, '', "no id"); 11 my $wrong_id = WWW::Hatena::IconURL->new('hoge_'); 12 is($wrong_id, '', "wrong id"); 13 my $id2url = WWW::Hatena::IconURL->new("genkivogue"); 14 is(ref $id2url, 'WWW::Hatena::IconURL', "new"); 6 15 7 16 8 17 is($id2url->id, 'genkivogue', "id"); 18 is(WWW::Hatena::IconURL::id(), undef, "no id"); 9 19 10 20 11 21 is($id2url->icon, 'http://www.hatena.ne.jp/users/ge/genkivogue/profile.gif', "icon"); 22 is(WWW::Hatena::IconURL::icon(), '', "no icon"); 12 23 13 24 14 25 is($id2url->icon_s, 'http://www.hatena.ne.jp/users/ge/genkivogue/profile_s.gif', "icon_s"); 26 is(WWW::Hatena::IconURL::icon_s(), '', "no icon_s"); 15 27 16
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)