In the following function, the regex doesn't work if the version is between ' ' instead of " ". This will result in no version at all :(
def get_cookbook_version()
version = nil
cpath = get_cookbook_path(@cookbook_name)
File.foreach("#{cpath}/metadata.rb") do |line|
if line =~ /version.*"(.*)"/i
# problem with -> version '0.1.21'
version = $1
break
end
end
if version.nil?
Chef::Log.error("Cannot get the version for cookbook #{@cookbook_name}")
exit 1
end
version
end
In the following function, the regex doesn't work if the version is between ' ' instead of " ". This will result in no version at all :(