Sha256: 5a26f0fec717bdcb5ad708ca86e78240e479c77a174eff6602606a9b521fc867

Contents?: true

Size: 1.55 KB

Versions: 21

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

# Require this file if you need Unicode support.
# Tips for improvement - esp. ruby 1.9: http://www.ruby-forum.com/topic/184730
require 'cucumber/platform'
require 'cucumber/formatter/ansicolor'

if Cucumber::WINDOWS
  if ENV['CUCUMBER_OUTPUT_ENCODING']
    Cucumber::CODEPAGE = ENV['CUCUMBER_OUTPUT_ENCODING']
  elsif `cmd /c chcp` =~ /(\d+)/
    if [65_000, 65_001].include? Regexp.last_match(1).to_i
      Cucumber::CODEPAGE = 'UTF-8'.freeze
      ENV['ANSICON_API'] = 'ruby'
    else
      Cucumber::CODEPAGE = "cp#{Regexp.last_match(1).to_i}".freeze
    end
  else
    Cucumber::CODEPAGE = 'cp1252'.freeze
    STDERR.puts("WARNING: Couldn't detect your output codepage. Assuming it is 1252. You may have to chcp 1252 or SET CUCUMBER_OUTPUT_ENCODING=cp1252.")
  end

  module Cucumber
    # @private
    module WindowsOutput
      def self.extended(output)
        output.instance_eval do
          def cucumber_preprocess_output(*out)
            out.map { |arg| arg.to_s.encode(Encoding.default_external) }
          rescue Encoding::UndefinedConversionError => e
            STDERR.cucumber_puts("WARNING: #{e.message}")
            out
          end

          alias cucumber_print print
          def print(*out)
            cucumber_print(*cucumber_preprocess_output(*out))
          end

          alias cucumber_puts puts
          def puts(*out)
            cucumber_puts(*cucumber_preprocess_output(*out))
          end
        end
      end

      Kernel.extend(self)
      STDOUT.extend(self)
      STDERR.extend(self)
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/cucumber-7.1.0/lib/cucumber/formatter/unicode.rb
cucumber-7.1.0 lib/cucumber/formatter/unicode.rb
cucumber-7.0.0 lib/cucumber/formatter/unicode.rb
cucumber-6.1.0 lib/cucumber/formatter/unicode.rb
cucumber-6.0.0 lib/cucumber/formatter/unicode.rb
cucumber-5.3.0 lib/cucumber/formatter/unicode.rb
cucumber-5.2.0 lib/cucumber/formatter/unicode.rb
cucumber-5.1.3 lib/cucumber/formatter/unicode.rb
cucumber-5.1.2 lib/cucumber/formatter/unicode.rb
cucumber-5.1.1 lib/cucumber/formatter/unicode.rb
cucumber-5.1.0 lib/cucumber/formatter/unicode.rb
cucumber-5.0.0 lib/cucumber/formatter/unicode.rb
cucumber-4.1.0 lib/cucumber/formatter/unicode.rb
cucumber-4.0.1 lib/cucumber/formatter/unicode.rb
cucumber-4.0.0 lib/cucumber/formatter/unicode.rb
cucumber-4.0.0.rc.6 lib/cucumber/formatter/unicode.rb
cucumber-4.0.0.rc.5 lib/cucumber/formatter/unicode.rb
cucumber-4.0.0.rc.4 lib/cucumber/formatter/unicode.rb
cucumber-4.0.0.rc.3 lib/cucumber/formatter/unicode.rb
cucumber-4.0.0.rc.2 lib/cucumber/formatter/unicode.rb