Skip to content

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
andrefs committed Apr 10, 2012
1 parent 140e685 commit 94d1df0
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 18 deletions.
31 changes: 31 additions & 0 deletions bin/doing
@@ -0,0 +1,31 @@
#!/usr/bin/env perl
use strict; use warnings;
use App::Rad qw/+App::doing/;
App::Rad->run;

sub add
:Help(add a new entry to your 'Currently Doing' file){
my $c = shift;
my $message;
if($c->options->{m}){ $message = shift $c->argv; }
return $c->add($message);
}

sub default {
open my $fh, '<', '.doing.log' or return;
my $res = <$fh>;
while(<$fh>){
last unless /^\t/;
$res.=$_;
}
return $res;
}

# ABSTRACT: Keep track of what you were doing in a folder!
# PODNAME: doing

=head1 NAME
doing - keep track of what you were doing in a folder!
35 changes: 18 additions & 17 deletions dist.ini
Expand Up @@ -3,34 +3,35 @@ author = Andre Santos <andrefs@cpan.org>
license = Perl_5
copyright_holder = Andre Santos
copyright_year = 2012
main_module = bin/doing

;[@Basic]
[@Filter / Basic]
-bundle = @Basic
-remove = Readme
;-remove = UploadToCPAN
;[FakeRelease]
-remove = UploadToCPAN
[FakeRelease]

[Git::NextVersion]
first_version = 0.01_01
[MetaResourcesFromGit]
homepage = https://github.com/%a/%r
bugtracker.web = https://github.com/%a/%r/issues
;[MetaResourcesFromGit]
;homepage = https://github.com/%a/%r
;bugtracker.web = https://github.com/%a/%r/issues

[ChangelogFromGit::CPAN::Changes]
file_name = Changes
tag_regexp = ^v\d+(\.\d+)?(?:_\d+)$
;[ChangelogFromGit::CPAN::Changes]
;file_name = Changes
;tag_regexp = ^v\d+(\.\d+)?(?:_\d+)$

;[@Git]
[@Filter / Git]
-bundle = @Git
-remove = Git::Commit
;changelog = Changes
allow_dirty = dist.ini
;allow_dirty = Changes
commit_msg = v%v%n%n%c
tag_format = v%v
push_to = origin
;[@Filter / Git]
;-bundle = @Git
;-remove = Git::Commit
;;changelog = Changes
;allow_dirty = dist.ini
;;allow_dirty = Changes
;;commit_msg = v%v%n%n%c
;tag_format = v%v
;push_to = origin

;[Test::CheckChanges]
;[NextRelease]
Expand Down
53 changes: 52 additions & 1 deletion lib/App/doing.pm
@@ -1,7 +1,58 @@
use strict;
use warnings;
package App::doing;
use File::Copy;
use DateTime;

# ABSTRACT: Doesn't matter what it does, it is awesome anyway! (TODO: change this -- ups!)
# ABSTRACT: Keep track of what you were doing in a folder!

=head2 add
Adds a new entry to the CURRENTLY_DOING file
=cut

sub add {
my ($c,$message,$options) = @_;
if (defined($message)){
_new_entry('.doing.log',$message);
}
else {
_new_entry('.doing.log');
system('vim','.doing.log');
}
return;
}

sub _new_entry {
my ($file,$message) = @_;
use DateTime;
my $dt = DateTime->now;
if(defined($message)){
$message =~ s/^(?!\t)/\t/gm;
_push_file($file,"$dt\n$message\n");
}
else {
_push_file($file,"$dt\n");
}
}

sub _push_file {
my ($file,$message,$options) = @_;
copy($file,"$file.old") if -f $file;
open my $out, '>', $file;
print $out "$message\n";

if (-f "$file.old"){
open my $in, '<', "$file.old";
while(<$in>){
print $out $_;
}
close $in;
unlink ("$file.old");
}

close $out;
}

1;

0 comments on commit 94d1df0

Please sign in to comment.