Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit a0e9dd348c15bbbe23114ca890e0aa3ab595e9bb 1 parent ceb84f5
David E. Wheeler authored September 08, 2011
3  bin/pgxn_site_server
@@ -30,7 +30,8 @@ _pod2usage(
30 30
 
31 31
 if ($version) {
32 32
     require File::Basename;
33  
-    say File::Basename::basename($0), ' ', PGXN::Site->VERSION;
  33
+    require PGXN::Site;
  34
+    say File::Basename::basename($0), ' ', PGXN::Site->version_string;
34 35
     exit;
35 36
 }
36 37
 
16  lib/PGXN/Site.pm
@@ -4,6 +4,10 @@ use 5.10.0;
4 4
 use utf8;
5 5
 our $VERSION = v0.8.0;
6 6
 
  7
+sub version_string {
  8
+    sprintf 'v%vd', $VERSION;
  9
+}
  10
+
7 11
 1;
8 12
 
9 13
 =head1 Name
@@ -68,6 +72,18 @@ will be provided as a clickable link.
68 72
 
69 73
 =back
70 74
 
  75
+=head1 Interface
  76
+
  77
+The PGXN::Site class itself consists of a single class method.
  78
+
  79
+=head2 Class Method
  80
+
  81
+=head3 C<version_string>
  82
+
  83
+  say 'PGXN::API ', PGXN::API->version_string;
  84
+
  85
+Returns a string representation of the PGXN::API version.
  86
+
71 87
 =head1 Author
72 88
 
73 89
 David E. Wheeler <david.wheeler@pgexperts.com>
5  lib/PGXN/Site/Templates.pm
@@ -3,6 +3,7 @@ package PGXN::Site::Templates;
3 3
 use 5.10.0;
4 4
 use utf8;
5 5
 use parent 'Template::Declare';
  6
+use PGXN::Site;
6 7
 use PGXN::Site::Locale;
7 8
 use Template::Declare::Tags;
8 9
 use Software::License::PostgreSQL;
@@ -58,7 +59,7 @@ BEGIN { create_wrapper wrapper => sub {
58 59
                 link {
59 60
                     rel   is 'stylesheet';
60 61
                     type  is 'text/css';
61  
-                    href  is "/ui/css/$spec->[0].css?" . __PACKAGE__->VERSION;
  62
+                    href  is "/ui/css/$spec->[0].css?" . PGXN::Site->version_string;
62 63
                     media is $spec->[1];
63 64
                 };
64 65
             }
@@ -139,7 +140,7 @@ BEGIN { create_wrapper wrapper => sub {
139 140
                     id is 'width';
140 141
                     span {
141 142
                         class is 'floatLeft';
142  
-                        outs __PACKAGE__->VERSION;
  143
+                        outs +PGXN::Site->version_string;
143 144
                         span { class is 'grey'; '|' };
144 145
                         outs 'code';
145 146
                         a {
4  t/router.t
@@ -7,7 +7,7 @@ use Test::More;
7 7
 #use Test::More 'no_plan';
8 8
 eval "use PGXN::API::Searcher";
9 9
 plan skip_all => "PGXN::API::Searcher required for router testing" if $@;
10  
-plan tests => 369;
  10
+plan tests => 368;
11 11
 
12 12
 use Plack::Test;
13 13
 use HTTP::Request::Common;
@@ -479,8 +479,6 @@ test_psgi $err_app => sub {
479 479
     my $cb = shift;
480 480
     ok my $res = $cb->(GET '/error'), "GET /error";
481 481
     ok $res->is_success, q{Should be success (because it's only served as a subrequest)};
482  
-    is $res->header('X-PGXN-API-Version'), PGXN::API->VERSION,
483  
-        'Should have API version in the header';
484 482
     like $res->content, qr{\Q<p>Internal server error.</p>},
485 483
         'body should contain error message';
486 484
 
4  t/templates.t
@@ -264,7 +264,7 @@ sub test_wrapper {
264 264
         );
265 265
 
266 266
         my $i = 0;
267  
-        my $v = PGXN::Site->VERSION;
  267
+        my $v = PGXN::Site->version_string;
268 268
         for my $spec (
269 269
             [ html   => 'screen, projection, tv' ],
270 270
             [ layout => 'screen, projection, tv' ],
@@ -373,7 +373,7 @@ sub test_wrapper {
373 373
             $tx->ok('./span[1]', 'Test the first span' => sub {
374 374
                 $tx->is('count(./*)', 6, 'Should have 6elements below #floatLeft');
375 375
                 $tx->is('./@class', 'floatLeft', 'Should be floatLeft');
376  
-                my $v = PGXN::Site->VERSION;
  376
+                my $v = PGXN::Site->version_string;
377 377
                 $tx->like('./text()', qr{^\Q$v\E\b}, qq{Text should contain "$v"});
378 378
                 $tx->like('./text()', qr{\bcode\b}, 'Text should contain "code"');
379 379
                 $tx->like('./text()', qr{\bdesign\b}, 'Text should contain "design"');

0 notes on commit a0e9dd3

Please sign in to comment.
Something went wrong with that request. Please try again.