Sha256: 3603433857626bbace0e0b0b2f6cb3e821346914bbd80cc539dda0c73b4cf091

Contents?: true

Size: 803 Bytes

Versions: 6

Compression:

Stored size: 803 Bytes

Contents

module Gitrb
  module Util
    if RUBY_VERSION > '1.9'
      def self.read_bytes_until(io, char)
        str = ''
        while ((ch = io.getc) != char) && !io.eof
          str << ch
        end
        str
      end
    else
      def self.read_bytes_until(io, char)
        str = ''
        while ((ch = io.getc.chr) != char) && !io.eof
          str << ch
        end
        str
      end
    end

    class Synchronized
      def initialize(obj)
        @obj = obj
        @mutex = Mutex.new
      end

      def method_missing(*args)
        @mutex.synchronize { @obj.send(*args) }
      end
    end
  end
end

# str[0] returns a 1-char string in Ruby 1.9 but a
# Fixnum in 1.8.  Monkeypatch a fix if we're on 1.8.
if !1.respond_to?(:ord)
  class Fixnum
    def ord
      self
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gitrb-0.2.1 lib/gitrb/util.rb
gitrb-0.2.0 lib/gitrb/util.rb
gitrb-0.1.9 lib/gitrb/util.rb
gitrb-0.1.8 lib/gitrb/util.rb
gitrb-0.1.7 lib/gitrb/util.rb
gitrb-0.1.6 lib/gitrb/util.rb