Module: Cucumber::WindowsOutput

Extended by:
WindowsOutput
Included in:
WindowsOutput
Defined in:
lib/cucumber/formatter/unicode.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.extended(o) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cucumber/formatter/unicode.rb', line 26

def self.extended(o)
  o.instance_eval do
    alias cucumber_print print
    def print(*a)
      if Cucumber::RUBY_1_9
        begin
          cucumber_print(*a.map{|arg| arg.to_s.encode(Encoding.default_external)})
        rescue Encoding::UndefinedConversionError => e
          STDERR.cucumber_puts("WARNING: #{e.message}")
          cucumber_print(*a)
        end
      else
        begin
          cucumber_print(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a.map{|a|a.to_s}))
        rescue Iconv::InvalidEncoding => e
          STDERR.cucumber_puts("WARNING: #{e.message}")
          cucumber_print(*a)
        rescue Iconv::IllegalSequence => e
          STDERR.cucumber_puts("WARNING: #{e.message}")
          cucumber_print(*a)
        end
      end
    end

    alias cucumber_puts puts
    def puts(*a)
      if Cucumber::RUBY_1_9
        begin
          cucumber_puts(*a.map{|arg| arg.to_s.encode(Encoding.default_external)})
        rescue Encoding::UndefinedConversionError => e
          STDERR.cucumber_puts("WARNING: #{e.message}")
          cucumber_puts(*a)
        end
      else
        begin
          cucumber_puts(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a.map{|a|a.to_s}))
        rescue Iconv::InvalidEncoding => e
          STDERR.cucumber_print("WARNING: #{e.message}")
          cucumber_print(*a)
        rescue Iconv::IllegalSequence => e
          STDERR.cucumber_puts("WARNING: #{e.message}")
          cucumber_puts(*a)
        end
      end
    end
  end
end