Switched from YAML to JSON for now
Sebastian Riedel [Wed, 25 Jan 2006 07:36:17 +0000 (07:36 +0000)]
Changes
Makefile.PL
lib/Catalyst.pm
lib/Catalyst/Helper.pm

diff --git a/Changes b/Changes
index ac4da56..5af7395 100644 (file)
--- 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
 
index 31424be..83d51a1 100644 (file)
@@ -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,
index f09b699..a3fc0f7 100644 (file)
@@ -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<YAML> config file like myapp.yml in your
+You can also use a L<JSON> 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 } );
 
index d965711..3b86793 100644 (file)
@@ -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