def version(val = NULL, &block)
      final_version = apply_overrides(:version)

      if block_given?
        if val.equal?(NULL)
          raise InvalidValue.new(:version,
            "pass a block when given a version argument")
        else
          if val == final_version
            #
            # Unfortunately we need to make a specific logic here for license files.
            # We support multiple calls `license_file` and we support overriding the
            # license files inside a version block. We can not differentiate whether
            # `license_file` is being called from a version block or not. So we need
            # to check if the license files are being overridden during the call to
            # block.
            #
            # If so we use the new set, otherwise we restore the old license files.
            #
            current_license_files = @license_files
            @license_files = []

            yield

            new_license_files = @license_files

            if new_license_files.empty?
              @license_files = current_license_files
            end
          end
        end
      end

      return if final_version.nil?

      begin
        Chef::Sugar::Constraints::Version.new(final_version)
      rescue ArgumentError
        log.warn(log_key) do
          "Version #{final_version} for software #{name} was not parseable. " \
          "Comparison methods such as #satisfies? will not be available for this version."
        end
        final_version
      end
    end
def version(val = NULL, &block)
      final_version = apply_overrides(:version)

      if block_given?
        if val.equal?(NULL)
          raise InvalidValue.new(:version,
            "pass a block when given a version argument")
        else
          if val == final_version
            #
            # Unfortunately we need to make a specific logic here for license files.
            # We support multiple calls `license_file` and we support overriding the
            # license files inside a version block. We can not differentiate whether
            # `license_file` is being called from a version block or not. So we need
            # to check if the license files are being overridden during the call to
            # block.
            #
            # If so we use the new set, otherwise we restore the old license files.
            #
            current_license_files = @license_files
            @license_files = []

            yield

            new_license_files = @license_files

            if new_license_files.empty?
              @license_files = current_license_files
            end
          end
        end
      end

      return if final_version.nil?

      begin
        Chef::Sugar::Constraints::Version.new(final_version)
      rescue ArgumentError
        log.warn(log_key) do
          "Version #{final_version} for software #{name} was not parseable. " \
          "Comparison methods such as #satisfies? will not be available for this version."
        end
        final_version
      end
    end
Evaluate a block only if the version matches.

 @example
   version '1.2.3' do
     source path: '/local/path/to/software-1.2.3'
   end

 @param [String] val
   the version of the software
 @param [Proc] block
   the block to run if the version we are building matches the argument

 @return [String, Proc]