From: Sebastian Riedel Date: Wed, 25 Jan 2006 07:36:17 +0000 (+0000) Subject: Switched from YAML to JSON for now X-Git-Tag: 5.7099_04~729 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=0ff7106c9f4652163ca58c84130de0fee52ea2f9 Switched from YAML to JSON for now --- diff --git a/Changes b/Changes index ac4da56..5af7395 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ This file documents the revision history for Perl extension Catalyst. +5.64 + + - Switched to JSON from YAML for the default config file + 5.63 - Updated prereq versions diff --git a/Makefile.PL b/Makefile.PL index 31424be..83d51a1 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -32,8 +32,9 @@ requires 'Tree::Simple::Visitor::FindByPath'; requires 'URI' => 1.35; requires 'File::Copy::Recursive'; requires 'Module::Install::Admin' => '0.54'; -requires 'Module::Install' => '0.54'; -requires 'YAML' => '0.52'; +requires 'Module::Install' => '0.54'; +requires 'JSON'; +requires 'File::Slurp'; feature 'Apache/mod_perl Support', -default => 0, diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index f09b699..a3fc0f7 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -21,7 +21,8 @@ use Scalar::Util qw/weaken/; use Tree::Simple qw/use_weak_refs/; use Tree::Simple::Visitor::FindByUID; use attributes; -use YAML (); +use JSON; +use File::Slurp; __PACKAGE__->mk_accessors( qw/counter request response state action stack namespace/ @@ -448,11 +449,12 @@ Returns or takes a hashref containing the application's configuration. __PACKAGE__->config({ db => 'dsn:SQLite:foo.db' }); -You can also use a L config file like myapp.yml in your +You can also use a L config file like myapp.json in your applications home directory. - --- - db: dsn:SQLite:foo.db + { + "db": "dsn:SQLite:foo.db" + } =head2 $c->debug @@ -590,12 +592,15 @@ sub setup { $class->setup_home( delete $flags->{home} ); - # YAML config support + # JSON config support my $confpath = $class->config->{file} || $class->path_to( - ( Catalyst::Utils::appprefix( ref $class || $class ) . '.yml' ) ); + ( Catalyst::Utils::appprefix( ref $class || $class ) . '.json' ) ); my $conf = {}; - $conf = YAML::LoadFile($confpath) if -f $confpath; + if ( -f $confpath ) { + my $content = read_file("$confpath"); + $conf = jsonToObj($content); + } my $oldconf = $class->config; $class->config( { %$oldconf, %$conf } ); diff --git a/lib/Catalyst/Helper.pm b/lib/Catalyst/Helper.pm index d965711..3b86793 100644 --- a/lib/Catalyst/Helper.pm +++ b/lib/Catalyst/Helper.pm @@ -360,7 +360,7 @@ sub _mk_config { my $dir = $self->{dir}; my $appprefix = $self->{appprefix}; $self->render_file( 'config', - File::Spec->catfile( $dir, "$appprefix.yml" ) ); + File::Spec->catfile( $dir, "$appprefix.json" ) ); } sub _mk_readme { @@ -616,8 +616,9 @@ install_script glob('script/*.pl'); auto_install; WriteAll; __config__ ---- -name: [% name %] +{ + "name": "[% name %]" +} __readme__ Run script/[% appprefix %]_server.pl to test the application. __changes__ @@ -783,7 +784,7 @@ my $port = 3000; my $keepalive = 0; my $restart = 0; my $restart_delay = 1; -my $restart_regex = '\.yml$|\.yaml$|\.pm$'; +my $restart_regex = '\.yml$|\.yaml$|\.json|\.pm$'; my @argv = @ARGV; @@ -844,7 +845,7 @@ require [% name %]; -rd -restartdelay delay between file checks -rr -restartregex regex match files that trigger a restart when modified - (defaults to '\.yml$|\.yaml$|\.pm$') + (defaults to '\.yml$|\.yaml$|\.json|\.pm$') See also: perldoc Catalyst::Manual