diff options
| author | Martin Afanasjew | 2016-04-06 06:22:22 +0200 |
|---|---|---|
| committer | Martin Afanasjew | 2016-04-06 06:22:22 +0200 |
| commit | a2c23dfec569c6e73d90cb20c7d4c26cced258d5 (patch) | |
| tree | be1f0ed45b02d46f37bf601f67acaf8fed33777d /Library/Homebrew/cmd | |
| parent | a9c0361a1d83374059fca73485643e89c2772331 (diff) | |
| download | brew-a2c23dfec569c6e73d90cb20c7d4c26cced258d5.tar.bz2 | |
test-bot: fix undefined method error
The method `fix_encoding!` is private to `Homebrew::Step` but is also
required by the `Homebrew.sanitize_output_for_xml` method for truncating
overly long logs. Move `fix_encoding!` into the `Homebrew` module to
make it accessible from both this method and the `Homebrew::Step` class.
This amends commit 343091c828d1e572829b86253d79b326c1986bcd.
Diffstat (limited to 'Library/Homebrew/cmd')
| -rw-r--r-- | Library/Homebrew/cmd/test-bot.rb | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/Library/Homebrew/cmd/test-bot.rb b/Library/Homebrew/cmd/test-bot.rb index 067e7da97..8f2635282 100644 --- a/Library/Homebrew/cmd/test-bot.rb +++ b/Library/Homebrew/cmd/test-bot.rb @@ -43,6 +43,24 @@ module Homebrew String.method_defined?(:force_encoding) end + if ruby_has_encoding? + def fix_encoding!(str) + # Assume we are starting from a "mostly" UTF-8 string + str.force_encoding(Encoding::UTF_8) + return str if str.valid_encoding? + str.encode!(Encoding::UTF_16, :invalid => :replace) + str.encode!(Encoding::UTF_8) + end + elsif require "iconv" + def fix_encoding!(str) + Iconv.conv("UTF-8//IGNORE", "UTF-8", str) + end + else + def fix_encoding!(str) + str + end + end + def resolve_test_tap if tap = ARGV.value("tap") return Tap.fetch(tap) @@ -188,26 +206,6 @@ module Homebrew exit 1 if ARGV.include?("--fail-fast") && failed? end - - private - - if Homebrew.ruby_has_encoding? - def fix_encoding!(str) - # Assume we are starting from a "mostly" UTF-8 string - str.force_encoding(Encoding::UTF_8) - return str if str.valid_encoding? - str.encode!(Encoding::UTF_16, :invalid => :replace) - str.encode!(Encoding::UTF_8) - end - elsif require "iconv" - def fix_encoding!(str) - Iconv.conv("UTF-8//IGNORE", "UTF-8", str) - end - else - def fix_encoding!(str) - str - end - end end class Test |
