File: inspect.rb

package info (click to toggle)
ruby-mocha 0.11.3-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,300 kB
  • sloc: ruby: 9,935; makefile: 2
file content (67 lines) | stat: -rw-r--r-- 1,055 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
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
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
require 'date'

module Mocha

  module ObjectMethods
    def mocha_inspect
      address = self.__id__ * 2
      address += 0x100000000 if address < 0
      inspect =~ /#</ ? "#<#{self.class}:0x#{'%x' % address}>" : inspect
    end
  end

  module StringMethods
    def mocha_inspect
      inspect.gsub(/\"/, "'")
    end
  end

  module ArrayMethods
    def mocha_inspect
      "[#{collect { |member| member.mocha_inspect }.join(', ')}]"
    end
  end

  module HashMethods
    def mocha_inspect
      "{#{collect { |key, value| "#{key.mocha_inspect} => #{value.mocha_inspect}" }.join(', ')}}"
    end
  end

  module TimeMethods
    def mocha_inspect
      "#{inspect} (#{to_f} secs)"
    end
  end

  module DateMethods
    def mocha_inspect
      to_s
    end
  end

end

class Object
  include Mocha::ObjectMethods
end

class String
  include Mocha::StringMethods
end

class Array
  include Mocha::ArrayMethods
end

class Hash
  include Mocha::HashMethods
end

class Time
  include Mocha::TimeMethods
end

class Date
  include Mocha::DateMethods
end