[Bps-public-commit] Config-GitLike branch, master, updated. 1.05-19-g8cf93ca

Alex Vandiver alexmv at bestpractical.com
Wed Oct 12 20:50:27 EDT 2011


The branch, master has been updated
       via  8cf93caadb5f93e7f365cf2c43cd6ec77615ce65 (commit)
       via  7ec1f7d6a02765754de63b452871f1a7a221a21a (commit)
       via  5d89d88978b1c1e5491bb036823cf185b8ab9323 (commit)
       via  93f2029ac04a323387ca60108fcd4f8267a8af1d (commit)
       via  74f5b4a683a8b1f6636730c42b5a436a4bed92c1 (commit)
       via  e8b4acfc6d43f831af9be8c8f725c37647fc0b9d (commit)
       via  824caa83bbb695b2bcde6a05f87d2c4514c13cc2 (commit)
       via  7502844ad287f4d8864e3a2e91fccddf9a4a594a (commit)
       via  34584f698000b50a88d047b74efc5b4986b798fc (commit)
       via  6d658d3a8f933c6453b8221c6e82921f84c1e85a (commit)
       via  835d0659484245d77c5aab10432c37f408c4ac9d (commit)
       via  8a062609ad6302b999920008ef6a3f957288c580 (commit)
       via  dcdd01f23ebd1cf481097b91c535a10fc7e8d8f4 (commit)
       via  919a5617be6b470779e9dc1e25c613fe210728dd (commit)
       via  be3f05c4aa834fe72d8b864b1af22cf0bf2da88b (commit)
       via  d28d3bcf60e508b2939c449fb2ac04f491d34e97 (commit)
      from  74cd4d2e15dbcead22e28288e14187cea44882ac (commit)

Summary of changes:
 Changes                      |   12 +++++++++
 MANIFEST.SKIP                |    2 +-
 Makefile.PL                  |    5 +--
 lib/Config/GitLike.pm        |   53 ++++++++++++++++++++++++++++++++---------
 lib/Config/GitLike/Git.pm    |    9 +++++++
 xt/release/00-dependencies.t |    6 ++--
 6 files changed, 68 insertions(+), 19 deletions(-)

- Log -----------------------------------------------------------------
commit d28d3bcf60e508b2939c449fb2ac04f491d34e97
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 19:35:37 2011 -0400

    Fix POD on config_files method -- it's not called config_filenames

diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index 8a7195b..91c0689 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -1308,7 +1308,7 @@ Returns a hash copy of all loaded configuration data stored in the module
 after the files have been loaded, or a hashref to this hash in
 scalar context.
 
-=head2 config_filenames
+=head2 config_files
 
 An array reference containing the absolute filenames of all config files
 that are currently loaded, in the order they were loaded.

commit be3f05c4aa834fe72d8b864b1af22cf0bf2da88b
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 20:01:51 2011 -0400

    Minor spelling nitpicks

diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index 91c0689..38b560e 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -1221,7 +1221,7 @@ L<http://www.kernel.org/pub/software/scm/git/docs/git-config.html#_configuration
 for details on the syntax of git configuration files. We won't waste pixels
 on the nitty gritty here.
 
-While the behaviour of a couple of this module's methods differ slightly
+While the behavior of a couple of this module's methods differ slightly
 from the C<git config> equivalents, this module can read any config file
 written by git. The converse is usually true, but only if you don't take
 advantage of this module's increased permissiveness when it comes to key
@@ -1262,7 +1262,7 @@ for each type.
 All get and set methods can filter what values they return via their
 C<filter> parameter, which is expected to be a string that is a valid
 regex. If you want to filter items OUT instead of IN, you can
-prefix your regex with a ! and that'll do the trick.
+prefix your regex with a ! and that will do the trick.
 
 Now, on the the methods!
 
@@ -1614,7 +1614,7 @@ Return C<value> cast into the type specified by C<as>.
 Valid values for C<as> are C<bool>, C<int>, C<num>, or C<bool-or-num>. For
 C<bool>, C<true>, C<yes>, C<on>, C<1>, and undef are translated into a true
 value (for Perl); anything else is false. Specifying a true value for the
-C<human> arg will get you a human-readable 'true' or 'false' rather than a
+C<human> argument will get you a human-readable 'true' or 'false' rather than a
 value that plays along with Perl's definition of truthiness (0 or 1).
 
 For C<int>s and C<num>s, if C<value> ends in C<k>, C<m>, or C<g>, it will be

commit 919a5617be6b470779e9dc1e25c613fe210728dd
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 19:50:41 2011 -0400

    Calling ->load_file on a nonexistant file should not set ->is_loaded

diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index 38b560e..f1bc7eb 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -147,11 +147,13 @@ sub _read_config {
 sub load_file {
     my $self = shift;
     my ($filename) = @_;
-    $self->data({}) unless $self->is_loaded;
 
     return $self->data if grep {$_ eq $filename} @{$self->config_files};
 
     my $c = $self->_read_config($filename);
+    return unless defined $c;
+
+    $self->data({}) unless $self->is_loaded;
     $self->parse_content(
         content  => $c,
         callback => sub {
@@ -1523,10 +1525,6 @@ Takes a string containing the path to a file, opens it if it exists, loads its
 config variables into memory, and returns the currently loaded config
 variables (a hashref).
 
-Note that you ought to only call this subroutine with an argument that you
-know exists, otherwise config files that don't exist will be recorded as
-havind been loaded.
-
 =head2 parse_content
 
 Parameters:

commit dcdd01f23ebd1cf481097b91c535a10fc7e8d8f4
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 19:52:28 2011 -0400

    Do simple canonicalization prior to loading a file
    
    This moves the ~ expansion somewhat more centrally, as well as helping
    not load a file more than once if it is specified by both relative and
    absolute paths.

diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index f1bc7eb..ff176da 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -121,7 +121,7 @@ sub load_global {
 sub user_file {
     my $self = shift;
     return
-        File::Spec->catfile( $ENV{'HOME'}, "." . $self->confname );
+        File::Spec->catfile( "~", "." . $self->confname );
 }
 
 sub load_user {
@@ -148,6 +148,10 @@ sub load_file {
     my $self = shift;
     my ($filename) = @_;
 
+    # Do some canonicalization
+    $filename =~ s/~/$ENV{'HOME'}/g;
+    $filename = File::Spec->rel2abs($filename);
+
     return $self->data if grep {$_ eq $filename} @{$self->config_files};
 
     my $c = $self->_read_config($filename);

commit 8a062609ad6302b999920008ef6a3f957288c580
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 20:08:38 2011 -0400

    ->dump should imply a ->load if we've not done so already

diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index ff176da..f744676 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -604,6 +604,8 @@ sub get_regexp {
 sub dump {
     my $self = shift;
 
+    $self->load unless $self->is_loaded;
+
     return %{$self->data} if wantarray;
 
     my $data = '';

commit 835d0659484245d77c5aab10432c37f408c4ac9d
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 19:54:01 2011 -0400

    Document that ->load is often unnecessary

diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index f744676..aafe1d6 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -1141,7 +1141,6 @@ Code that uses this config module might look like:
     use Config::GitLike;
 
     my $c = Config::GitLike->new(confname => 'config');
-    $c->load;
 
     $c->get( key => 'section.name' );
     # make the return value a Perl true/false value
@@ -1304,6 +1303,10 @@ passing in a new name (and then reloading via L<"load">).
 
 =head2 load
 
+This method is usually called implicitly on the first L</get>,
+L</get_all>, L</get_regex>, or L</dump> call used, and is only necessary
+if you want to explicitly reload the data.
+
 Load the global, local, and directory configuration file with the filename
 C<confname>(if they exist). Configuration variables loaded later
 override those loaded earlier, so variables from the directory

commit 6d658d3a8f933c6453b8221c6e82921f84c1e85a
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 20:15:08 2011 -0400

    Allow load_file as a class method to just read one file, for simplicity
    
    This makes the module easier to use useful in one-liners and less
    complicated scenarios.

diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index aafe1d6..1cba087 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -145,9 +145,17 @@ sub _read_config {
 }
 
 sub load_file {
-    my $self = shift;
+    my $ref = shift;
     my ($filename) = @_;
 
+    my $self;
+    if (ref $ref) {
+        $self = $ref;
+    } else {
+        # Set up a temporary object
+        $self = $ref->new( confname => "" );
+    }
+
     # Do some canonicalization
     $filename =~ s/~/$ENV{'HOME'}/g;
     $filename = File::Spec->rel2abs($filename);
@@ -155,7 +163,10 @@ sub load_file {
     return $self->data if grep {$_ eq $filename} @{$self->config_files};
 
     my $c = $self->_read_config($filename);
-    return unless defined $c;
+    unless (defined $c) {
+        die "Failed to load $filename: $!\n" if not ref $ref;
+        return;
+    }
 
     $self->data({}) unless $self->is_loaded;
     $self->parse_content(
@@ -1140,6 +1151,11 @@ Code that uses this config module might look like:
 
     use Config::GitLike;
 
+    # just load a specific file
+    my $data = Config::GitLike->load_file("~/.fooconf");
+
+    # or use the object interface to load /etc/config, ~/.config, and
+    # `pwd`/.config
     my $c = Config::GitLike->new(confname => 'config');
 
     $c->get( key => 'section.name' );
@@ -1280,6 +1296,9 @@ There are the methods you're likely to use the most.
 =head2 new( confname => 'config' )
 
 Create a new configuration object with the base config name C<confname>.
+If you are interested simply in loading one specific file, and not in
+automatically loading a global file, a per-user file, and a
+per-directory file, see L</load_file>, below.
 
 C<confname> is used to construct the filenames that will be loaded; by
 default, these are C</etc/confname> (global configuration file),
@@ -1534,6 +1553,9 @@ Takes a string containing the path to a file, opens it if it exists, loads its
 config variables into memory, and returns the currently loaded config
 variables (a hashref).
 
+This method can also be called as a class method, which will die if the
+file cannot be read.
+
 =head2 parse_content
 
 Parameters:

commit 34584f698000b50a88d047b74efc5b4986b798fc
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 20:44:21 2011 -0400

    Don't skip ExtraTests.pm, which also contains "xt"

diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
index 69ff982..d561f22 100644
--- a/MANIFEST.SKIP
+++ b/MANIFEST.SKIP
@@ -10,6 +10,6 @@ pm_to_blib
 .gitignore$
 .shipit$
 inc/.author
-xt
+^xt/
 MANIFEST.SKIP
 cover_db/

commit 7502844ad287f4d8864e3a2e91fccddf9a4a594a
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 20:18:58 2011 -0400

    Revert "we don't have any extra tests" -- we do have them
    
    This reverts commit d59b415077f17db1c61906cc9766815dfe424fe6.  Use
    `RELEASE_TESTING=1 make test` to run tests with them.

diff --git a/Makefile.PL b/Makefile.PL
index f1f1116..3360234 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -8,5 +8,6 @@ build_requires 'Test::More';
 build_requires 'Test::Exception';
 build_requires 'File::Spec';
 build_requires 'File::Temp';
+extra_tests();
 sign();
 WriteAll();

commit 824caa83bbb695b2bcde6a05f87d2c4514c13cc2
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 20:34:27 2011 -0400

    Config::GitLike contains "use 5.008" -- make that obvious at build-time

diff --git a/Makefile.PL b/Makefile.PL
index 3360234..66b207f 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -3,6 +3,7 @@ name('Config-GitLike');
 all_from('lib/Config/GitLike.pm');
 repository('http://github.com/bestpractical/config-gitlike');
 
+perl_version '5.008';
 requires 'Any::Moose';
 build_requires 'Test::More';
 build_requires 'Test::Exception';

commit e8b4acfc6d43f831af9be8c8f725c37647fc0b9d
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 20:35:40 2011 -0400

    Perl 5.8 is guaranteed to provide these three modules

diff --git a/Makefile.PL b/Makefile.PL
index 66b207f..31bd0ee 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -5,10 +5,7 @@ repository('http://github.com/bestpractical/config-gitlike');
 
 perl_version '5.008';
 requires 'Any::Moose';
-build_requires 'Test::More';
 build_requires 'Test::Exception';
-build_requires 'File::Spec';
-build_requires 'File::Temp';
 extra_tests();
 sign();
 WriteAll();

commit 74f5b4a683a8b1f6636730c42b5a436a4bed92c1
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 20:36:10 2011 -0400

    Document two overridden functions

diff --git a/lib/Config/GitLike/Git.pm b/lib/Config/GitLike/Git.pm
index f68ad8d..4961070 100644
--- a/lib/Config/GitLike/Git.pm
+++ b/lib/Config/GitLike/Git.pm
@@ -93,6 +93,15 @@ The per-user configuration file is F<~/.gitconfig>
 
 The per-host configuration file is F</etc/gitconfig>
 
+=head2 is_git_dir
+
+Returns true if a file contains the necessary files (as git would reckon
+it) for the path to be a git repository.
+
+=head2 load_dirs
+
+Loads the relevant .git/config file.
+
 =head1 SEE ALSO
 
 L<Config::GitLike|Config::GitLike>

commit 93f2029ac04a323387ca60108fcd4f8267a8af1d
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 20:36:36 2011 -0400

    We do not ship a bin/ directory

diff --git a/xt/release/00-dependencies.t b/xt/release/00-dependencies.t
index f601789..97c7875 100644
--- a/xt/release/00-dependencies.t
+++ b/xt/release/00-dependencies.t
@@ -23,7 +23,7 @@ elsif ( ! -e 'inc/.author' ) {
 plan 'no_plan';
 
 my %used;
-find( \&wanted, qw/ lib bin t / );
+find( \&wanted, qw/ lib t / );
 
 sub wanted {
     return unless -f $_;

commit 5d89d88978b1c1e5491bb036823cf185b8ab9323
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 20:37:14 2011 -0400

    "use 5.008" is exempt from having to be in Makefile.PL

diff --git a/xt/release/00-dependencies.t b/xt/release/00-dependencies.t
index 97c7875..bc85853 100644
--- a/xt/release/00-dependencies.t
+++ b/xt/release/00-dependencies.t
@@ -42,7 +42,7 @@ sub wanted {
     $data =~ s/^=head.+?(^=cut|\Z)//gms;
 
     # look for use and use base statements
-    $used{$1}{$File::Find::name}++ while $data =~ /^\s*use\s+([\w:]+)/gm;
+    $used{$1}{$File::Find::name}++ while $data =~ /^\s*use\s+(\d(\.\d+)*|[\w:]+)/gm;
     while ( $data =~ m|^\s*use base qw.([\w\s:]+)|gm ) {
         $used{$_}{$File::Find::name}++ for split ' ', $1;
     }
@@ -65,7 +65,7 @@ my %required;
 for ( sort keys %used ) {
     my $first_in = Module::CoreList->first_release($_);
     next if defined $first_in and $first_in <= 5.00803;
-    next if /^(Config::GitLike|inc|t)(::|$)/;
+    next if /^(Config::GitLike|inc|t|\d(\.\d+)*)(::|$)/;
 
     #warn $_;
     ok( exists $required{$_}, "$_ in Makefile.PL" )

commit 7ec1f7d6a02765754de63b452871f1a7a221a21a
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 20:37:32 2011 -0400

    TestConfig is similarly exempt from being a dep in Makefile.PL

diff --git a/xt/release/00-dependencies.t b/xt/release/00-dependencies.t
index bc85853..9b7b456 100644
--- a/xt/release/00-dependencies.t
+++ b/xt/release/00-dependencies.t
@@ -65,7 +65,7 @@ my %required;
 for ( sort keys %used ) {
     my $first_in = Module::CoreList->first_release($_);
     next if defined $first_in and $first_in <= 5.00803;
-    next if /^(Config::GitLike|inc|t|\d(\.\d+)*)(::|$)/;
+    next if /^(Config::GitLike|inc|t|TestConfig|\d(\.\d+)*)(::|$)/;
 
     #warn $_;
     ok( exists $required{$_}, "$_ in Makefile.PL" )

commit 8cf93caadb5f93e7f365cf2c43cd6ec77615ce65
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Oct 12 20:49:34 2011 -0400

    Version 1.06 releng

diff --git a/Changes b/Changes
index 63953cb..975055b 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,15 @@
+1.06 2011-10-12
+
+* Allow calling ->load_file as a class method, for simple use cases
+  (alexmv)
+* Fix a parsing bug when quoted strings directly adjoined to unquoted
+  strings (alexmv)
+* Calling ->load_file on a nonexistant file no longer sets ->is_loaded
+  (alexmv)
+* Document that getters implicitly call ->load (alexmv)
+* Make ->dump implicitly call ->load as well (alexmv)
+* Minor POD fixes (alexmv, spang)
+
 1.05 2011-01-07
 
 * support Module::Install::ExtraTests 0.007 (sunnavy)
diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index 1cba087..f19312a 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -7,7 +7,7 @@ use Scalar::Util qw(openhandle);
 use Fcntl qw(O_CREAT O_EXCL O_WRONLY);
 use 5.008;
 
-our $VERSION = '1.05';
+our $VERSION = '1.06';
 
 
 has 'confname' => (

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



More information about the Bps-public-commit mailing list