/[Frey]/trunk/lib/Frey/SVK.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/SVK.pm

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

revision 552 by dpavlin, Thu Nov 27 15:40:12 2008 UTC revision 585 by dpavlin, Fri Nov 28 13:26:08 2008 UTC
# Line 4  use Moose; Line 4  use Moose;
4  extends 'Frey';  extends 'Frey';
5  with 'Frey::Web';  with 'Frey::Web';
6    
7    has commit_path => (
8            documentation => 'path to commit',
9            is => 'rw',
10            isa => 'Str',
11    );
12    
13    has message => (
14            documentation => 'commit message',
15            is => 'rw',
16            isa => 'Str',
17    );
18    
19  sub svk {  sub svk {
20          my ( $self, $exec, $coderef ) = @_;          my ( $self, $exec, $coderef ) = @_;
21          open(my $svk, '-|', 'svk ' . $exec) or die "svk $exec: $@";          open(my $svk, '-|', 'svk ' . $exec) or die "svk $exec: $@";
# Line 18  sub modified { Line 30  sub modified {
30          my ($self) = @_;          my ($self) = @_;
31          my @modified;          my @modified;
32          my $svk = $self->svk('status -q', sub {          my $svk = $self->svk('status -q', sub {
33                  push @modified, $1 if /^(M|A)\s+(.+)/;                  push @modified, $1 if /^\w+\s+(.+)/;
34          });          });
35          return @modified;          return @modified;
36  }  }
# Line 31  sub info { Line 43  sub info {
43                  my ( $label, $value ) = split(/:\s+/, $_, 2);                  my ( $label, $value ) = split(/:\s+/, $_, 2);
44                  $info->{$label} = $value if $label;                  $info->{$label} = $value if $label;
45          });          });
46            warn "# svk info ",$self->dump( $info );
47          return $info;          return $info;
48  }  }
49    
# Line 41  sub as_data { Line 54  sub as_data {
54          }          }
55  }  }
56    
57  sub as_markup {  sub status_as_markup {
58          my ($self) = @_;          my ($self) = @_;
   
59          my $status = `svk status -q`;          my $status = `svk status -q`;
60            $status =~ s{^(\w+\s+)(\S+)$}{$1<a href="#$2">$2</a>}gm;
61            $self->add_css( qq| pre.l a { text-decoration: none; } | );
62            $status = qq|<pre class="l">$status</pre>|;
63            $self->add_status( $status );
64            return $status;
65    }
66    
67    sub diff_as_markup {
68            my ($self) = @_;
69    
70          my $diff   = `svk diff`;          my $diff   = `svk diff`;
71    
72          Frey::Web->meta->apply( $self ); # provide html_escape          $diff = $self->html_escape( $diff );
73            $self->add_css( qq|
74            pre span.add { background: #dfd }
75            pre span.del { background: #fdd }
76            | );
77            $diff =~ s{^(\+.+?)$}{<span class="add">$1</span>}gm;
78            $diff =~ s{^(\-.+?)$}{<span class="del">$1</span>}gm;
79            $diff =~ s{^(===\s+)(\S+)$}{$1<a name="$2">$2</a>}gm;
80    
81            $diff = qq|<pre>$diff</pre>|;
82            return $diff;
83    }
84    
85    sub as_markup {
86            my ($self) = @_;
87    
88            if ( ! $self->can('html_escape') ) {
89                    Frey::Web->meta->apply( $self );
90                    $self->TODO( "Frey::Web role missing" );
91            }
92    
93          my $html          my $html = $self->status_as_markup . $self->diff_as_markup;
94                  = qq|<pre>$status</pre><hr><pre>|          warn "html ",length($html)," bytes";
                 . $self->html_escape( $diff )  
                 . qq|</pre>|  
                 ;  
         warn "diff ",length($html)," bytes";  
95    
96          return $html;          return $html;
97  }  }

Legend:
Removed from v.552  
changed lines
  Added in v.585

  ViewVC Help
Powered by ViewVC 1.1.26