lib/chef/sugar/platform.rb in chef-sugar-1.2.6 vs lib/chef/sugar/platform.rb in chef-sugar-1.3.0
- old
+ new
@@ -19,15 +19,16 @@
module Platform
extend self
PLATFORM_VERSIONS = {
'debian' => {
- 'squeeze' => '6.0',
- 'wheezy' => '7.0',
- 'jessie' => '8.0',
+ 'squeeze' => '6',
+ 'wheezy' => '7',
+ 'jessie' => '8',
},
'linuxmint' => {
+ 'petra' => '16',
'olivia' => '15',
'nadia' => '14',
'maya' => '13',
'lisa' => '12',
},
@@ -43,10 +44,11 @@
'oneiric' => '11.10',
'precise' => '12.04',
'quantal' => '12.10',
'raring' => '13.04',
'saucy' => '13.10',
+ 'trusty' => '14.04',
},
}
COMPARISON_OPERATORS = {
'after' => ->(a, b) { a > b },
@@ -62,12 +64,17 @@
PLATFORM_VERSIONS.each do |platform, versions|
versions.each do |name, version|
COMPARISON_OPERATORS.each do |operator, block|
method_name = "#{platform}_#{operator}_#{name}?".squeeze('_').to_sym
define_method(method_name) do |node|
+ # Find the highest precedence that we actually care about based
+ # off of what was given to us in the list.
+ length = version.split('.').size
+ check = node['platform_version'].split('.')[0...length].join('.')
+
# Calling #to_f will ensure we only check major versions since
# '10.04.4'.to_f #=> 10.04.
- node['platform'] == platform && block.call(node['platform_version'].to_f, version.to_f)
+ node['platform'] == platform && block.call(check.to_f, version.to_f)
end
end
end
end