Vendor the external cookbooks
Knife-Zero doesn't include Berkshelf support, so vendoring everything in the repo is convenient again
This commit is contained in:
37
cookbooks/nginx/libraries/nginx_version.rb
Normal file
37
cookbooks/nginx/libraries/nginx_version.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
class NginxVersion
|
||||
include Comparable
|
||||
|
||||
attr_reader :version
|
||||
|
||||
def initialize(version)
|
||||
@version = version
|
||||
end
|
||||
|
||||
def <=>(other)
|
||||
lhsegments = segments
|
||||
rhsegments = other.segments
|
||||
|
||||
parts = [lhsegments.size, rhsegments.size].max
|
||||
|
||||
(0..(parts - 1)).each do |index|
|
||||
lhs = lhsegments[index] || 0
|
||||
rhs = rhsegments[index] || 0
|
||||
|
||||
next if lhs == rhs
|
||||
|
||||
return lhs <=> rhs
|
||||
end
|
||||
|
||||
0
|
||||
end
|
||||
|
||||
def to_s
|
||||
version
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def segments
|
||||
version.split('.').map { |part| Integer(part) }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user