assertions/version.rb in yes_ship_it-0.0.5 vs assertions/version.rb in yes_ship_it-0.0.6
- old
+ new
@@ -1,29 +1,27 @@
module YSI
class Version < Assertion
parameter :version_file, "lib/version.rb"
- def display_name
+ def self.display_name
"version number"
end
def check
if !File.exist?(version_file)
- @error = "Expected version in #{version_file}"
- return nil
+ raise AssertionError.new("Expected version in #{version_file}")
end
version = parse_version(version_file)
if version
@engine.version = version
return @engine.version
end
- @error = "Couldn't find version in #{version_file}"
- nil
+ raise AssertionError.new("Couldn't find version in #{version_file}")
end
- def assert(dry_run: false)
+ def assert(_executor)
end
def parse_version(file_name)
if file_name =~ /\.rb$/
File.read(file_name).each_line do |line|
@@ -32,9 +30,15 @@
end
end
elsif file_name =~ /\.go$/
File.read(file_name).each_line do |line|
if line =~ /Version = "(.*)"/
+ return $1
+ end
+ end
+ elsif file_name =~ /\.h$/
+ File.read(file_name).each_line do |line|
+ if line =~ /#define .*_VERSION "(.*)"/
return $1
end
end
end
nil