Sha256: 9af93601b3e5eca0d0ca6cbea858f5d4b8e716aea1c5a53342aacfa4173e3576

Contents?: true

Size: 935 Bytes

Versions: 3

Compression:

Stored size: 935 Bytes

Contents

module YSI
  class Version < Assertion
    parameter :version_file, "lib/version.rb"

    def display_name
      "version number"
    end

    def check
      if !File.exist?(version_file)
        @error = "Expected version in #{version_file}"
        return nil
      end

      version = parse_version(version_file)
      if version
        @engine.version = version
        return @engine.version
      end
      @error = "Couldn't find version in #{version_file}"
      nil
    end

    def assert(dry_run: false)
    end

    def parse_version(file_name)
      if file_name =~ /\.rb$/
        File.read(file_name).each_line do |line|
          if line =~ /VERSION = "(.*)"/
            return $1
          end
        end
      elsif file_name =~ /\.go$/
        File.read(file_name).each_line do |line|
          if line =~ /Version = "(.*)"/
            return $1
          end
        end
      end
      nil
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yes_ship_it-0.0.5 assertions/version.rb
yes_ship_it-0.0.4 assertions/version.rb
yes_ship_it-0.0.3 assertions/version.rb