【しばらく編集不可モードで運営します】 編集(管理者用) | 差分 | 新規作成 | 一覧 | RSS | FrontPage | 検索 | 更新履歴

CvsTiny - [[CVS]]や[[RCS]]を使ってYukiWikiのデータを管理させるモジュール(開発途上)

CVSやRCS?を使ってYukiWikiのデータを管理させるモジュール(開発途上)


 require 5.004_71;
 package Yuki::CvsTiny;
 use vars qw($VERSION);
 ($VERSION) = q($Revision: 1.02 $) =~ m/\x20([\d.]+)\x20/;
 use strict;
 
 sub new {
     my $this = bless {}, shift;
     $this->init(@_);
     return $this;
 }
 
 sub init {
     my $this = shift;
     $this->{cvsdir} = '.';
 }
 
 sub cvsdir {
     my $this = shift;
     $this->{cvsdir} = shift if @_;
     return $this->{cvsdir};
 }
 
 sub shell_execute {
     my $this = shift;
     my $cmdname = shift;
     my $result = '';
     open(FD, $cmdname); 
     while(<FD>) {
         $result .= $_;
     }
     return $result;
 }
 
 sub update {
     my $this = shift;
     my $revision = shift; # 直し。
     my $filename = shift;
     my $cmdname = "(cd $this->{cvsdir}; cvs update -r ${revision} -p '${filename}')|" ;
     return $this->shell_execute($cmdname);
 }
 
 sub log {
     my $this = shift;
     my $filename = shift;
     my $cmdname = "(cd $this->{cvsdir}; cvs log '${filename}')|";
     return $this->shell_execute($cmdname);
 }
 
 sub diff {
     my $this = shift;
     my $filename = shift;
     my $cmdname = "(cd $this->{cvsdir}; cvs diff -u '${filename}')|";
     return $this->shell_execute($cmdname);
 }
 
 sub commit { # -m オプションにてコメントを指定
     my $this = shift;
     my $filename = shift;
     my $cmdname = "(cd $this->{cvsdir} ; cvs commit -m '')|";
     return $this->shell_execute($cmdname);
 }
 
 1;
 __END__

 $ perl -MYuki::CvsTiny -e 'use Yuki::CvsTiny; $cvs = new Yuki::CvsTiny; print $cvs->commit("a");'
 cvs: not found
 
 そういえばcvs入れてなかった(w


(Too many spams ... embedded comments are not allowed now, sorry.)