Changeset 19782
- Timestamp:
- 09/24/08 00:09:41 (5 years ago)
- Location:
- lang/perl/App-Hachero/trunk
- Files:
-
- 3 modified
-
lib/App/Hachero/Plugin/Output/TT.pm (modified) (1 diff)
-
lib/App/Hachero/Result.pm (modified) (2 diffs)
-
t/plugin/output/04_tt.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/App-Hachero/trunk/lib/App/Hachero/Plugin/Output/TT.pm
r19768 r19782 12 12 my $tt = Template->new; 13 13 my $template < io $tt_file; 14 $tt->process(\$template, $context ->result, \my $out);14 $tt->process(\$template, $context, \my $out); 15 15 $out > io $out_file; 16 16 } 17 17 18 18 1; 19 19 __DATA__ -
lang/perl/App-Hachero/trunk/lib/App/Hachero/Result.pm
r19768 r19782 17 17 my ($self, $args) = @_; 18 18 my $key = $self->key($args); 19 $self->data->{$key} ||= $args;20 $self->data->{$key}-> {count}++;19 $self->data->{$key} ||= App::Hachero::Result::Data->new($args); 20 $self->data->{$key}->count_up; 21 21 } 22 22 … … 51 51 } 52 52 53 package App::Hachero::Result::Data; 54 55 sub new { 56 my ($class, $self) = @_; 57 bless $self, $class; 58 } 59 60 sub keys { 61 my $self = shift; 62 return sort {$a eq 'count' ? 1 : 0} keys %{$self}; 63 } 64 65 sub value { 66 my ($self, $arg) = @_; 67 return $self->{$arg}; 68 } 69 70 sub count_up { 71 shift->{count}++; 72 } 73 53 74 1; -
lang/perl/App-Hachero/trunk/t/plugin/output/04_tt.t
r19768 r19782 65 65 - key: hooo 66 66 --- template 67 [% FOR i IN Hoge.values -%] 68 [% i.key %]: [% i.count %] 67 [% FOR r IN result -%] 68 [% r.key %] 69 [% FOR i IN r.value.values -%] 70 [% FOR k IN i.keys -%] 71 [% k %]: [% i.value(k) %] 72 [% END -%] 73 [% END -%] 69 74 [% END -%] 70 75 --- expected 71 bar: 2 72 hooo: 3 76 Hoge 77 key: bar 78 count: 2 79 key: hooo 80 count: 3 81
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)