safer 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +14 -0
 - data/Manifest.txt +1 -1
 - data/{README.txt → README.rdoc} +0 -0
 - data/Rakefile +2 -1
 - data/lib/safer/hashprotocol.rb +263 -265
 - data/lib/safer/ivar.rb +4 -219
 - data/lib/safer/protocol.rb +454 -457
 - data/lib/safer.rb +1 -1
 - data/test/test_safer_hashprotocol.rb +27 -27
 - data/test/test_safer_ivar.rb +25 -41
 - data/test/test_safer_ivar_run.rb +77 -0
 - data/test/test_safer_ivarfactory.rb +36 -0
 - data/test/test_safer_protocol.rb +8 -3
 - metadata +11 -8
 
    
        data/lib/safer.rb
    CHANGED
    
    
| 
         @@ -8,40 +8,40 @@ class TC_SaferHashProtocol < Test::Unit::TestCase 
     | 
|
| 
       8 
8 
     | 
    
         
             
                @all_hash = { :foo => nil, :bar => nil, :baz => nil }
         
     | 
| 
       9 
9 
     | 
    
         
             
                @fail_hash = { :blubby => nil }
         
     | 
| 
       10 
10 
     | 
    
         
             
                @has_key = SHP::HasKey.create(*@all_hash.keys)
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                @any = SHP::Any.new(*@has_key)
         
     | 
| 
      
 13 
     | 
    
         
            +
                @not_any = SHP::Not.new(@any)
         
     | 
| 
      
 14 
     | 
    
         
            +
                @all = SHP::All.new(*@has_key)
         
     | 
| 
      
 15 
     | 
    
         
            +
                @not_all = SHP::Not.new(@all)
         
     | 
| 
      
 16 
     | 
    
         
            +
                @only = SHP::Only.new(@any)
         
     | 
| 
      
 17 
     | 
    
         
            +
                @all_plus = @all_hash.merge(@fail_hash)
         
     | 
| 
       11 
18 
     | 
    
         
             
              end
         
     | 
| 
       12 
19 
     | 
    
         
             
              def teardown
         
     | 
| 
       13 
20 
     | 
    
         
             
              end
         
     | 
| 
       14 
21 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
              def  
     | 
| 
       16 
     | 
    
         
            -
                any  
     | 
| 
       17 
     | 
    
         
            -
                not_any  
     | 
| 
       18 
     | 
    
         
            -
                assert(any === @ 
     | 
| 
       19 
     | 
    
         
            -
                assert(! (not_any === @ 
     | 
| 
       20 
     | 
    
         
            -
                assert(any === @ 
     | 
| 
       21 
     | 
    
         
            -
                assert( 
     | 
| 
       22 
     | 
    
         
            -
                assert(! (any === @fail_hash))
         
     | 
| 
       23 
     | 
    
         
            -
                assert(not_any === @fail_hash)
         
     | 
| 
      
 22 
     | 
    
         
            +
              def test_anyFromAllKeysShouldMatchAllButFailHash
         
     | 
| 
      
 23 
     | 
    
         
            +
                assert(@any === @any_hash)
         
     | 
| 
      
 24 
     | 
    
         
            +
                assert(! (@not_any === @any_hash))
         
     | 
| 
      
 25 
     | 
    
         
            +
                assert(@any === @all_hash)
         
     | 
| 
      
 26 
     | 
    
         
            +
                assert(! (@not_any === @all_hash))
         
     | 
| 
      
 27 
     | 
    
         
            +
                assert(! (@any === @fail_hash))
         
     | 
| 
      
 28 
     | 
    
         
            +
                assert(@not_any === @fail_hash)
         
     | 
| 
       24 
29 
     | 
    
         
             
              end
         
     | 
| 
       25 
30 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
              def  
     | 
| 
       27 
     | 
    
         
            -
                all  
     | 
| 
       28 
     | 
    
         
            -
                not_all  
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                assert(! ( 
     | 
| 
       31 
     | 
    
         
            -
                assert( 
     | 
| 
       32 
     | 
    
         
            -
                assert( 
     | 
| 
       33 
     | 
    
         
            -
                assert(! (not_all === @all_hash))
         
     | 
| 
       34 
     | 
    
         
            -
                assert(! (all === @fail_hash))
         
     | 
| 
       35 
     | 
    
         
            -
                assert(not_all === @fail_hash)
         
     | 
| 
      
 31 
     | 
    
         
            +
              def test_allFromAllKeysShouldMatchOnlyAllHash
         
     | 
| 
      
 32 
     | 
    
         
            +
                assert(! (@all === @any_hash))
         
     | 
| 
      
 33 
     | 
    
         
            +
                assert(@not_all === @any_hash)
         
     | 
| 
      
 34 
     | 
    
         
            +
                assert(@all === @all_hash)
         
     | 
| 
      
 35 
     | 
    
         
            +
                assert(! (@not_all === @all_hash))
         
     | 
| 
      
 36 
     | 
    
         
            +
                assert(! (@all === @fail_hash))
         
     | 
| 
      
 37 
     | 
    
         
            +
                assert(@not_all === @fail_hash)
         
     | 
| 
       36 
38 
     | 
    
         
             
              end
         
     | 
| 
       37 
39 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
              def  
     | 
| 
       39 
     | 
    
         
            -
                 
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                assert(only === @ 
     | 
| 
       43 
     | 
    
         
            -
                assert(any === @ 
     | 
| 
       44 
     | 
    
         
            -
                assert(! (only === all_plus))
         
     | 
| 
       45 
     | 
    
         
            -
                assert(any === all_plus)
         
     | 
| 
      
 40 
     | 
    
         
            +
              def test_onlyAnyFromAllKeysShouldMatchAll
         
     | 
| 
      
 41 
     | 
    
         
            +
                assert(@only === @all_hash)
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
              def test_onlyAnyFromAllKeysShouldFailWithExtraKey
         
     | 
| 
      
 44 
     | 
    
         
            +
                assert(! (@only === @all_plus))
         
     | 
| 
      
 45 
     | 
    
         
            +
                assert(@any === @all_plus)
         
     | 
| 
       46 
46 
     | 
    
         
             
              end
         
     | 
| 
       47 
47 
     | 
    
         
             
            end
         
     | 
    
        data/test/test_safer_ivar.rb
    CHANGED
    
    | 
         @@ -1,58 +1,42 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'safer/ivar'
         
     | 
| 
       2 
2 
     | 
    
         
             
            require 'test/unit'
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
               
     | 
| 
       6 
     | 
    
         
            -
                class  
     | 
| 
       7 
     | 
    
         
            -
                   
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                   
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                   
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                   
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
            class TC_SaferIVar < Test::Unit::TestCase
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Root
         
     | 
| 
      
 6 
     | 
    
         
            +
                class Test
         
     | 
| 
      
 7 
     | 
    
         
            +
                  class Instance
         
     | 
| 
      
 8 
     | 
    
         
            +
                    Safer::IVar.instance_variable(self, :instance)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
                  class Reader
         
     | 
| 
      
 11 
     | 
    
         
            +
                    Safer::IVar.instance_variable(self, :instance)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    Safer::IVar.export_reader(self, :instance)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
                  class Writer
         
     | 
| 
      
 15 
     | 
    
         
            +
                    Safer::IVar.instance_variable(self, :instance)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    Safer::IVar.export_writer(self, :instance)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  class Accessor
         
     | 
| 
      
 19 
     | 
    
         
            +
                    Safer::IVar.instance_variable(self, :instance)
         
     | 
| 
      
 20 
     | 
    
         
            +
                    Safer::IVar.export_accessor(self, :instance)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
       20 
22 
     | 
    
         
             
                end
         
     | 
| 
       21 
23 
     | 
    
         
             
              end
         
     | 
| 
       22 
     | 
    
         
            -
            end
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
            class TC_SaferIVar < Test::Unit::TestCase
         
     | 
| 
       25 
25 
     | 
    
         
             
              def setup
         
     | 
| 
       26 
26 
     | 
    
         
             
              end
         
     | 
| 
       27 
27 
     | 
    
         
             
              def teardown
         
     | 
| 
       28 
28 
     | 
    
         
             
              end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
              def assert_no_respond_to(object, method, message="")
         
     | 
| 
       31 
     | 
    
         
            -
                 
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
                      nil,
         
     | 
| 
       35 
     | 
    
         
            -
                      "<?>\ngiven as the method name argument to #assert_no_respond_to " +
         
     | 
| 
       36 
     | 
    
         
            -
                        "must be a Symbol or #respond_to\\?(:to_str).",
         
     | 
| 
       37 
     | 
    
         
            -
                      method
         
     | 
| 
       38 
     | 
    
         
            -
                    )
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                  assert_block(full_message) do
         
     | 
| 
       41 
     | 
    
         
            -
                    method.kind_of?(Symbol) || method.respond_to?(:to_str)
         
     | 
| 
       42 
     | 
    
         
            -
                  end
         
     | 
| 
       43 
     | 
    
         
            -
                  full_message = 
         
     | 
| 
       44 
     | 
    
         
            -
                    build_message(
         
     | 
| 
       45 
     | 
    
         
            -
                      message, "<?>\nof type <?>\nnot expected to respond_to\\\\?<?>.\n",
         
     | 
| 
       46 
     | 
    
         
            -
                      object, object.class, method
         
     | 
| 
       47 
     | 
    
         
            -
                    )
         
     | 
| 
       48 
     | 
    
         
            -
                  assert_block(full_message) { not object.respond_to?(method) }
         
     | 
| 
       49 
     | 
    
         
            -
                end
         
     | 
| 
      
 31 
     | 
    
         
            +
                assert method.kind_of?(Symbol)
         
     | 
| 
      
 32 
     | 
    
         
            +
                msg = "#{object} of type #{object.class} not expected to respond_to? #{method}\n#{message}"
         
     | 
| 
      
 33 
     | 
    
         
            +
                assert((not object.respond_to?(method)), msg)
         
     | 
| 
       50 
34 
     | 
    
         
             
              end
         
     | 
| 
       51 
35 
     | 
    
         | 
| 
       52 
36 
     | 
    
         
             
              def test_class_symbol_prefix
         
     | 
| 
       53 
     | 
    
         
            -
                assert_equal(" 
     | 
| 
       54 
     | 
    
         
            -
                assert_equal(" 
     | 
| 
       55 
     | 
    
         
            -
                assert_equal(" 
     | 
| 
      
 37 
     | 
    
         
            +
                assert_equal("tc_saferivar_root", Safer::IVar.class_symbol_prefix(Root))
         
     | 
| 
      
 38 
     | 
    
         
            +
                assert_equal("tc_saferivar_root_test", Safer::IVar.class_symbol_prefix(Root::Test))
         
     | 
| 
      
 39 
     | 
    
         
            +
                assert_equal("tc_saferivar_root_test_instance", Safer::IVar.class_symbol_prefix(Root::Test::Instance))
         
     | 
| 
       56 
40 
     | 
    
         
             
                k = Root.class_eval("$k = Class.new(Root::Test::Instance)")
         
     | 
| 
       57 
41 
     | 
    
         
             
                assert_same(nil, Safer::IVar.class_symbol_prefix(k))
         
     | 
| 
       58 
42 
     | 
    
         
             
                b = k.class_eval("class Blah ; end ; Blah")
         
     | 
| 
         @@ -73,7 +57,7 @@ class TC_SaferIVar < Test::Unit::TestCase 
     | 
|
| 
       73 
57 
     | 
    
         
             
                  end
         
     | 
| 
       74 
58 
     | 
    
         
             
                end
         
     | 
| 
       75 
59 
     | 
    
         
             
                ti = Root::Test::Instance.new
         
     | 
| 
       76 
     | 
    
         
            -
                assert_respond_to(ti, : 
     | 
| 
      
 60 
     | 
    
         
            +
                assert_respond_to(ti, :tc_saferivar_root_test_instance__instance)
         
     | 
| 
       77 
61 
     | 
    
         
             
                test_accessors.call(ti, false, false)
         
     | 
| 
       78 
62 
     | 
    
         
             
                tr = Root::Test::Reader.new
         
     | 
| 
       79 
63 
     | 
    
         
             
                test_accessors.call(tr, true, false)
         
     | 
| 
         @@ -0,0 +1,77 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'safer/ivar'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'test/unit'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class TC_SaferIVarRun < Test::Unit::TestCase
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Root
         
     | 
| 
      
 6 
     | 
    
         
            +
                class Test
         
     | 
| 
      
 7 
     | 
    
         
            +
                  class Instance
         
     | 
| 
      
 8 
     | 
    
         
            +
                    Safer::IVar.run(self) do |iv|
         
     | 
| 
      
 9 
     | 
    
         
            +
                      iv.ivar(:instance)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    end
         
     | 
| 
      
 11 
     | 
    
         
            +
                  end
         
     | 
| 
      
 12 
     | 
    
         
            +
                  class Reader
         
     | 
| 
      
 13 
     | 
    
         
            +
                    Safer::IVar.run(self) do |iv|
         
     | 
| 
      
 14 
     | 
    
         
            +
                      iv.ivar(:instance)
         
     | 
| 
      
 15 
     | 
    
         
            +
                      iv.reader(:instance)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    end
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  class Writer
         
     | 
| 
      
 19 
     | 
    
         
            +
                    Safer::IVar.run(self) do |iv|
         
     | 
| 
      
 20 
     | 
    
         
            +
                      iv.ivar(:instance)
         
     | 
| 
      
 21 
     | 
    
         
            +
                      iv.writer(:instance)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    end
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
                  class Accessor
         
     | 
| 
      
 25 
     | 
    
         
            +
                    Safer::IVar.run(self) do |iv|
         
     | 
| 
      
 26 
     | 
    
         
            +
                      iv.ivar(:instance)
         
     | 
| 
      
 27 
     | 
    
         
            +
                      iv.accessor(:instance)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    end
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              def assert_no_respond_to(object, method, message="")
         
     | 
| 
      
 39 
     | 
    
         
            +
                assert method.kind_of?(Symbol)
         
     | 
| 
      
 40 
     | 
    
         
            +
                msg = "#{object} of type #{object.class} not expected to respond_to? #{method}\n#{message}"
         
     | 
| 
      
 41 
     | 
    
         
            +
                assert((not object.respond_to?(method)), msg)
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              def test_class_symbol_prefix
         
     | 
| 
      
 45 
     | 
    
         
            +
                assert_equal("tc_saferivarrun_root", Safer::IVar.class_symbol_prefix(Root))
         
     | 
| 
      
 46 
     | 
    
         
            +
                assert_equal("tc_saferivarrun_root_test", Safer::IVar.class_symbol_prefix(Root::Test))
         
     | 
| 
      
 47 
     | 
    
         
            +
                assert_equal("tc_saferivarrun_root_test_instance", Safer::IVar.class_symbol_prefix(Root::Test::Instance))
         
     | 
| 
      
 48 
     | 
    
         
            +
                k = Root.class_eval("$k = Class.new(Root::Test::Instance)")
         
     | 
| 
      
 49 
     | 
    
         
            +
                assert_same(nil, Safer::IVar.class_symbol_prefix(k))
         
     | 
| 
      
 50 
     | 
    
         
            +
                b = k.class_eval("class Blah ; end ; Blah")
         
     | 
| 
      
 51 
     | 
    
         
            +
                assert_equal("blah", Safer::IVar.class_symbol_prefix(b))
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              def test_instance
         
     | 
| 
      
 55 
     | 
    
         
            +
                test_accessors = proc do |obj, expectRead, expectWrite|
         
     | 
| 
      
 56 
     | 
    
         
            +
                  if expectRead
         
     | 
| 
      
 57 
     | 
    
         
            +
                    assert_respond_to(obj, :instance)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  else
         
     | 
| 
      
 59 
     | 
    
         
            +
                    assert_no_respond_to(obj, :instance)
         
     | 
| 
      
 60 
     | 
    
         
            +
                  end
         
     | 
| 
      
 61 
     | 
    
         
            +
                  if expectWrite
         
     | 
| 
      
 62 
     | 
    
         
            +
                    assert_respond_to(obj, :instance=)
         
     | 
| 
      
 63 
     | 
    
         
            +
                  else
         
     | 
| 
      
 64 
     | 
    
         
            +
                    assert_no_respond_to(obj, :instance=)
         
     | 
| 
      
 65 
     | 
    
         
            +
                  end
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
                ti = Root::Test::Instance.new
         
     | 
| 
      
 68 
     | 
    
         
            +
                assert_respond_to(ti, :tc_saferivarrun_root_test_instance__instance)
         
     | 
| 
      
 69 
     | 
    
         
            +
                test_accessors.call(ti, false, false)
         
     | 
| 
      
 70 
     | 
    
         
            +
                tr = Root::Test::Reader.new
         
     | 
| 
      
 71 
     | 
    
         
            +
                test_accessors.call(tr, true, false)
         
     | 
| 
      
 72 
     | 
    
         
            +
                tw = Root::Test::Writer.new
         
     | 
| 
      
 73 
     | 
    
         
            +
                test_accessors.call(tw, false, true)
         
     | 
| 
      
 74 
     | 
    
         
            +
                ta = Root::Test::Accessor.new
         
     | 
| 
      
 75 
     | 
    
         
            +
                test_accessors.call(ta, true, true)
         
     | 
| 
      
 76 
     | 
    
         
            +
              end
         
     | 
| 
      
 77 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'test/unit'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'safer/ivarfactory'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class TC_SaferIVarFactory < Test::Unit::TestCase
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Root
         
     | 
| 
      
 6 
     | 
    
         
            +
                class Test
         
     | 
| 
      
 7 
     | 
    
         
            +
                  class Instance
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
                  class Reader
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
                  class Writer
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
                  class Accessor
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              def test_fullPrefix
         
     | 
| 
      
 24 
     | 
    
         
            +
                assert_equal(
         
     | 
| 
      
 25 
     | 
    
         
            +
                  Safer::IVarFactory::Prefix::Full.class_symbol_prefix(Root::Test),
         
     | 
| 
      
 26 
     | 
    
         
            +
                  'tc_saferivarfactory_root_test')
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
              def test_lastPrefix
         
     | 
| 
      
 29 
     | 
    
         
            +
                assert_equal(
         
     | 
| 
      
 30 
     | 
    
         
            +
                  Safer::IVarFactory::Prefix::Last.class_symbol_prefix(Root::Test),
         
     | 
| 
      
 31 
     | 
    
         
            +
                  'test')
         
     | 
| 
      
 32 
     | 
    
         
            +
                assert_equal(
         
     | 
| 
      
 33 
     | 
    
         
            +
                  Safer::IVarFactory::Prefix::Last.class_symbol_prefix(Root),
         
     | 
| 
      
 34 
     | 
    
         
            +
                  'root')
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
    
        data/test/test_safer_protocol.rb
    CHANGED
    
    | 
         @@ -12,7 +12,9 @@ module ArityModule 
     | 
|
| 
       12 
12 
     | 
    
         
             
              end
         
     | 
| 
       13 
13 
     | 
    
         
             
              def arity_2_any(one, two, *args)
         
     | 
| 
       14 
14 
     | 
    
         
             
              end
         
     | 
| 
       15 
     | 
    
         
            -
              METHODS =  
     | 
| 
      
 15 
     | 
    
         
            +
              METHODS = self.instance_methods.find_all do |meth|
         
     | 
| 
      
 16 
     | 
    
         
            +
                /^arity_/ === meth.to_s
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
       16 
18 
     | 
    
         
             
            end
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
20 
     | 
    
         
             
            class TestArityClass
         
     | 
| 
         @@ -78,7 +80,9 @@ class TC_SaferProtocol < Test::Unit::TestCase 
     | 
|
| 
       78 
80 
     | 
    
         
             
                assert_equal(@both_protocol.class_signature, @class_protocol.class_signature)
         
     | 
| 
       79 
81 
     | 
    
         
             
                assert_equal(@both_protocol.instance_signature, @instance_protocol.instance_signature)
         
     | 
| 
       80 
82 
     | 
    
         
             
                assert_equal(@class_protocol.class_signature, @instance_protocol.instance_signature)
         
     | 
| 
       81 
     | 
    
         
            -
                arity_methods = ArityModule 
     | 
| 
      
 83 
     | 
    
         
            +
                arity_methods = ArityModule.instance_methods.find_all do |meth|
         
     | 
| 
      
 84 
     | 
    
         
            +
                  ArityModule::METHODS.include?(meth)
         
     | 
| 
      
 85 
     | 
    
         
            +
                end.sort
         
     | 
| 
       82 
86 
     | 
    
         
             
                assert_equal(@class_protocol.class_signature.table.keys.sort, arity_methods)
         
     | 
| 
       83 
87 
     | 
    
         
             
              end
         
     | 
| 
       84 
88 
     | 
    
         | 
| 
         @@ -109,7 +113,8 @@ class TC_SaferProtocol < Test::Unit::TestCase 
     | 
|
| 
       109 
113 
     | 
    
         
             
                assert_same(methods[:get_object].call(@error_instance), violations.error_object)
         
     | 
| 
       110 
114 
     | 
    
         
             
                assert_same(@instance_protocol, violations.protocol)
         
     | 
| 
       111 
115 
     | 
    
         
             
                assert_same(nil, violations.class_violations)
         
     | 
| 
       112 
     | 
    
         
            -
                 
     | 
| 
      
 116 
     | 
    
         
            +
                keysym = ArityModule::METHODS.find do |name| name.to_s == 'arity_empty' end
         
     | 
| 
      
 117 
     | 
    
         
            +
                assert_equal({ keysym => 1 }, violations.instance_violations.table)
         
     | 
| 
       113 
118 
     | 
    
         
             
                begin
         
     | 
| 
       114 
119 
     | 
    
         
             
                  @instance_protocol.send(methods[:conforms], methods[:get_object].call(@error_instance))
         
     | 
| 
       115 
120 
     | 
    
         
             
                  flunk("Expected exception.")
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: safer
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 15
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 8 
     | 
    
         
            +
              - 4
         
     | 
| 
      
 9 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.4.0
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Aidan Cully
         
     | 
| 
         @@ -15,7 +15,7 @@ autorequire: 
     | 
|
| 
       15 
15 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
16 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            date:  
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2011-10-29 00:00:00 -04:00
         
     | 
| 
       19 
19 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       20 
20 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       21 
21 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -73,12 +73,11 @@ extensions: [] 
     | 
|
| 
       73 
73 
     | 
    
         
             
            extra_rdoc_files: 
         
     | 
| 
       74 
74 
     | 
    
         
             
            - History.txt
         
     | 
| 
       75 
75 
     | 
    
         
             
            - Manifest.txt
         
     | 
| 
       76 
     | 
    
         
            -
            - README.txt
         
     | 
| 
       77 
76 
     | 
    
         
             
            files: 
         
     | 
| 
       78 
77 
     | 
    
         
             
            - .autotest
         
     | 
| 
       79 
78 
     | 
    
         
             
            - History.txt
         
     | 
| 
       80 
79 
     | 
    
         
             
            - Manifest.txt
         
     | 
| 
       81 
     | 
    
         
            -
            - README. 
     | 
| 
      
 80 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
       82 
81 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       83 
82 
     | 
    
         
             
            - lib/safer.rb
         
     | 
| 
       84 
83 
     | 
    
         
             
            - lib/safer/ivar.rb
         
     | 
| 
         @@ -87,6 +86,8 @@ files: 
     | 
|
| 
       87 
86 
     | 
    
         
             
            - test/test_safer_ivar.rb
         
     | 
| 
       88 
87 
     | 
    
         
             
            - test/test_safer_protocol.rb
         
     | 
| 
       89 
88 
     | 
    
         
             
            - test/test_safer_hashprotocol.rb
         
     | 
| 
      
 89 
     | 
    
         
            +
            - test/test_safer_ivar_run.rb
         
     | 
| 
      
 90 
     | 
    
         
            +
            - test/test_safer_ivarfactory.rb
         
     | 
| 
       90 
91 
     | 
    
         
             
            has_rdoc: true
         
     | 
| 
       91 
92 
     | 
    
         
             
            homepage: http://safer.rubyforge.org
         
     | 
| 
       92 
93 
     | 
    
         
             
            licenses: []
         
     | 
| 
         @@ -94,7 +95,7 @@ licenses: [] 
     | 
|
| 
       94 
95 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       95 
96 
     | 
    
         
             
            rdoc_options: 
         
     | 
| 
       96 
97 
     | 
    
         
             
            - --main
         
     | 
| 
       97 
     | 
    
         
            -
            - README. 
     | 
| 
      
 98 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
       98 
99 
     | 
    
         
             
            require_paths: 
         
     | 
| 
       99 
100 
     | 
    
         
             
            - lib
         
     | 
| 
       100 
101 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
         @@ -125,4 +126,6 @@ summary: Safer is an umbrella library, with components designed to make it simpl 
     | 
|
| 
       125 
126 
     | 
    
         
             
            test_files: 
         
     | 
| 
       126 
127 
     | 
    
         
             
            - test/test_safer_hashprotocol.rb
         
     | 
| 
       127 
128 
     | 
    
         
             
            - test/test_safer_ivar.rb
         
     | 
| 
      
 129 
     | 
    
         
            +
            - test/test_safer_ivar_run.rb
         
     | 
| 
      
 130 
     | 
    
         
            +
            - test/test_safer_ivarfactory.rb
         
     | 
| 
       128 
131 
     | 
    
         
             
            - test/test_safer_protocol.rb
         
     |