~ubuntu-branches/ubuntu/karmic/libcairo-ruby/karmic

« back to all changes in this revision

Viewing changes to test-unit/lib/test/unit/util/procwrapper.rb

  • Committer: Bazaar Package Importer
  • Author(s): Paul van Tilburg, Gunnar Wolf, Paul van Tilburg
  • Date: 2009-05-05 12:14:31 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090505121431-n803uyjz51je38l0
Tags: 1.8.0-1
[ Gunnar Wolf ]
* Changed section to Ruby as per ftp-masters' request

[ Paul van Tilburg ]
* New upstream release.
* debian/patches:
  - Dropped patch 01_fix-st.h-ruby1.9-paths: fixed by upstream. 
* debian/control:
  - Bumped standards version to 3.8.1; no changes required.
  - Added ${misc:Depends} to the depends of libcairo-ruby (binary).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#--
 
2
#
 
3
# Author:: Nathaniel Talbott.
 
4
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
 
5
# License:: Ruby license.
 
6
 
 
7
module Test
 
8
  module Unit
 
9
    module Util
 
10
 
 
11
      # Allows the storage of a Proc passed through '&' in a
 
12
      # hash.
 
13
      #
 
14
      # Note: this may be inefficient, since the hash being
 
15
      # used is not necessarily very good. In Observable,
 
16
      # efficiency is not too important, since the hash is
 
17
      # only accessed when adding and removing listeners,
 
18
      # not when notifying.
 
19
 
 
20
      class ProcWrapper
 
21
 
 
22
        # Creates a new wrapper for a_proc.
 
23
        def initialize(a_proc)
 
24
          @a_proc = a_proc
 
25
          @hash = a_proc.inspect.sub(/^(#<#{a_proc.class}:)/){''}.sub(/(>)$/){''}.hex
 
26
        end
 
27
 
 
28
        def hash
 
29
          return @hash
 
30
        end
 
31
 
 
32
        def ==(other)
 
33
          case(other)
 
34
            when ProcWrapper
 
35
              return @a_proc == other.to_proc
 
36
            else
 
37
              return super
 
38
          end
 
39
        end
 
40
        alias :eql? :==
 
41
 
 
42
        def to_proc
 
43
          return @a_proc
 
44
        end
 
45
      end
 
46
    end
 
47
  end
 
48
end