Sha256: 834836a9e28709737a9c53e72b3f23c8695fc0a23e0f658ddc51632413ca8edc

Contents?: true

Size: 922 Bytes

Versions: 3

Compression:

Stored size: 922 Bytes

Contents

# frozen_string_literal: true

require 'cucumber/platform'
require 'cucumber/gherkin/formatter/ansi_escapes'

module Cucumber
  module Deprecate
    module ForUsers
      AnsiEscapes = Cucumber::Gherkin::Formatter::AnsiEscapes

      def self.call(message, method, remove_after_version)
        STDERR.puts AnsiEscapes.failed + "\nWARNING: ##{method} is deprecated" \
        " and will be removed after version #{remove_after_version}. #{message}.\n" \
        "(Called from #{caller(3..3).first})" + AnsiEscapes.reset
      end
    end

    module ForDevelopers
      def self.call(_message, _method, remove_after_version)
        raise "This method is due for removal after version #{remove_after_version}" if Cucumber::VERSION > remove_after_version
      end
    end

    STRATEGY = $PROGRAM_NAME =~ /rspec$/ ? ForDevelopers : ForUsers
  end

  def self.deprecate(*args)
    Deprecate::STRATEGY.call(*args)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cucumber-4.0.0.rc.3 lib/cucumber/deprecate.rb
cucumber-4.0.0.rc.2 lib/cucumber/deprecate.rb
cucumber-4.0.0.rc.1 lib/cucumber/deprecate.rb