[Jifty-commit] r992 - in jifty/trunk/lib/Jifty: . Script
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri May 5 00:20:58 EDT 2006
Author: autrijus
Date: Fri May 5 00:20:57 2006
New Revision: 992
Modified:
jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm
jifty/trunk/lib/Jifty/Handle.pm
jifty/trunk/lib/Jifty/Script/Action.pm
jifty/trunk/lib/Jifty/Script/App.pm
jifty/trunk/lib/Jifty/Script/Model.pm
jifty/trunk/lib/Jifty/Util.pm
Log:
* Jifty is now ported to Win32 (tested with ActivePerl 5.8.8.817).
* Unified nonportable _mkpath into Jifty::Util::make_path,
which now uses File::Path::mkpath underneath.
* On application creation, make bin/jifty.bat as well as bin/jifty.
* Changed nonportable use of splitdir() to File::Basename's
basename() and dirname().
* Jifty::Handle: correct "jifty schema --setup" sequence so
it can create tables from nonexisting databases.
Modified: jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm (original)
+++ jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm Fri May 5 00:20:57 2006
@@ -2,6 +2,7 @@
use base qw/Jifty::Action/;
use File::Spec;
+use File::Basename ();
=head1 NAME
@@ -161,9 +162,9 @@
sub take_action {
my $self = shift;
my $dest = $self->{'write_to'};
- my @dirs = File::Spec->splitdir( $dest );
- pop @dirs; # discard filename. we only want to make the directory ;)
- Jifty::Util->make_path( File::Spec->catdir(@dirs));
+
+ # discard filename. we only want to make the directory ;)
+ Jifty::Util->make_path( File::Basename::dirname( $dest ) );
my $writehandle = IO::File->new();
my $content = $self->argument_value('content');
Modified: jifty/trunk/lib/Jifty/Handle.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Handle.pm (original)
+++ jifty/trunk/lib/Jifty/Handle.pm Fri May 5 00:20:57 2006
@@ -124,7 +124,7 @@
local $SIG{__WARN__} = sub { };
$dbv = Jifty->handle->fetch_result(
"SELECT value FROM _jifty_metadata WHERE key = 'application_db_version'");
- };
+ } or undef($dbv);
}
die
Modified: jifty/trunk/lib/Jifty/Script/Action.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Action.pm (original)
+++ jifty/trunk/lib/Jifty/Script/Action.pm Fri May 5 00:20:57 2006
@@ -137,17 +137,6 @@
);
}
-sub _mkpath {
- my $self = shift;
- my @parts = File::Spec->splitdir( shift );
- for (0..$#parts) {
- my $path = File::Spec->catdir(@parts[0..$_]);
- next if -e $path and -d $path;
- print("Creating directory $path\n");
- mkdir $path or die "Can't create $path: $!";
- }
-}
-
sub _write {
my $self = shift;
my %files = (@_);
@@ -156,7 +145,7 @@
my ($volume, $dir, $file) = File::Spec->splitpath($path);
# Make sure the directories we need are there
- $self->_mkpath($dir);
+ Jifty::Util::make_path($dir);
# If it already exists, bail
if (-e $path and not $self->{force}) {
Modified: jifty/trunk/lib/Jifty/Script/App.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/App.pm (original)
+++ jifty/trunk/lib/Jifty/Script/App.pm Fri May 5 00:20:57 2006
@@ -7,6 +7,7 @@
use File::Copy;
use Jifty::Config;
use Jifty::YAML;
+use File::Basename;
__PACKAGE__->mk_accessors(qw/prefix dist_name mod_name/);
@@ -67,10 +68,18 @@
sub _install_jifty_binary {
my $self = shift;
my $prefix = $self->prefix;
+ my $basename = basename($0);
+
# Copy our running copy of 'jifty' to bin/jifty
- copy($0, "$prefix/bin/jifty");
+ copy($0, "$prefix/bin/$basename");
# Mark it executable
- chmod(0555, "$prefix/bin/jifty");
+ chmod(0555, "$prefix/bin/$basename");
+
+ # Do the same for .bat if we are on a DOSish platform
+ if (-e "$0.bat") {
+ copy("$0.bat", "$prefix/bin/$basename.bat");
+ chmod(0555, "$prefix/bin/$basename.bat");
+ }
}
Modified: jifty/trunk/lib/Jifty/Script/Model.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Model.pm (original)
+++ jifty/trunk/lib/Jifty/Script/Model.pm Fri May 5 00:20:57 2006
@@ -140,17 +140,6 @@
);
}
-sub _mkpath {
- my $self = shift;
- my @parts = File::Spec->splitdir( shift );
- for (0..$#parts) {
- my $path = File::Spec->catdir(@parts[0..$_]);
- next if -e $path and -d $path;
- print("Creating directory $path\n");
- mkdir $path or die "Can't create $path: $!";
- }
-}
-
sub _write {
my $self = shift;
my %files = (@_);
@@ -159,7 +148,7 @@
my ($volume, $dir, $file) = File::Spec->splitpath($path);
# Make sure the directories we need are there
- $self->_mkpath($dir);
+ Jifty::Util::make_path($dir);
# If it already exists, bail
if (-e $path and not $self->{force}) {
Modified: jifty/trunk/lib/Jifty/Util.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Util.pm (original)
+++ jifty/trunk/lib/Jifty/Util.pm Fri May 5 00:20:57 2006
@@ -14,8 +14,10 @@
use Jifty;
use File::Spec;
+use File::Path;
use File::ShareDir;
use UNIVERSAL::require;
+use ExtUtils::MakeMaker ();
use Cwd ();
# Trivial memoization to ward off evil Cwd calls.
@@ -112,7 +114,7 @@
while (@root) {
my $try = File::Spec->catdir( @root, "bin", "jifty" );
if ( -e $try
- and -x $try
+ and (-x $try or MM->maybe_command($try))
and $try ne "/usr/bin/jifty"
and $try ne "/usr/local/bin/jifty" )
{
@@ -158,17 +160,7 @@
sub make_path {
my $self = shift;
my $whole_path = shift;
- my @dirs = File::Spec->splitdir( $whole_path );
- my $path ='';
- foreach my $dir ( @dirs) {
- $path = File::Spec->catdir($path, $dir);
- if (-d $path) { next }
- if (-w $path) { die "$path not writable"; }
-
-
- mkdir($path) || die "Couldn't create directory $path: $!";
- }
-
+ File::Path::mkpath([$whole_path]);
}
=head2 require PATH
More information about the Jifty-commit
mailing list