Sha256: e301bb2d057d302c7d4123145a97df9528374ed5343a8a96f982cd9389da0ff2

Contents?: true

Size: 506 Bytes

Versions: 6

Compression:

Stored size: 506 Bytes

Contents

# frozen_string_literal: true

module Travis
  module Tools
    module SafeString
      module_function

      def encoded(string)
        return string unless string.respond_to? :encode

        string.encode 'utf-8'
      rescue Encoding::UndefinedConversionError
        string.force_encoding 'utf-8'
      end

      def colorized(string)
        encoded(string).gsub(/[^[:print:]\e\n]/, '')
      end

      def clean(string)
        colorized(string).gsub(/\e[^m]+m/, '')
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
travis-1.14.0 lib/travis/tools/safe_string.rb
travis-1.13.3 lib/travis/tools/safe_string.rb
travis-1.13.2 lib/travis/tools/safe_string.rb
travis-1.13.1 lib/travis/tools/safe_string.rb
travis-1.13.0 lib/travis/tools/safe_string.rb
travis-1.12.0 lib/travis/tools/safe_string.rb