[Bps-public-commit] RT-Extension-PriorityAsString branch, master, updated. 0.04-17-g443858a
Kevin Falcone
falcone at bestpractical.com
Wed Aug 29 17:42:05 EDT 2012
The branch, master has been updated
via 443858aec4e5732f45dc17d03a677f1641dab71f (commit)
via 7b74467aa28d31567cf37fc2230ba01b44c4af42 (commit)
via c3e0b5f524198c80147a9ee3410ca19950304c55 (commit)
via 880ca9b4444f49cd6f570b6ad4d09bcb4f3d72ca (commit)
via ec8f671892eef75aec2f37192757b7954a184928 (commit)
from 04e15f2e6354d78ecb0f8e4496feaf3fa2d032f0 (commit)
Summary of changes:
.gitignore | 13 +++-
README | 16 +++--
html/Elements/SelectPriorityAsString | 5 +-
inc/Module/Install/RTx.pm | 30 ++--------
inc/Module/Install/ReadmeFromPod.pm | 112 +++++++++++++++++++++++++++++++----
lib/RT/Extension/PriorityAsString.pm | 27 ++++-----
6 files changed, 141 insertions(+), 62 deletions(-)
- Log -----------------------------------------------------------------
commit ec8f671892eef75aec2f37192757b7954a184928
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Mon Aug 6 12:30:24 2012 -0400
bump up MI
diff --git a/inc/Module/Install/ReadmeFromPod.pm b/inc/Module/Install/ReadmeFromPod.pm
index 348531e..fb7075f 100644
--- a/inc/Module/Install/ReadmeFromPod.pm
+++ b/inc/Module/Install/ReadmeFromPod.pm
@@ -7,29 +7,119 @@ use warnings;
use base qw(Module::Install::Base);
use vars qw($VERSION);
-$VERSION = '0.12';
+$VERSION = '0.18';
sub readme_from {
my $self = shift;
return unless $self->is_admin;
- my $file = shift || $self->_all_from
+ # Input file
+ my $in_file = shift || $self->_all_from
or die "Can't determine file to make readme_from";
- my $clean = shift;
- print "Writing README from $file\n";
+ # Get optional arguments
+ my ($clean, $format, $out_file, $options);
+ my $args = shift;
+ if ( ref $args ) {
+ # Arguments are in a hashref
+ if ( ref($args) ne 'HASH' ) {
+ die "Expected a hashref but got a ".ref($args)."\n";
+ } else {
+ $clean = $args->{'clean'};
+ $format = $args->{'format'};
+ $out_file = $args->{'output_file'};
+ $options = $args->{'options'};
+ }
+ } else {
+ # Arguments are in a list
+ $clean = $args;
+ $format = shift;
+ $out_file = shift;
+ $options = \@_;
+ }
+
+ # Default values;
+ $clean ||= 0;
+ $format ||= 'txt';
+
+ # Generate README
+ print "readme_from $in_file to $format\n";
+ if ($format =~ m/te?xt/) {
+ $out_file = $self->_readme_txt($in_file, $out_file, $options);
+ } elsif ($format =~ m/html?/) {
+ $out_file = $self->_readme_htm($in_file, $out_file, $options);
+ } elsif ($format eq 'man') {
+ $out_file = $self->_readme_man($in_file, $out_file, $options);
+ } elsif ($format eq 'pdf') {
+ $out_file = $self->_readme_pdf($in_file, $out_file, $options);
+ }
- require Pod::Text;
- my $parser = Pod::Text->new();
- open README, '> README' or die "$!\n";
- $parser->output_fh( *README );
- $parser->parse_file( $file );
if ($clean) {
- $self->clean_files('README');
+ $self->clean_files($out_file);
}
+
return 1;
}
+
+sub _readme_txt {
+ my ($self, $in_file, $out_file, $options) = @_;
+ $out_file ||= 'README';
+ require Pod::Text;
+ my $parser = Pod::Text->new( @$options );
+ open my $out_fh, '>', $out_file or die "Could not write file $out_file:\n$!\n";
+ $parser->output_fh( *$out_fh );
+ $parser->parse_file( $in_file );
+ close $out_fh;
+ return $out_file;
+}
+
+
+sub _readme_htm {
+ my ($self, $in_file, $out_file, $options) = @_;
+ $out_file ||= 'README.htm';
+ require Pod::Html;
+ Pod::Html::pod2html(
+ "--infile=$in_file",
+ "--outfile=$out_file",
+ @$options,
+ );
+ # Remove temporary files if needed
+ for my $file ('pod2htmd.tmp', 'pod2htmi.tmp') {
+ if (-e $file) {
+ unlink $file or warn "Warning: Could not remove file '$file'.\n$!\n";
+ }
+ }
+ return $out_file;
+}
+
+
+sub _readme_man {
+ my ($self, $in_file, $out_file, $options) = @_;
+ $out_file ||= 'README.1';
+ require Pod::Man;
+ my $parser = Pod::Man->new( @$options );
+ $parser->parse_from_file($in_file, $out_file);
+ return $out_file;
+}
+
+
+sub _readme_pdf {
+ my ($self, $in_file, $out_file, $options) = @_;
+ $out_file ||= 'README.pdf';
+ eval { require App::pod2pdf; }
+ or die "Could not generate $out_file because pod2pdf could not be found\n";
+ my $parser = App::pod2pdf->new( @$options );
+ $parser->parse_from_file($in_file);
+ open my $out_fh, '>', $out_file or die "Could not write file $out_file:\n$!\n";
+ select $out_fh;
+ $parser->output;
+ select STDOUT;
+ close $out_fh;
+ return $out_file;
+}
+
+
sub _all_from {
my $self = shift;
return unless $self->admin->{extensions};
@@ -44,5 +134,5 @@ sub _all_from {
__END__
-#line 112
+#line 254
commit 880ca9b4444f49cd6f570b6ad4d09bcb4f3d72ca
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Wed Aug 29 17:35:07 2012 -0400
bump MI
diff --git a/inc/Module/Install/RTx.pm b/inc/Module/Install/RTx.pm
index 73b9cda..2eba7ad 100644
--- a/inc/Module/Install/RTx.pm
+++ b/inc/Module/Install/RTx.pm
@@ -8,7 +8,7 @@ no warnings 'once';
use Module::Install::Base;
use base 'Module::Install::Base';
-our $VERSION = '0.29';
+our $VERSION = '0.29_02';
use FindBin;
use File::Glob ();
@@ -129,18 +129,7 @@ install ::
my %has_etc;
if ( File::Glob::bsd_glob("$FindBin::Bin/etc/schema.*") ) {
-
- # got schema, load factory module
$has_etc{schema}++;
- $self->load('RTxFactory');
- $self->postamble(<< ".");
-factory ::
-\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxFactory(qw($RTx $name))"
-
-dropdb ::
-\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxFactory(qw($RTx $name drop))"
-
-.
}
if ( File::Glob::bsd_glob("$FindBin::Bin/etc/acl.*") ) {
$has_etc{acl}++;
@@ -164,28 +153,19 @@ dropdb ::
print "For first-time installation, type 'make initdb'.\n";
my $initdb = '';
$initdb .= <<"." if $has_etc{schema};
-\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(schema))"
+\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(schema \$(NAME) \$(VERSION)))"
.
$initdb .= <<"." if $has_etc{acl};
-\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(acl))"
+\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(acl \$(NAME) \$(VERSION)))"
.
$initdb .= <<"." if $has_etc{initialdata};
-\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(insert))"
+\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(insert \$(NAME) \$(VERSION)))"
.
$self->postamble("initdb ::\n$initdb\n");
$self->postamble("initialize-database ::\n$initdb\n");
}
}
-sub RTxInit {
- unshift @INC, substr( delete( $INC{'RT.pm'} ), 0, -5 ) if $INC{'RT.pm'};
- require RT;
- RT::LoadConfig();
- RT::ConnectToDatabase();
-
- die "Cannot load RT" unless $RT::Handle and $RT::DatabaseType;
-}
-
# stolen from RT::Handle so we work on 3.6 (cmp_versions came in with 3.8)
{ my %word = (
a => -4,
@@ -228,4 +208,4 @@ sub requires_rt {
__END__
-#line 348
+#line 328
commit c3e0b5f524198c80147a9ee3410ca19950304c55
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Aug 28 22:42:13 2012 -0400
Only use PriorityAsStringOrder for display
Any value of PriorityAsStringOrder which was different from the computed
set (by re-ordering or substraction of levels) would also cause the
levels for display to be incorrect. Fix the algorithm to be independent
of the PriorityAsStringOrder setting, and update the documentation to
make it clearer that most use cases do not require setting it.
diff --git a/html/Elements/SelectPriorityAsString b/html/Elements/SelectPriorityAsString
index 11db60b..281ecc2 100644
--- a/html/Elements/SelectPriorityAsString
+++ b/html/Elements/SelectPriorityAsString
@@ -22,9 +22,8 @@ $Mapping => undef
<%INIT>
my %map = $Mapping ? %{ $Mapping } : RT->Config->Get('PriorityAsString');
-my @order = RT->Config->Get('PriorityAsStringOrder');
- at order = sort { $map{$a} <=> $map{$b} } keys %map
- unless @order;
+my @order = $Mapping ? sort { $map{$a} <=> $map{$b} } keys %map
+ : grep {exists $map{$_}} RT->Config->Get('PriorityAsStringOrder');
my $default_label = '';
if ( defined $Default && length $Default ) {
diff --git a/lib/RT/Extension/PriorityAsString.pm b/lib/RT/Extension/PriorityAsString.pm
index ac7673c..6ad9dd8 100644
--- a/lib/RT/Extension/PriorityAsString.pm
+++ b/lib/RT/Extension/PriorityAsString.pm
@@ -19,9 +19,11 @@ RT::Extension::PriorityAsString - show priorities in RT as strings instead of nu
# numeric representation
Set(%PriorityAsString, (Low => 0, Medium => 50, High => 100));
- # which order to display the priority strings
- # if you don't specify this, the strings in the PriorityAsString
- # hash will be sorted and displayed
+ # Fine-tuned control of the order of priorities as displayed in the
+ # drop-down box; usually this computed automatically and need not be
+ # set explicitly. It can be used to limit the set of options
+ # presented during update, but allow a richer set of levels when
+ # they are adjusted automatically.
Set(@PriorityAsStringOrder, qw(Low Medium High));
# Uncomment if you want to apply different configurations to
@@ -88,15 +90,10 @@ sub _PriorityAsString {
} else {
%map = RT->Config->Get('PriorityAsString');
}
- if ( my ($res) = grep $map{$_} == $priority, keys %map ) {
- return $res;
- }
-
- my @order = reverse RT->Config->Get('PriorityAsStringOrder');
- @order = sort { $map{$b} <=> $map{$a} } keys %map
- unless @order;
- foreach my $label ( @order ) {
+ # Count from high down to low until we find one that our number is
+ # greater than or equal to.
+ foreach my $label ( sort { $map{$b} <=> $map{$a} } keys %map ) {
return $label if $priority >= $map{ $label };
}
return "unknown";
commit 7b74467aa28d31567cf37fc2230ba01b44c4af42
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Wed Aug 29 17:41:30 2012 -0400
Get all of our default gitignores
diff --git a/.gitignore b/.gitignore
index d8ea4ba..eedbd36 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,12 @@
+blib*
Makefile
-pm_to_blib
-blib/
-MANIFEST.bak
+Makefile.old
+pm_to_blib*
+*.tar.gz
+.lwpcookies
+cover_db
+pod2htm*.tmp
+/RT-Extension-PriorityAsString*
+*.bak
+*.swp
/MYMETA.*
commit 443858aec4e5732f45dc17d03a677f1641dab71f
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Wed Aug 29 17:41:40 2012 -0400
Update README from lib/ and update lib to be even more explicit
diff --git a/README b/README
index 68a88ba..12d77aa 100644
--- a/README
+++ b/README
@@ -10,17 +10,21 @@ SYNOPSIS
# numeric representation
Set(%PriorityAsString, (Low => 0, Medium => 50, High => 100));
- # which order to display the priority strings
- # if you don't specify this, the strings in the PriorityAsString
- # hash will be sorted and displayed
- Set(@PriorityAsStringOrder, qw(Low Medium High));
+ # Fine-tuned control of the order of priorities as displayed in the
+ # drop-down box; usually this computed automatically and need not be
+ # set explicitly. It can be used to limit the set of options
+ # presented during update, but allow a richer set of levels when
+ # they are adjusted automatically.
+ # Set(@PriorityAsStringOrder, qw(Low Medium High));
# Uncomment if you want to apply different configurations to
# different queues. Each key is the name of a different queue;
# queues which do not appear in this configuration will use RT's
# default numeric scale.
- # This option means that %PriorityAsString is ignored (no global
- # override, you must specify a set of priorities per queue).
+ # This option means that %PriorityAsString and
+ # @PriorityAsStringOrder are ignored (no global override, you must
+ # specify a set of priorities per queue). You can safely leave them
+ # out of your RT_SiteConfig.pm to avoid confusion.
# Set(%PriorityAsStringQueues,
# General => { Low => 0, Medium => 50, High => 100 },
# Binary => { Low => 0, High => 10 },
diff --git a/lib/RT/Extension/PriorityAsString.pm b/lib/RT/Extension/PriorityAsString.pm
index 6ad9dd8..ec403fd 100644
--- a/lib/RT/Extension/PriorityAsString.pm
+++ b/lib/RT/Extension/PriorityAsString.pm
@@ -24,14 +24,16 @@ RT::Extension::PriorityAsString - show priorities in RT as strings instead of nu
# set explicitly. It can be used to limit the set of options
# presented during update, but allow a richer set of levels when
# they are adjusted automatically.
- Set(@PriorityAsStringOrder, qw(Low Medium High));
+ # Set(@PriorityAsStringOrder, qw(Low Medium High));
# Uncomment if you want to apply different configurations to
# different queues. Each key is the name of a different queue;
# queues which do not appear in this configuration will use RT's
# default numeric scale.
- # This option means that %PriorityAsString is ignored (no global
- # override, you must specify a set of priorities per queue).
+ # This option means that %PriorityAsString and
+ # @PriorityAsStringOrder are ignored (no global override, you must
+ # specify a set of priorities per queue). You can safely leave them
+ # out of your RT_SiteConfig.pm to avoid confusion.
# Set(%PriorityAsStringQueues,
# General => { Low => 0, Medium => 50, High => 100 },
# Binary => { Low => 0, High => 10 },
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list