Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: <pkg>::VERSION, git, hashes, shipit, Class::MOP, Moose, perl core support - what NOW makes sense.

by kyle (Abbot)
on Apr 21, 2009 at 03:20 UTC ( #758859=note: print w/ replies, xml ) Need Help??


in reply to <pkg>::VERSION, git, hashes, shipit, Class::MOP, Moose, perl core support - what NOW makes sense.

You could make a module part of your distribution whose job is only to hold the distribution version number.

package Your::Dist::Version; # note no strict $VERSION = 1.23; sub import { my $pkg = caller; ${ "$pkg\::VERSION" } = $VERSION; } 1;

Then use Your::Dist::Version from every module in the distribution. Everything that does has the One True Version inserted into its namespace. You can change it in one place and keep other info in that one file as convenient.


Comment on Re: <pkg>::VERSION, git, hashes, shipit, Class::MOP, Moose, perl core support - what NOW makes sense.
Select or Download Code
Re^2: <pkg>::VERSION, git, hashes, shipit, Class::MOP, Moose, perl core support - what NOW makes sense.
by otto (Beadle) on Apr 21, 2009 at 20:44 UTC

    Another way is to make the top-level module more akin to a base of the whole dist, which in some manners it is. Then others inherit the version. Class::MOP::Object provides dump for everything ...

    At issue is to examine and dissect what really is the use of ::VERSION for each of the concepts of file, module, package, and distribution. These are all very different, but often are used interchangeably due to some of the syntactic sugar applied to them. Dealing with versioning means you really need to carefully examine the distinctions

Re^2: <pkg>::VERSION, git, hashes, shipit, Class::MOP, Moose, perl core support - what NOW makes sense.
by JavaFan (Canon) on Apr 21, 2009 at 22:11 UTC
    Then use Your::Dist::Version from every module in the distribution. Everything that does has the One True Version inserted into its namespace.
    But it won't work.

    The CPAN indexer searches for lines in modules that seems to set the VERSION number, extracts that line, and executes it. Just that line. Nothing more. Any clever tricks you'd like to use will work at run time (for instance, if someone does use Module VERSION;), but the important part, the CPAN indexer, won't be able to find the version number.

      Sorry if that might seem ignorant, but why is that a problem? Can't the CPAN indexer simply take the version from the META.yaml and take that as a default version?

      Then all you have to do is to make sure that the meta data and Your::Dest::Version agree.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://758859]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2014-09-19 17:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (144 votes), past polls