Browse files

(#4) Add semantic version support

This change replaces the validation of the version string using
Gem::Version.new() with a regular expression matching the semver.org
description of versions.

The reason for this change is that Gem::Version.new() is too restrictive
and does not allow semantic version strings to be used.  We're trying to
use semantic versions for modules and for development releases these may
be in the form of 0.0.2git-8-g3d316d1

Also changed the error message to indicate we support semantic versions and
provide the end user a link to semver.org for more information.
  • Loading branch information...
1 parent 69a43b8 commit fadc5b30d56031b421228eaf007dd7ab34647a97 @jeffmccune jeffmccune committed Jun 16, 2011
Showing with 2 additions and 4 deletions.
  1. +2 −4 lib/puppet/module/tool/applications/application.rb
View
6 lib/puppet/module/tool/applications/application.rb
@@ -70,10 +70,8 @@ def parse_filename!
unless @username && @module_name
abort "Username and Module name not provided"
end
- begin
- Gem::Version.new(@version)
- rescue ArgumentError => e
- abort "Invalid version format: #{@version}"
+ if @version !~ /^(\d+)\.(\d+)\.(\d+)$|^(\d)+\.(\d)+\.(\d+)([a-zA-Z][a-zA-Z0-9-]*)$/ then
+ abort "Invalid version format: #{@version} (Semantic Versions are acceptable: http://semver.org)"
end
end
end

0 comments on commit fadc5b3

Please sign in to comment.