Permalink
Browse files

imported from version 0.06, see Changes file.

  • Loading branch information...
1 parent 8d3a7c6 commit bfe017ce46a0ed3f57ea52aa0b6937eba6c9141d @barbie committed Apr 6, 2009
Showing with 55 additions and 8 deletions.
  1. +4 −0 Changes
  2. +2 −0 MANIFEST
  3. +2 −2 META.yml
  4. +24 −6 lib/Data/Phrasebook/Loader/Ini.pm
  5. +4 −0 t/05dict.ini
  6. +19 −0 t/05dicts.t
View
@@ -1,5 +1,9 @@
# Changes log for Data::Phrasebook::Loader::Ini
+0.06 13/06/2005
+ - dictionary reload bug spotted (Sam Tregar).
+ - added dicts() support.
+
0.05 25/03/2005
- Added DSLIP information
- Rewrote test scripts
View
@@ -11,5 +11,7 @@ META.yml
README
t/01load.t
t/01phrases.ini
+t/05dicts.t
+t/05dict.ini
t/90podtest.t
t/91podcover.t
View
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Data-Phrasebook-Loader-Ini
-version: 0.05
+version: 0.06
version_from: lib/Data/Phrasebook/Loader/Ini.pm
installdirs: site
requires:
@@ -10,4 +10,4 @@ requires:
Test::More: 0.47
distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.25
+generated_by: ExtUtils::MakeMaker version 6.17
@@ -5,7 +5,7 @@ use Carp qw( croak );
use base qw( Data::Phrasebook::Loader::Base Data::Phrasebook::Debug );
use Config::IniFiles;
-our $VERSION = '0.05';
+our $VERSION = '0.06';
=head1 NAME
@@ -21,9 +21,13 @@ Data::Phrasebook::Loader::Ini - Absract your phrases with ini files.
file => 'phrases.ini',
);
- $q->delimiters( qr{ \[% \s* (\w+) \s* %\] }x );
+ # simple keyword to phrase mapping
my $phrase = $q->fetch($keyword);
+ # keyword to phrase mapping with parameters
+ $q->delimiters( qr{ \[% \s* (\w+) \s* %\] }x );
+ my $phrase = $q->fetch($keyword,{this => 'that'});
+
=head1 ABSTRACT
This module provides a loader class for phrasebook implementations using INI
@@ -43,8 +47,8 @@ An example ini file:
[BASE]
foo=\
- Welcome to [% my %] world. \
- It is a nice [%place %].
+ Welcome to :my world. \
+ It is a nice :place.
Within the phrase text placeholders can be used, which are then replaced with
the appropriate values once the get() method is called. The default style of
@@ -89,8 +93,9 @@ sub load
# what sections are we using?
($class->{default}) = $cfg->Sections;
- $class->{dict} = $class->{default}
- unless($dict && $class->{cfg}->SectionExists( $dict ));
+ $class->{dict} = $class->{default};
+ $class->{dict} = $dict
+ if($dict && $class->{cfg}->SectionExists( $dict ));
};
=head2 get
@@ -115,6 +120,19 @@ sub get {
return $data;
}
+=head2 dicts
+
+Returns the list of dictionaries available.
+
+ my @dicts = $loader->dicts();
+
+=cut
+
+sub dicts {
+ my $class = shift;
+ $class->{cfg}->Sections
+}
+
1;
__END__
View
@@ -0,0 +1,4 @@
+[DEF]
+foo=I'm original foo.
+[ONE]
+foo=I'm new foo.
View
@@ -0,0 +1,19 @@
+#!/usr/bin/perl -w
+use strict;
+use lib 't';
+use vars qw( $class );
+
+use Test::More 'no_plan';
+use Data::Phrasebook;
+
+my $file = 't/02dict.ini';
+
+# load up the default dict
+my $book = Data::Phrasebook->new(class => 'Plain',
+ loader => 'Ini',
+ file => 't/05dict.ini');
+is($book->fetch('foo'), "I'm original foo.");
+
+# now switch to the second one
+$book->dict('ONE');
+is($book->fetch('foo'), "I'm new foo.");

0 comments on commit bfe017c

Please sign in to comment.