[Bps-public-commit] RT-Extension-TicketLocking branch, master, updated. 17b999c205011f587970b13ba59c70d6c2d45eb7

Kevin Falcone falcone at bestpractical.com
Thu Feb 20 17:28:39 EST 2014


The branch, master has been updated
       via  17b999c205011f587970b13ba59c70d6c2d45eb7 (commit)
       via  015ed01858b5d091481b8200318d63e73c8cf62c (commit)
      from  b7453429240c4d3fd0cb7f31f48226f319d4e9b4 (commit)

Summary of changes:
 MANIFEST                            |   1 +
 META.yml                            |   2 +-
 Makefile.PL                         |   9 +-
 README                              | 179 +++++++++++++++++++++++++++++++++---
 inc/Module/Install/RTx.pm           |  64 +++++++------
 inc/Module/Install/ReadmeFromPod.pm | 138 +++++++++++++++++++++++++++
 lib/RT/Extension/TicketLocking.pm   |  81 ++++++++++++----
 7 files changed, 406 insertions(+), 68 deletions(-)
 create mode 100644 inc/Module/Install/ReadmeFromPod.pm

- Log -----------------------------------------------------------------
commit 015ed01858b5d091481b8200318d63e73c8cf62c
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Feb 20 17:16:09 2014 -0500

    Upgrade Module::Install::RTx

diff --git a/MANIFEST b/MANIFEST
index 403016e..74e56d9 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -57,6 +57,7 @@ inc/Module/Install/Can.pm
 inc/Module/Install/Fetch.pm
 inc/Module/Install/Makefile.pm
 inc/Module/Install/Metadata.pm
+inc/Module/Install/ReadmeFromPod.pm
 inc/Module/Install/RTx.pm
 inc/Module/Install/Substitute.pm
 inc/Module/Install/Win32.pm
diff --git a/inc/Module/Install/RTx.pm b/inc/Module/Install/RTx.pm
index ac04c79..469eb42 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.32';
+our $VERSION = '0.32_02';
 
 use FindBin;
 use File::Glob     ();
@@ -136,7 +136,9 @@ install ::
         $has_etc{acl}++;
     }
     if ( -e 'etc/initialdata' ) { $has_etc{initialdata}++; }
-    if ( -d 'etc/upgrade/' )    { $has_etc{upgrade}++; }
+    if ( grep { /\d+\.\d+\.\d+.*$/ } glob('etc/upgrade/*.*.*') ) {
+        $has_etc{upgrade}++;
+    }
 
     $self->postamble("$postamble\n");
     unless ( $subdirs{'lib'} ) {
@@ -174,46 +176,50 @@ install ::
     }
 }
 
-# stolen from RT::Handle so we work on 3.6 (cmp_versions came in with 3.8)
-{ my %word = (
-    a     => -4,
-    alpha => -4,
-    b     => -3,
-    beta  => -3,
-    pre   => -2,
-    rc    => -1,
-    head  => 9999,
-);
-sub cmp_version($$) {
-    my ($a, $b) = (@_);
-    my @a = grep defined, map { /^[0-9]+$/? $_ : /^[a-zA-Z]+$/? $word{$_}|| -10 : undef }
-        split /([^0-9]+)/, $a;
-    my @b = grep defined, map { /^[0-9]+$/? $_ : /^[a-zA-Z]+$/? $word{$_}|| -10 : undef }
-        split /([^0-9]+)/, $b;
-    @a > @b
-        ? push @b, (0) x (@a- at b)
-        : push @a, (0) x (@b- at a);
-    for ( my $i = 0; $i < @a; $i++ ) {
-        return $a[$i] <=> $b[$i] if $a[$i] <=> $b[$i];
-    }
-    return 0;
-}}
 sub requires_rt {
     my ($self,$version) = @_;
 
     # if we're exactly the same version as what we want, silently return
     return if ($version eq $RT::VERSION);
 
-    my @sorted = sort cmp_version $version,$RT::VERSION;
+    _load_rt_handle();
+    my @sorted = sort RT::Handle::cmp_version $version,$RT::VERSION;
 
     if ($sorted[-1] eq $version) {
         # should we die?
-        warn "\nWarning: prerequisite RT $version not found. Your installed version of RT ($RT::VERSION) is too old.\n\n";
+        die "\nWarning: prerequisite RT $version not found. Your installed version of RT ($RT::VERSION) is too old.\n\n";
+    }
+}
+
+sub rt_too_new {
+    my ($self,$version,$msg) = @_;
+    $msg ||= "Your version %s is too new, this extension requires a release of RT older than %s\n";
+
+    _load_rt_handle();
+    my @sorted = sort RT::Handle::cmp_version $version,$RT::VERSION;
+
+    if ($sorted[0] eq $version) {
+        die sprintf($msg,$RT::VERSION,$version);
+    }
+}
+
+# RT::Handle runs FinalizeDatabaseType which calls RT->Config->Get
+# On 3.8, this dies.  On 4.0/4.2 ->Config transparently runs LoadConfig.
+# LoadConfig requires being able to read RT_SiteConfig.pm (root) so we'd
+# like to avoid pushing that on users.
+# Fake up just enough Config to let FinalizeDatabaseType finish, and
+# anyone later calling LoadConfig will overwrite our shenanigans.
+sub _load_rt_handle {
+    unless ($RT::Config) {
+        require RT::Config;
+        $RT::Config = RT::Config->new;
+        RT->Config->Set('DatabaseType','mysql');
     }
+    require RT::Handle;
 }
 
 1;
 
 __END__
 
-#line 336
+#line 362
diff --git a/inc/Module/Install/ReadmeFromPod.pm b/inc/Module/Install/ReadmeFromPod.pm
new file mode 100644
index 0000000..b5e03c3
--- /dev/null
+++ b/inc/Module/Install/ReadmeFromPod.pm
@@ -0,0 +1,138 @@
+#line 1
+package Module::Install::ReadmeFromPod;
+
+use 5.006;
+use strict;
+use warnings;
+use base qw(Module::Install::Base);
+use vars qw($VERSION);
+
+$VERSION = '0.22';
+
+sub readme_from {
+  my $self = shift;
+  return unless $self->is_admin;
+
+  # Input file
+  my $in_file  = shift || $self->_all_from
+    or die "Can't determine file to make readme_from";
+
+  # 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);
+  }
+
+  if ($clean) {
+    $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};
+  my ($metadata) = grep {
+    ref($_) eq 'Module::Install::Metadata';
+  } @{$self->admin->{extensions}};
+  return unless $metadata;
+  return $metadata->{values}{all_from} || '';
+}
+
+'Readme!';
+
+__END__
+
+#line 254
+

commit 17b999c205011f587970b13ba59c70d6c2d45eb7
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Feb 20 17:22:35 2014 -0500

    Update documentation to reflect modern standards for RT extensions
    
    This preps to release the 0.12 that was version bumped in October, but
    not actually released.

diff --git a/META.yml b/META.yml
index b5ab6cb..9ad6882 100644
--- a/META.yml
+++ b/META.yml
@@ -1,7 +1,7 @@
 ---
 abstract: 'Enables users to place advisory locks on tickets'
 author:
-  - 'Turner Hayes <thayes at bestpractical.com>'
+  - 'Turner Hayes    <thayes at bestpractical.com>'
 build_requires:
   ExtUtils::MakeMaker: 6.59
   Test::More: 0
diff --git a/Makefile.PL b/Makefile.PL
index f986ba5..43a3335 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -3,16 +3,11 @@ use inc::Module::Install;
 RTx('RT-Extension-TicketLocking');
 license('GPL2');
 all_from('lib/RT/Extension/TicketLocking.pm');
+readme_from;
 
 build_requires('Test::More');
 
-{ # check RT version
-    my @v = split /\./, "$RT::VERSION";
-    unless (($v[0]>=3 && $v[1]>=7) || $v[0]>3) {
-        die "Extension needs RT 3.7.0 at least, you have $RT::VERSION";
-    }
-}
-
+requires_rt('3.7.0');
 
 my ($lib_path) = $INC{'RT.pm'} =~ /^(.*)[\\\/]/;
 my $local_lib_path = "$RT::LocalPath/lib";
diff --git a/README b/README
index 3a42088..69ecbc3 100644
--- a/README
+++ b/README
@@ -1,24 +1,175 @@
-RT-Extension-TicketLocking
+NAME
+    RT::Extension::TicketLocking - Enables users to place advisory locks on
+    tickets
+
+DESCRIPTION
+    Locks can be of several different types. Current types are:
+
+    hard (manual) lock
+        A lock can be initiated manually by clicking the "Lock" link on one
+        of the pages for the ticket. However, hard locks are available only
+        to users who can ModifyTicket.
+
+    take lock
+        This is only applicable within RTIR. See "RTIR" section below.
+
+    auto lock
+        A lock is created whenever a user performs an action on a ticket
+        that takes multiple steps if a hard lock is not already in place for
+        that ticket.
+
+        An auto lock is removed once the user is done with whatever he was
+        doing on the page (e.g., when he clicks "Save Changes" on the Edit
+        page). It is also removed if the Unlock link is clicked from a page
+        that generated an auto lock.
+
+        Auto-lock is set for the following actions in RT:
+
+            - Comment
+            - Reply
+            - Resolve
+
+        RTIR's user may find list of actions below.
+
+    Locks are advisory: if a ticket is locked by one user, other users will
+    be given a notification (in red) that another user has locked the
+    ticket, with the locking user's name and how long he has had it locked
+    for, but they will still be allowed to edit and submit changes on the
+    ticket.
+
+    When a user locks a ticket (auto lock or hard lock), they are given a
+    notification informing them of their lock and how long they have had the
+    ticket locked (in some other color - currently green).
+
+  Removing locks
+    Locks will remain in place until:
+
+    *   The user is done editing/replying/etc. (for auto locks, if there is
+        no hard lock on the ticket)
+
+    *   A lock can be removed manually by clicking the "Unlock" link on one
+        of the pages for the ticket. This removes any type of lock.
+
+    *   The user logs out
+
+    *   A configurable expiry period has elapsed (if the $LockExpiry config
+        variable has been set to a value greater than zero)
+
+    When a user unlocks a ticket (auto unlock or hard unlock), they are
+    given a notification informing them that their lock has been removed,
+    and how long they had the ticket locked for.
+
+  Merging tickets
+    When a locked ticket (hard or take lock) is merged into another ticket,
+    the ticket being merged into will get the lock type of the ticket being
+    merged from. This lock shift is conditional upon priority, as usual - if
+    the merged from ticket has a lock of a lower priority than the merged-to
+    ticket, the merged-to ticket will retain its lock. If the merged-to
+    ticket is locked by a different user, that user will retain the lock.
+    Basically, the merged-to ticket will retain its lock if it is higher
+    priority than the lock on the ticket being merged from.
+
+  RTIR
+    Within RTIR auto locks are applied for the following actions:
+
+        - Edit
+        - Split
+        - Merge
+        - Advanced
+        - Reply
+        - Resolve
+        - Reject
+        - Comment
+        - Remove
+
+    As well, there is special type of lock implemented in RTIR. When a user
+    clicks the "Take" link for an RTIR Incident ticket, a Take lock is
+    added. This lock will only be removed when the IR is linked to a new or
+    existing Incident. If RTIR is not installed, this type will not be
+    available.
 
 INSTALLATION
+    "perl Makefile.PL"
+    "make"
+    "make install"
+        May need root permissions
+
+    Edit your /opt/rt4/etc/RT_SiteConfig.pm
+        If you are using RT 4.2 or greater, add this line:
+
+            Plugin('RT::Extension::TicketLocking');
+
+        For RT 3.8 and 4.0, add this line:
+
+            Set(@Plugins, qw(RT::Extension::TicketLocking));
+
+        or add "RT::Extension::TicketLocking" to your existing @Plugins
+        line.
+
+    Clear your mason cache
+            rm -rf /opt/rt4/var/mason_data/obj
+
+    Restart your webserver
+
+CONFIGURATION
+  LockExpiry option
+    In the config you can set LockExpiry option to a number of seconds, the
+    longest time a lock can remain without being automatically removed, for
+    example:
+
+        Set( $LockExpiry, 5*60 ); # lock expires after five minutes
+
+    If you don't wish to have your locks automatically expire, simply set
+    $LockExpiry to a false (zero or undef) value. This is the default if you
+    do not provide a $LockExpiry.
+
+  Allowing users to use 'MyLocks' portlet
+    The extension comes with a portlet users can place on thier home page
+    RT's or RTIR's. Using this portlet user can easily jump to locked
+    tickets, remove particular lock or all locks at once.
+
+    If you want the MyLocks portlet to be available then you have to place
+    it in the list of allowed components.
+
+    For RT:
+
+        Set($HomepageComponents, [qw(
+            MyLocks 
+            ... list of another portlets ...
+        )]);
+
+    People can then choose to add the portlet to their homepage in
+    Preferences -> 'RT at a glance'.
+
+    If you are running RTIR, and want the portlet to be available from the
+    RTIR home page, you will need to do something similar to set the
+    RTIR_HomepageComponents array in your config file, like this:
 
-To install this module, run the following commands:
+        Set(@RTIR_HomepageComponents, qw(
+            MyLocks
+            ... list of another portlets ...
+        ));
 
-    perl Makefile.PL
-    make
-    make install
+    People can then choose to add the portlet to their homepage in
+    Preferences -> 'RTIR Home'.
 
-DOCUMENTAION
+AUTHOR
+        Turner Hayes    <thayes at bestpractical.com>
+        Ruslan Zakirov  <ruz at bestpractical.com>
+        Kevin Falcone   <falcone at bestpractical.com>
 
-All documentation about this extension you can find in
-'lib/RT/Extension/TicketLocking.pm', use `perldoc` utility
-to read it.
+BUGS
+    All bugs should be reported via email to
+    bug-rt-extension-ticketlocking at rt.cpan.org
+    <mailto:bug-rt-extension-ticketlocking at rt.cpan.org> or via the web at
+    rt.cpan.org
+    <http://rt.cpan.org/Public/Dist/Display.html?Name=rt-extension-ticketloc
+    king>.
 
-    perldoc lib/RT/Extension/TicketLocking.pm
+LICENSE AND COPYRIGHT
+    This software is Copyright (c) 2007-2014 by Best Practical Solutions
 
-COPYRIGHT AND LICENCE
+    This is free software, licensed under:
 
-Copyright (C) 2007-2008, Best Practical Solutions LLC.
+      The GNU General Public License, Version 2, June 1991
 
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
diff --git a/lib/RT/Extension/TicketLocking.pm b/lib/RT/Extension/TicketLocking.pm
index e3c567e..55e6da3 100644
--- a/lib/RT/Extension/TicketLocking.pm
+++ b/lib/RT/Extension/TicketLocking.pm
@@ -2,8 +2,8 @@
 # 
 # COPYRIGHT:
 #  
-# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC 
-#                                          <jesse at bestpractical.com>
+# This software is Copyright (c) 2007-2014 Best Practical Solutions, LLC 
+#                                          <sales at bestpractical.com>
 # 
 # (Except where explicitly superseded by other copyright notices)
 # 
@@ -158,6 +158,39 @@ is added. This lock will only be removed when the IR is linked to
 a new or existing Incident. If RTIR is not installed, this type
 will not be available.
 
+=head1 INSTALLATION
+
+=over
+
+=item C<perl Makefile.PL>
+
+=item C<make>
+
+=item C<make install>
+
+May need root permissions
+
+=item Edit your F</opt/rt4/etc/RT_SiteConfig.pm>
+
+If you are using RT 4.2 or greater, add this line:
+
+    Plugin('RT::Extension::TicketLocking');
+
+For RT 3.8 and 4.0, add this line:
+
+    Set(@Plugins, qw(RT::Extension::TicketLocking));
+
+or add C<RT::Extension::TicketLocking> to your existing C<@Plugins> line.
+
+=item Clear your mason cache
+
+    rm -rf /opt/rt4/var/mason_data/obj
+
+=item Restart your webserver
+
+=back
+
+
 =head1 CONFIGURATION
 
 =head2 LockExpiry option
@@ -169,7 +202,8 @@ for example:
     Set( $LockExpiry, 5*60 ); # lock expires after five minutes
 
 If you don't wish to have your locks automatically expire, simply
-set $LockExpiry to a false (zero or undef) value.
+set $LockExpiry to a false (zero or undef) value. This is the default if
+you do not provide a $LockExpiry.
 
 =head2 Allowing users to use 'MyLocks' portlet
 
@@ -203,18 +237,38 @@ like this:
 People can then choose to add the portlet to their homepage
 in Preferences -> 'RTIR Home'.
 
-=head1 IMPLEMENTATION DETAILS
+=head1 AUTHOR
+
+    Turner Hayes    <thayes at bestpractical.com>
+    Ruslan Zakirov  <ruz at bestpractical.com>
+    Kevin Falcone   <falcone at bestpractical.com> 
+
+=head1 BUGS
+
+All bugs should be reported via email to
+L<bug-rt-extension-ticketlocking at rt.cpan.org|mailto:bug-rt-extension-ticketlocking at rt.cpan.org>
+or via the web at
+L<rt.cpan.org|http://rt.cpan.org/Public/Dist/Display.html?Name=rt-extension-ticketlocking>.
+
+=head1 LICENSE AND COPYRIGHT
+
+This software is Copyright (c) 2007-2014 by Best Practical Solutions
 
-Each type is associated with a priority. Current priorities are as follows,
-from highest priority to lowest:
-    - Hard
-    - Take (when applicable)
-    - Auto
+This is free software, licensed under:
 
-This allow us to store only one lock record with higher priority.
+  The GNU General Public License, Version 2, June 1991
 
 =cut
 
+# IMPLEMENTATION DETAILS
+#  Each type is associated with a priority. Current priorities are as follows,
+#  from highest priority to lowest:
+#      - Hard
+#      - Take (when applicable)
+#      - Auto
+#  
+#  This allow us to store only one lock record with higher priority.
+
 use RT::Ticket;
 package RT::Ticket;
 
@@ -345,10 +399,3 @@ sub RemoveLocks {
 }
 
 1;
-
-=head1 AUTHOR
-
-Turner Hayes E<lt>thayes at bestpractical.comE<gt>
-
-=cut
-

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



More information about the Bps-public-commit mailing list