FIXED: the YAML export/import change were missing too. grml...

FIXED:          NOTEDB::general backend fixed loading Config::General
This commit is contained in:
TLINDEN
2012-02-10 20:38:46 +01:00
parent 060def0814
commit 77c359ffd7
6 changed files with 41 additions and 48 deletions

View File

@@ -1,3 +1,7 @@
1.3.10:
FIXED: the YAML export/import change were missing too. grml...
FIXED: NOTEDB::general backend fixed loading Config::General
================================================================================
1.3.9: 1.3.9:
FIXED: bin/note were missing. for whatever reason, I don't know. FIXED: bin/note were missing. for whatever reason, I don't know.
================================================================================ ================================================================================

View File

@@ -4,12 +4,12 @@
package NOTEDB::general; package NOTEDB::general;
$NOTEDB::general::VERSION = "1.01"; $NOTEDB::general::VERSION = "1.02";
use strict; use strict;
#use Data::Dumper; #use Data::Dumper;
use File::Spec; use File::Spec;
use Config::General; use Config::General qw(ParseConfig SaveConfig SaveConfigString);
use MIME::Base64; use MIME::Base64;
use FileHandle; use FileHandle;
use NOTEDB; use NOTEDB;

4
README
View File

@@ -1,4 +1,4 @@
note 1.3.8 by Thomas Linden, 02/01/2012 note 1.3.10 by Thomas Linden, 02/09/2012
======================================= =======================================
Introduction Introduction
@@ -214,4 +214,4 @@ and I'll add you.
Last changed Last changed
============ ============
02/01/2012 02/09/2012

View File

@@ -1 +1 @@
1.3.9 1.3.10

View File

@@ -35,6 +35,7 @@ no strict 'refs';
use Getopt::Long; use Getopt::Long;
use FileHandle; use FileHandle;
use File::Spec; use File::Spec;
use YAML;
#use Data::Dumper; #use Data::Dumper;
@@ -140,7 +141,7 @@ $CONF = File::Spec->catfile($ENV{HOME}, ".noterc");
$USER = getlogin || getpwuid($<); $USER = getlogin || getpwuid($<);
chomp $USER; chomp $USER;
$TOPIC = 1; $TOPIC = 1;
$version = "1.3.9"; $version = "1.3.10";
$CurDepth = 1; # the current depth inside the topic "directory" structure... $CurDepth = 1; # the current depth inside the topic "directory" structure...
$maxlen = "auto"; $maxlen = "auto";
$timelen = 22; $timelen = 22;
@@ -909,7 +910,6 @@ sub edit {
$db->unlock(); $db->unlock();
} }
sub dump { sub dump {
my(%res, $num, $DUMP); my(%res, $num, $DUMP);
# $dump_file # $dump_file
@@ -922,13 +922,21 @@ sub dump {
} }
select $DUMP; select $DUMP;
%res = $db->get_all(); %res = $db->get_all();
# FIXME: prepare hashing in NOTEDB class
foreach $num (sort { $a <=> $b } keys %res) { foreach $num (sort { $a <=> $b } keys %res) {
print STDOUT "dumping note number $num to $dump_file\n" if($dump_file ne "-"); print STDOUT "dumping note number $num to $dump_file\n" if($dump_file ne "-");
print "Number: $num\n" my($title, $path, $body);
."Timestamp: $res{$num}->{'date'}\n" if ($res{$num}->{note} =~ /^\//) {
."$res{$num}->{'note'}\n"; ($path, $title, $body) = split /\n/, $res{$num}->{note}, 3;
} }
print "\n"; else {
($title, $body) = split /\n/, $res{$num}->{note}, 2;
$path = '';
}
my $date = $res{$num}->{date};
$res{$num} = { body => $body, title => $title, path => $path, date => $date};
}
print Dump(\%res);
close(DUMPFILE); close(DUMPFILE);
select STDOUT; select STDOUT;
} }
@@ -945,51 +953,32 @@ sub import {
$DUMP = *DUMPFILE; $DUMP = *DUMPFILE;
} }
$complete = $start = 0; my $yaml = join '', <$DUMP>;
$number = 1;
while (<$DUMP>) {
chomp $_;
if ($_ =~ /^Number:\s\d+/) {
if ($start == 0) {
# we have no previous record
$start = 1;
}
else {
# we got a complete record, save it!
$data{$number} = {
date => $date,
note => &add_ticket($note)
};
print "fetched note number $number from $dump_file from $date.\n" if(!$stdin);
$complete = 0;
$note = "";
$date = "";
$number++;
}
}
elsif ($_ =~ /^Timestamp:\s\d+/ && $complete == 0) {
($dummi,$date,$time) = split(/\s/,$_);
$date = "$date $time";
$complete = 1;
}
else {
$note .= $_ . "\n";
}
}
if ($note ne "" && $date ne "") { my $res = Load($yaml);
# the last record, if existent
foreach my $number (keys %{$res}) {
my $note;
if ($res->{$number}->{path}) {
$note = "$res->{$number}->{path}\n$res->{$number}->{title}\n$res->{$number}->{body}";
}
else {
$note = "$res->{$number}->{title}\n$res->{$number}->{body}";
}
$data{$number} = { $data{$number} = {
date => $date, date => $res->{$number}->{date},
note => &add_ticket($note) note => &add_ticket($note)
}; };
print "fetched note number $number from $dump_file from $date.\n" if(!$stdin); print "fetched note number $number from $dump_file from $res->{$number}->{date}.\n" if(!$stdin);
$number++;
} }
$db->set_del_all() if($ImportType ne ""); $db->set_del_all() if($ImportType ne "");
$db->import_data(\%data); $db->import_data(\%data);
} }
sub determine_width { sub determine_width {
# determine terminal wide, if possible # determine terminal wide, if possible
if ($maxlen eq "auto") { if ($maxlen eq "auto") {

View File

@@ -535,6 +535,6 @@ Thomas Linden <tom at linden dot at>
=head1 VERSION =head1 VERSION
1.3.8 (02/01/2012) 1.3.10 (02/09/2012)
=cut =cut