Module: Confetti::Template::VersionHelper

Included in:
BlackberryWidgetsConfig, WebosAppinfo, WindowsPhone7Manifest
Defined in:
lib/confetti/templates/version_helper.rb

Defined Under Namespace

Classes: VersionError

Instance Method Summary collapse

Instance Method Details

#normalize_version(str) ⇒ Object

ensure version is in “x.x.x” format



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/confetti/templates/version_helper.rb', line 7

def normalize_version(str)
  default = "0.0.1"

  if str.nil? or str.empty?
    default
  elsif str.match /^(\d)+[.](\d)+[.](\d)+$/
    str
  elsif str.match /^((\d)+[.])*(\d)+$/
    fix_version(str)
  else
    raise VersionError, "need a valid version number of the form 0.0.0"
  end
end