[Bps-public-commit] SD branch, config-gitlike, created. 48e062210fa330d834263cc99b905f10855b92d8

spang at bestpractical.com spang at bestpractical.com
Tue Jun 16 06:56:00 EDT 2009


The branch, config-gitlike has been created
        at  48e062210fa330d834263cc99b905f10855b92d8 (commit)

- Log -----------------------------------------------------------------
commit bf784c9f13886e60175e6dbf81402de3c05cc3f0
Author: Christine Spang <spang at bestpractical.com>
Date:   Tue Jun 16 12:11:32 2009 +0300

    Kill t/05-config-file-loading.t
    
    These tests don't cover anything that Config::GitLike's
    tests don't cover.

diff --git a/t/05-config-file-loading.t b/t/05-config-file-loading.t
deleted file mode 100644
index e40a7d3..0000000
--- a/t/05-config-file-loading.t
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-
-use Prophet::Test tests => 10;
-use App::SD::Test;
-use File::Temp qw/tempdir/;
-use Path::Class;
-
-
-no warnings 'once';
-
-BEGIN {
-    require File::Temp;
-    $ENV{'PROPHET_REPO'} = $ENV{'SD_REPO'} = $ENV{'HOME'} = File::Temp::tempdir( CLEANUP => 1 ) . '/_svb';
-    diag "export SD_REPO=".$ENV{'PROPHET_REPO'} ."\n";
-    diag "export HOME=".$ENV{'PROPHET_REPO'} ."\n";
-    delete $ENV{'PROPHET_APP_CONFIG'}; # clear this because Prophet::Test sets it
-}
-
-# Tests the config file order of preference laid out in App::SD::Config
-run_script( 'sd', [ 'init']);
-
-
-
-# create from sd
-my ($yatta_id, $yatta_uuid) = create_ticket_ok( '--summary', 'YATTA');
-
-# default config file
-diag("Testing default config file\n");
-
-run_output_matches( 'sd', [ 'ticket',
-    'list', '--regex', '.' ],
-    [ qr/(\d+) YATTA new/]
-);
-
-# override App::SD::Test
-delete $ENV{'SD_CONFIG'};
-delete $ENV{'PROPHET_APP_CONFIG'};
-
-ok( ! $ENV{'SD_CONFIG'}, "SD_CONFIG env var has been cleared" );
-ok( ! $ENV{'PROPHET_APP_CONFIG'}, "PROPHET_APP_CONFIG env var has been cleared" );
-
-# Test from least-preferred to most preferred, leaving the least-preferred
-# files in place to make sure the next-most-preferred file is preferred
-# over all the files beneath it.
-
-diag("Testing \$HOME/.prophetrc\n");
-
-my $config_filename = $ENV{'HOME'} . '/.prophetrc';
-
-App::SD::Test->write_to_file($config_filename,
-    "summary_format_ticket = %4s },\$luid | %-11.11s,status | %-60.60s,summary\n");
-
-run_output_matches( 'sd', [ 'ticket',
-    'list', '--regex', '.' ],
-    [ qr/\s+(\d+) } new         YATTA/]
-);
-
-diag("Testing PROPHET_APP_CONFIG\n");
-
-$config_filename = $ENV{'HOME'} . '/config-test';
-$ENV{'PROPHET_APP_CONFIG'} = $config_filename;
-
-App::SD::Test->write_to_file($config_filename,
-    "summary_format_ticket = %-9.9s,status | %-60.60s,summary\n");
-
-run_output_matches( 'sd', [ 'ticket',
-    'list', '--regex', '.' ],
-    [ qr/new       YATTA/]
-);
-
-diag("Testing \$HOME/.sdrc\n");
-
-$config_filename = $ENV{'HOME'} . '/.sdrc';
-
-App::SD::Test->write_to_file($config_filename,
-    "summary_format_ticket = %4s },\$luid | %-7.7s,status | %-60.60s,summary\n");
-
-run_output_matches( 'sd', [ 'ticket',
-    'list', '--regex', '.' ],
-    [ qr/\s+(\d+) } new     YATTA/]
-);
-
-diag("Testing fs_root/prophetrc\n");
-
-$config_filename = $ENV{'SD_REPO'} . '/prophetrc';
-
-App::SD::Test->write_to_file($config_filename,
-    "summary_format_ticket = %4s },\$luid | %-10.10s,status | %-60.60s,summary\n");
-
-run_output_matches( 'sd', [ 'ticket',
-    'list', '--regex', '.' ],
-    [ qr/\s+(\d+) } new        YATTA/]
-);
-
-diag("Testing fs_root/config\n");
-
-$config_filename = $ENV{'SD_REPO'} . '/config';
-
-App::SD::Test->write_to_file($config_filename,
-    "summary_format_ticket = %4s },\$luid | %-6.6s,status | %-60.60s,summary\n");
-
-run_output_matches( 'sd', [ 'ticket',
-    'list', '--regex', '.' ],
-    [ qr/\s+(\d+) } new    YATTA/]
-);
-
-diag("Testing SD_CONFIG\n");
-
-$ENV{'SD_CONFIG'} = 't/prophet_testing.conf';
-
-run_output_matches( 'sd', [ 'ticket',
-    'list', '--regex', '.' ],
-    [ qr/(\d+) } new    YATTA /]
-);

commit a9e5b5957fe3c4b4526e825201dd2841c375f8e4
Author: Christine Spang <spang at bestpractical.com>
Date:   Tue Jun 16 13:40:00 2009 +0300

    Update core to use Config::GitLike-based Prophet::Config.

diff --git a/lib/App/SD.pm b/lib/App/SD.pm
index 7f8e47e..1b96c6f 100644
--- a/lib/App/SD.pm
+++ b/lib/App/SD.pm
@@ -1,6 +1,6 @@
 package App::SD;
 use Any::Moose;
-use App::SD::Config;
+use Prophet::Config;
 
 extends 'Prophet::App';
 
@@ -9,14 +9,15 @@ our $VERSION = '0.02';
 has '+config' => (
     default => sub {
         my $self = shift;
-        return App::SD::Config->new(app_handle => $self);
+        $ENV{PROPHET_APP_CONFIG} = $ENV{SD_CONFIG} if defined $ENV{SD_CONFIG};
+        return Prophet::Config->new( app_handle => $self, confname => 'sdrc' );
     }
 );
 
 sub database_settings {
 { 
         statuses            => ['24183C4D-EFD0-4B16-A207-ED7598E875E6' => qw/new open stalled closed rejected/],
-        active_statuses            => ['C879A68F-8CFE-44B5-9EDD-14E53933669E' => qw/new open/],
+        active_statuses     => ['C879A68F-8CFE-44B5-9EDD-14E53933669E' => qw/new open/],
         default_status      => ['2F9E6509-4468-438A-A733-246B3061003E' => 'new' ],
         components          => ['6CBD84A1-4568-48E7-B90C-F1A5B7BD8ECD' => qw/core ui docs tests/],
         default_component   => ['0AEC922F-57B1-44BE-9588-816E5841BB18' => 'core'],
@@ -24,8 +25,8 @@ sub database_settings {
         default_milestone   => ['BAB613BD-9E25-4612-8DE3-21E4572859EA' => 'alpha'],
 
         project_name        => ['3B4B297C-906F-4018-9829-F7CC672274C9' => 'Your SD Project'],
-        common_ticket_props    => ['3f0a074f-af13-406f-bf7b-d69bbf360720' => qw/id summary status milestone component owner created due creator reporter original_replica/],
-        prop_descriptions => ['c1bced3a-ad2c-42c4-a502-4149205060f1',
+        common_ticket_props => ['3f0a074f-af13-406f-bf7b-d69bbf360720' => qw/id summary status milestone component owner created due creator reporter original_replica/],
+        prop_descriptions   => ['c1bced3a-ad2c-42c4-a502-4149205060f1',
         {   summary =>
               "a one-line summary of what this ticket is about",
             owner =>
diff --git a/lib/App/SD/Config.pm b/lib/App/SD/Config.pm
deleted file mode 100644
index 8892c3e..0000000
--- a/lib/App/SD/Config.pm
+++ /dev/null
@@ -1,35 +0,0 @@
-package App::SD::Config;
-use Any::Moose;
-use File::Spec;
-
-extends 'Prophet::Config';
-
-# We can't just frob $ENV{PROPHET_APP_CONFIG} the way the sd script does
-# with $ENV{PROPHET_REPO} because we need to instantiate App::SD::CLI to
-# get the location of the repo root, and then Prophet would load its own
-# config file before we got around to messing with the env var
-sub app_config_file {
-    my $self = shift;
-
-    # The order of preference for config files is:
-    #   $ENV{SD_CONFIG} > fs_root/config > fs_root/prophetrc (for backcompat)
-    #   $HOME/.sdrc > $ENV{PROPHET_APP_CONFIG} > $HOME/.prophetrc
-
-    $ENV{'PROPHET_APP_CONFIG'}
-            =  $self->file_if_exists($ENV{'SD_CONFIG'})
-            || $self->file_if_exists(
-                File::Spec->catfile($self->app_handle->handle->fs_root => 'config'))
-            || $self->file_if_exists(
-                # backcompat
-                File::Spec->catfile($self->app_handle->handle->fs_root => 'prophetrc'))
-            || $self->file_if_exists(
-                File::Spec->catfile($ENV{'HOME'}.'/.sdrc'))
-            || $ENV{'PROPHET_APP_CONFIG'} # don't overwrite with nothing
-            || ''; # don't write undef
-        $self->SUPER::app_config_file(@_);
-}
-
-__PACKAGE__->meta->make_immutable;
-no Any::Moose;
-
-1;

commit 7ff676c9fe83a16b46f6dfd168482b38ed523776
Author: Christine Spang <spang at bestpractical.com>
Date:   Tue Jun 16 13:41:09 2009 +0300

    Update ticket search command and related test to use new config API and names.

diff --git a/lib/App/SD/CLI/Command/Ticket/Search.pm b/lib/App/SD/CLI/Command/Ticket/Search.pm
index 87adc92..4444f00 100644
--- a/lib/App/SD/CLI/Command/Ticket/Search.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Search.pm
@@ -10,18 +10,20 @@ sub run {
     my $self = shift;
 
     if (  (!$self->has_arg('sort') || !$self->arg('sort'))
-        && $self->app_handle->config->get('default_sort_ticket_list') )
+        && $self->app_handle->config->get( key => 'ticket.list.default-sort') )
     {
         $self->set_arg(
-            'sort' => $self->app_handle->config->get('default_sort_ticket_list')
+            'sort' => $self->app_handle->config->get(
+                key => 'ticket.list.default-sort'
+            )
         );
     }
 
     if (  (!$self->has_arg('group') || !$self->arg('group'))
-        && $self->app_handle->config->get('default_group_ticket_list') )
+        && $self->app_handle->config->get( key => 'ticket.list.default-group') )
     {
         $self->set_arg( 'group' =>
-              $self->app_handle->config->get('default_group_ticket_list') );
+              $self->app_handle->config->get( key => 'ticket.list.default-group') );
     }
 
     # sort output by given prop if user specifies --sort
diff --git a/t/07-sort-group.t b/t/07-sort-group.t
index 952247e..8703bf3 100644
--- a/t/07-sort-group.t
+++ b/t/07-sort-group.t
@@ -40,11 +40,13 @@ run_output_matches( 'sd', [ 'ticket', 'list', '--sort', 'owner' ],
 );
 
 my $config_filename = $ENV{'SD_REPO'} . '/config';
-App::SD::Test->write_to_file($config_filename,
-    "default_sort_ticket_list = owner\n");
+App::SD::Test->write_to_file($config_filename, '
+[ticket "list"]
+    default-sort = owner
+');
 $ENV{'SD_CONFIG'} = $config_filename;
 
-diag('using default_sort_ticket_list = owner');
+diag('using ticket.list.default-sort = owner');
 run_output_matches( 'sd', [ 'ticket', 'list' ],
     [ qr/(\d+) huzzah! new/,
       qr/(\d+) YATTA new/,
@@ -58,7 +60,7 @@ run_output_matches( 'sd', [ 'ticket', 'list', '--sort' ],
     ]
 );
 
-diag('using default_sort_ticket_list = owner and --sort none');
+diag('using ticket.list.default-sort = owner and --sort none');
 run_output_matches( 'sd', [ 'ticket', 'list', '--sort', 'none' ],
     [ qr/(\d+) YATTA new/,
       qr/(\d+) huzzah! new/,
@@ -82,11 +84,11 @@ run_output_matches( 'sd', [ 'ticket', 'list', '--group', 'owner' ],
     ]
 );
 
-diag('using default_group_ticket_list = owner');
-$config_filename = $ENV{'SD_REPO'} . '/config';
-App::SD::Test->write_to_file($config_filename,
-    "default_group_ticket_list = owner\n");
-$ENV{'SD_CONFIG'} = $config_filename;
+diag('using ticket.list.default-group = owner');
+App::SD::Test->write_to_file($config_filename, '
+[ticket "list"]
+    default-group = owner
+');
 
 run_output_matches( 'sd', [ 'ticket', 'list' ],
     [ '',
@@ -117,7 +119,7 @@ run_output_matches( 'sd', [ 'ticket', 'list', '--group' ],
     ]
 );
 
-diag('using default_group_ticket_list = owner and --group none');
+diag('using ticket.list.default-group = owner and --group none');
 run_output_matches( 'sd', [ 'ticket', 'list', '--group', 'none' ],
     [ qr/(\d+) YATTA new/,
       qr/(\d+) huzzah! new/,

commit d8cf98d1fceda68f32a5dfbab9fb5a0ba4d60430
Author: Christine Spang <spang at bestpractical.com>
Date:   Tue Jun 16 13:41:59 2009 +0300

    Update ticket show and related test to new config API.

diff --git a/lib/App/SD/CLI/Command/Ticket/Show.pm b/lib/App/SD/CLI/Command/Ticket/Show.pm
index b3f9090..a3f6078 100644
--- a/lib/App/SD/CLI/Command/Ticket/Show.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Show.pm
@@ -46,11 +46,13 @@ override run => sub {
     }
 
     # allow user to not display history by specifying the --skip-history
-    # arg or setting disable_ticket_show_history_by_default config item to a
+    # arg or setting ticket.show.disable-history config item to a
     # true value (can be overridden with --with-history)
     if (!$self->has_arg('skip-history')
-        && (  !$self->app_handle->config->get('disable_ticket_show_history_by_default')
-            || $self->has_arg('with-history') )
+        && (  !$self->app_handle->config->get(
+                key => 'ticket.show.disable-history',
+                as => 'bool',
+            ) || $self->has_arg('with-history') )
         )
     {
         print "\n= HISTORY\n\n";
diff --git a/t/06-ticket-show.t b/t/06-ticket-show.t
index fa3802d..00f30c8 100644
--- a/t/06-ticket-show.t
+++ b/t/06-ticket-show.t
@@ -93,22 +93,24 @@ diag("passing --skip history (doesn't show history)");
 check_output_without_history('--skip-history');
 
 my $config_filename = $ENV{'SD_REPO'} . '/config';
-App::SD::Test->write_to_file($config_filename,
-    "disable_ticket_show_history_by_default = 1\n");
+App::SD::Test->write_to_file($config_filename, '
+[ticket "show"]
+    disable-history = true
+');
 $ENV{'SD_CONFIG'} = $config_filename;
 
-diag("config option disable_ticket_show_history_by_default set");
+diag("config option ticket.show.disable-history set");
 diag("(shouldn't show history)");
 
 check_output_without_history();
 
-diag("config option disable_ticket_show_history_by_default set");
+diag("config option ticket.show.disable-history set");
 diag("and --skip-history passed (shouldn't show history)");
 
 check_output_without_history('--skip-history');
 
 # config option set and --with-history passed (should show history)
-diag('config option disable_ticket_show_history_by_default set');
+diag('config option ticket.show.disable-history set');
 diag('and --with-history passed (should show history)');
 
 check_output_with_history('--with-history');

commit 48e062210fa330d834263cc99b905f10855b92d8
Author: Christine Spang <spang at bestpractical.com>
Date:   Tue Jun 16 13:42:43 2009 +0300

    Update the last couple places where the old config API was used.

diff --git a/lib/App/SD/Model/Ticket.pm b/lib/App/SD/Model/Ticket.pm
index e9bebcc..a453f47 100644
--- a/lib/App/SD/Model/Ticket.pm
+++ b/lib/App/SD/Model/Ticket.pm
@@ -167,7 +167,7 @@ sub props_to_show {
     my $self = shift;
     my $args = shift || {};
     my @props_from_config = split(',',
-        ($self->app_handle->config->get('common_ticket_props') || ''));
+        ($self->app_handle->config->get( key => 'ticket.common-props') || ''));
     my $props_list = @props_from_config ? \@props_from_config :
         $self->app_handle->setting(label => 'common_ticket_props')->get();
 
diff --git a/lib/App/SD/Server/View.pm b/lib/App/SD/Server/View.pm
index 7f25e13..eada473 100644
--- a/lib/App/SD/Server/View.pm
+++ b/lib/App/SD/Server/View.pm
@@ -294,7 +294,9 @@ template '/tickets/hot' => sub {
             if (   $item->has_active_status
                 && ( $item->prop('milestone') || '' ) eq $current_milestone
                 && ( ( $item->prop('owner') || '' ) eq
-                    ( $item->app_handle->config->get('email_address') || '') || !$item->prop('owner') )
+                    ( $item->app_handle->config->get(
+                            key => 'user.email-address'
+                        ) || '') || !$item->prop('owner') )
                 )
             {
                 return 1;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list