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



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cucumber/formatter/unicode.rb', line 12

def self.extended(o)
  o.instance_eval do
    alias cucumber_print print
    def print(*a)
      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

    alias cucumber_puts puts
    def puts(*a)
      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