Show
Ignore:
Timestamp:
03/14/08 10:06:37 (9 months ago)
Author:
daisuke
Message:

lang/perl/Acme-Shukugawa-Atom; Make it possible to override the path to config

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Acme-Shukugawa-Atom/trunk/lib/Acme/Shukugawa/Atom.pm

    r7939 r7941  
    1717# Special case handling -- this could be optimized further 
    1818# put it in a sharefile later 
    19 our (@DEFAULT_WORDS, $RE_EXCEPTION, $RE_SMALL, $RE_SYLLABLE, $RE_NBAR); 
     19our ($CONFIG, @DEFAULT_WORDS, $RE_EXCEPTION, $RE_SMALL, $RE_SYLLABLE, $RE_NBAR); 
    2020BEGIN 
    2121{ 
    22     my $config = YAML::LoadFile( File::ShareDir::module_file(__PACKAGE__, 'config.yaml') ); 
     22    my $config = YAML::LoadFile(  
     23        $CONFIG || File::ShareDir::module_file(__PACKAGE__, 'config.yaml') ); 
    2324    $RE_SMALL    = decode_utf8("[ャュョッー]"); 
    2425    $RE_SYLLABLE = decode_utf8("(?:.$RE_SMALL?)"); 
     
    233234  my $newstring = Acme::Shukugawa::Atom->translate($string); 
    234235 
     236  # By default, share/config.yaml is used (via File::ShareDir) for custom 
     237  # fixed replacements. You can however override this by specifying the 
     238  # alternate config filename at load time 
     239  BEGIN 
     240  { 
     241    $Acme::Shukugawa::Atom::CONFIG = '/path/to/config.yaml'; 
     242  } 
     243  use Acme::Shukugawa::Atom; 
     244   
     245  # Or you can specify them (on top of the default words) at run time 
    235246  my $atom = Acme::Shukugawa::Atom->new( 
    236247    # The default values are stored in @Acme::Shukugawa::Atom::DEFAULT_WORDS