summaryrefslogtreecommitdiff
path: root/lib/chef/version
diff options
context:
space:
mode:
authorXabier de Zuazo <xabier@onddo.com>2013-03-13 12:03:35 +0100
committerBryan McLellan <btm@opscode.com>2013-04-11 13:04:33 -0700
commit7052e7712a6b159626c2077f86e8be551e79bbd4 (patch)
treeef0cb7faba3afcce049d2f8a34076344811625c6 /lib/chef/version
parentf554a1c0fbc1f308462d3d62544a0fd7ed7df6ec (diff)
downloadchef-7052e7712a6b159626c2077f86e8be551e79bbd4.tar.gz
[CHEF-3919] Removed Chef::Version::Cookbook code and replaced by a Chef::Version::Platform class, reverting Chef::Version class changes
Diffstat (limited to 'lib/chef/version')
-rw-r--r--lib/chef/version/platform.rb (renamed from lib/chef/version/cookbook.rb)25
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/chef/version/cookbook.rb b/lib/chef/version/platform.rb
index 391d46563c..2921341cd2 100644
--- a/lib/chef/version/cookbook.rb
+++ b/lib/chef/version/platform.rb
@@ -18,20 +18,23 @@ require 'chef/version_class'
class Chef
class Version
- class Cookbook < Chef::Version
+ class Platform < Chef::Version
protected
- def parse(str='')
- msg = "'#{str.to_s}' does not match 'x.y.z' or 'x.y'"
- begin
- super
- rescue Chef::Exceptions::InvalidVersion => e
- raise Chef::Exceptions::InvalidCookbookVersion.new( msg )
- end
- if str.to_s =~ /^(\d+)$/
- raise Chef::Exceptions::InvalidCookbookVersion.new( msg )
- end
+ def parse(str="")
+ @major, @minor, @patch =
+ case str.to_s
+ when /^(\d+)\.(\d+)\.(\d+)$/
+ [ $1.to_i, $2.to_i, $3.to_i ]
+ when /^(\d+)\.(\d+)$/
+ [ $1.to_i, $2.to_i, 0 ]
+ when /^(\d+)$/
+ [ $1.to_i, 0, 0 ]
+ else
+ msg = "'#{str.to_s}' does not match 'x.y.z', 'x.y' or 'x'"
+ raise Chef::Exceptions::InvalidPlatformVersion.new( msg )
+ end
end
end