Permalink
Browse files

Add `version_string` to PGXN::Site and use it.

  • Loading branch information...
1 parent ceb84f5 commit a0e9dd348c15bbbe23114ca890e0aa3ab595e9bb @theory theory committed Sep 8, 2011
Showing with 24 additions and 8 deletions.
  1. +2 −1 bin/pgxn_site_server
  2. +16 −0 lib/PGXN/Site.pm
  3. +3 −2 lib/PGXN/Site/Templates.pm
  4. +1 −3 t/router.t
  5. +2 −2 t/templates.t
@@ -30,7 +30,8 @@ _pod2usage(
if ($version) {
require File::Basename;
- say File::Basename::basename($0), ' ', PGXN::Site->VERSION;
+ require PGXN::Site;
+ say File::Basename::basename($0), ' ', PGXN::Site->version_string;
exit;
}
View
@@ -4,6 +4,10 @@ use 5.10.0;
use utf8;
our $VERSION = v0.8.0;
+sub version_string {
+ sprintf 'v%vd', $VERSION;
+}
+
1;
=head1 Name
@@ -68,6 +72,18 @@ will be provided as a clickable link.
=back
+=head1 Interface
+
+The PGXN::Site class itself consists of a single class method.
+
+=head2 Class Method
+
+=head3 C<version_string>
+
+ say 'PGXN::API ', PGXN::API->version_string;
+
+Returns a string representation of the PGXN::API version.
+
=head1 Author
David E. Wheeler <david.wheeler@pgexperts.com>
@@ -3,6 +3,7 @@ package PGXN::Site::Templates;
use 5.10.0;
use utf8;
use parent 'Template::Declare';
+use PGXN::Site;
use PGXN::Site::Locale;
use Template::Declare::Tags;
use Software::License::PostgreSQL;
@@ -58,7 +59,7 @@ BEGIN { create_wrapper wrapper => sub {
link {
rel is 'stylesheet';
type is 'text/css';
- href is "/ui/css/$spec->[0].css?" . __PACKAGE__->VERSION;
+ href is "/ui/css/$spec->[0].css?" . PGXN::Site->version_string;
media is $spec->[1];
};
}
@@ -139,7 +140,7 @@ BEGIN { create_wrapper wrapper => sub {
id is 'width';
span {
class is 'floatLeft';
- outs __PACKAGE__->VERSION;
+ outs +PGXN::Site->version_string;
span { class is 'grey'; '|' };
outs 'code';
a {
View
@@ -7,7 +7,7 @@ use Test::More;
#use Test::More 'no_plan';
eval "use PGXN::API::Searcher";
plan skip_all => "PGXN::API::Searcher required for router testing" if $@;
-plan tests => 369;
+plan tests => 368;
use Plack::Test;
use HTTP::Request::Common;
@@ -479,8 +479,6 @@ test_psgi $err_app => sub {
my $cb = shift;
ok my $res = $cb->(GET '/error'), "GET /error";
ok $res->is_success, q{Should be success (because it's only served as a subrequest)};
- is $res->header('X-PGXN-API-Version'), PGXN::API->VERSION,
- 'Should have API version in the header';
like $res->content, qr{\Q<p>Internal server error.</p>},
'body should contain error message';
View
@@ -264,7 +264,7 @@ sub test_wrapper {
);
my $i = 0;
- my $v = PGXN::Site->VERSION;
+ my $v = PGXN::Site->version_string;
for my $spec (
[ html => 'screen, projection, tv' ],
[ layout => 'screen, projection, tv' ],
@@ -373,7 +373,7 @@ sub test_wrapper {
$tx->ok('./span[1]', 'Test the first span' => sub {
$tx->is('count(./*)', 6, 'Should have 6elements below #floatLeft');
$tx->is('./@class', 'floatLeft', 'Should be floatLeft');
- my $v = PGXN::Site->VERSION;
+ my $v = PGXN::Site->version_string;
$tx->like('./text()', qr{^\Q$v\E\b}, qq{Text should contain "$v"});
$tx->like('./text()', qr{\bcode\b}, 'Text should contain "code"');
$tx->like('./text()', qr{\bdesign\b}, 'Text should contain "design"');

0 comments on commit a0e9dd3

Please sign in to comment.