prototype 0.2.0 → 0.3.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/README +40 -2
- data/lib/{prototype-0.2.0.rb → prototype-0.3.0.rb} +31 -8
- data/lib/prototype.rb +31 -8
- data/samples/i.rb +25 -0
- metadata +4 -4
- data/prototype-0.2.0.gem +0 -0
    
        data/README
    CHANGED
    
    | @@ -64,7 +64,7 @@ SAMPLES | |
| 64 64 |  | 
| 65 65 | 
             
              ~ > ruby samples/b.rb
         | 
| 66 66 |  | 
| 67 | 
            -
                #<#<Class: | 
| 67 | 
            +
                #<#<Class:0xb7593c54>:0xb759322c @conn_string="localhost:4242", @port=4242, @host="localhost">
         | 
| 68 68 | 
             
                "localhost"
         | 
| 69 69 | 
             
                4242
         | 
| 70 70 | 
             
                "localhost:4242"
         | 
| @@ -108,7 +108,7 @@ SAMPLES | |
| 108 108 | 
             
                "42"
         | 
| 109 109 | 
             
                "42"
         | 
| 110 110 | 
             
                42.0
         | 
| 111 | 
            -
                samples/c.rb:24: undefined method `method3' for #<#<Class: | 
| 111 | 
            +
                samples/c.rb:24: undefined method `method3' for #<#<Class:0xb7595790>:0xb7595420> (NoMethodError)
         | 
| 112 112 |  | 
| 113 113 |  | 
| 114 114 | 
             
              <========< samples/d.rb >========>
         | 
| @@ -221,3 +221,41 @@ SAMPLES | |
| 221 221 |  | 
| 222 222 | 
             
                42
         | 
| 223 223 |  | 
| 224 | 
            +
             | 
| 225 | 
            +
              <========< samples/i.rb >========>
         | 
| 226 | 
            +
             | 
| 227 | 
            +
              ~ > cat samples/i.rb
         | 
| 228 | 
            +
             | 
| 229 | 
            +
                require 'prototype'
         | 
| 230 | 
            +
                
         | 
| 231 | 
            +
                o = Object.new
         | 
| 232 | 
            +
                
         | 
| 233 | 
            +
                o.prototyping do
         | 
| 234 | 
            +
                  @a = 42
         | 
| 235 | 
            +
                  attr 'a'
         | 
| 236 | 
            +
                end
         | 
| 237 | 
            +
                p o.a
         | 
| 238 | 
            +
                
         | 
| 239 | 
            +
                o = prototype do
         | 
| 240 | 
            +
                  @a = 42
         | 
| 241 | 
            +
                  attr 'a'
         | 
| 242 | 
            +
                end
         | 
| 243 | 
            +
                p o.a
         | 
| 244 | 
            +
                
         | 
| 245 | 
            +
                o.prototyping do
         | 
| 246 | 
            +
                  @b = 42
         | 
| 247 | 
            +
                  attr 'b'
         | 
| 248 | 
            +
                end
         | 
| 249 | 
            +
                p o.b
         | 
| 250 | 
            +
                o.prototyping do
         | 
| 251 | 
            +
                  @b = 42.0
         | 
| 252 | 
            +
                end
         | 
| 253 | 
            +
                p o.b
         | 
| 254 | 
            +
             | 
| 255 | 
            +
              ~ > ruby samples/i.rb
         | 
| 256 | 
            +
             | 
| 257 | 
            +
                42
         | 
| 258 | 
            +
                42
         | 
| 259 | 
            +
                42
         | 
| 260 | 
            +
                42.0
         | 
| 261 | 
            +
             | 
| @@ -26,7 +26,7 @@ end | |
| 26 26 | 
             
            #
         | 
| 27 27 |  | 
| 28 28 | 
             
            class Prototype
         | 
| 29 | 
            -
              VERSION = '0. | 
| 29 | 
            +
              VERSION = '0.3.0'
         | 
| 30 30 |  | 
| 31 31 | 
             
              module Prototypical
         | 
| 32 32 | 
             
                module ClassMethods
         | 
| @@ -35,7 +35,14 @@ class Prototype | |
| 35 35 | 
             
                      table = {}
         | 
| 36 36 | 
             
                      define_method('__prototype_table__'){ table }
         | 
| 37 37 | 
             
                    }
         | 
| 38 | 
            -
                    __prototype_table__
         | 
| 38 | 
            +
                    __prototype_table__    # does not recurse!
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  def __prototype_table_inject__ other
         | 
| 42 | 
            +
                    __prototype_table__.each do |ivar, value|
         | 
| 43 | 
            +
                      other.instance_variable_set ivar, value
         | 
| 44 | 
            +
                    end
         | 
| 45 | 
            +
                    __prototype_table__.clear
         | 
| 39 46 | 
             
                  end
         | 
| 40 47 |  | 
| 41 48 | 
             
                  def __prototype_eval__ &b
         | 
| @@ -112,17 +119,17 @@ class Prototype | |
| 112 119 | 
             
                    super
         | 
| 113 120 | 
             
                  end
         | 
| 114 121 |  | 
| 115 | 
            -
                  def __prototype_init__
         | 
| 116 | 
            -
                     | 
| 117 | 
            -
                      defined = instance_eval "defined? #{ ivar }"
         | 
| 118 | 
            -
                      unless defined
         | 
| 122 | 
            +
                  def __prototype_init__ c = self.class
         | 
| 123 | 
            +
                    c.__prototype_table__.each do |ivar, value|
         | 
| 124 | 
            +
                      #defined = instance_eval "defined? #{ ivar }"
         | 
| 125 | 
            +
                      #unless defined
         | 
| 119 126 | 
             
                        instance_variable_set ivar, value
         | 
| 120 | 
            -
                      end
         | 
| 127 | 
            +
                      #end
         | 
| 121 128 |  | 
| 122 129 | 
             
                      a = ivar[%r/\w+/]
         | 
| 123 130 | 
             
                      defined = respond_to? a 
         | 
| 124 131 | 
             
                      unless defined
         | 
| 125 | 
            -
                        self.class.module_eval{ attribute a  | 
| 132 | 
            +
                        self.class.module_eval{ attribute a }
         | 
| 126 133 | 
             
                      end
         | 
| 127 134 | 
             
                    end
         | 
| 128 135 | 
             
                  end
         | 
| @@ -168,10 +175,26 @@ class Prototype | |
| 168 175 |  | 
| 169 176 | 
             
                alias_method "exnihilo", "new"
         | 
| 170 177 | 
             
                alias_method "ex_nihilo", "new"
         | 
| 178 | 
            +
             | 
| 179 | 
            +
                def prototyping obj, *a, &b
         | 
| 180 | 
            +
                  c =
         | 
| 181 | 
            +
                    class << obj 
         | 
| 182 | 
            +
                      self
         | 
| 183 | 
            +
                    end
         | 
| 184 | 
            +
                  parent = c.class
         | 
| 185 | 
            +
                  c.extend Prototypical unless Prototypical === c
         | 
| 186 | 
            +
                  c.__prototype_table__.update parent.__prototype_table__ if
         | 
| 187 | 
            +
                    parent.respond_to? '__prototype_table__'
         | 
| 188 | 
            +
                  c.__prototype_prototype__ &b
         | 
| 189 | 
            +
                  obj.__prototype_init__ c
         | 
| 190 | 
            +
                  obj
         | 
| 191 | 
            +
                end
         | 
| 171 192 | 
             
              end
         | 
| 172 193 | 
             
            end
         | 
| 173 194 |  | 
| 174 195 | 
             
            class Object
         | 
| 175 196 | 
             
              def Prototype(*a, &b) Prototype.new *a, &b end
         | 
| 176 197 | 
             
              def prototype(*a, &b) Prototype.new *a, &b end
         | 
| 198 | 
            +
              def Prototyping(*a, &b) Prototype.prototyping self, *a, &b end
         | 
| 199 | 
            +
              def prototyping(*a, &b) Prototype.prototyping self, *a, &b end
         | 
| 177 200 | 
             
            end
         | 
    
        data/lib/prototype.rb
    CHANGED
    
    | @@ -26,7 +26,7 @@ end | |
| 26 26 | 
             
            #
         | 
| 27 27 |  | 
| 28 28 | 
             
            class Prototype
         | 
| 29 | 
            -
              VERSION = '0. | 
| 29 | 
            +
              VERSION = '0.3.0'
         | 
| 30 30 |  | 
| 31 31 | 
             
              module Prototypical
         | 
| 32 32 | 
             
                module ClassMethods
         | 
| @@ -35,7 +35,14 @@ class Prototype | |
| 35 35 | 
             
                      table = {}
         | 
| 36 36 | 
             
                      define_method('__prototype_table__'){ table }
         | 
| 37 37 | 
             
                    }
         | 
| 38 | 
            -
                    __prototype_table__
         | 
| 38 | 
            +
                    __prototype_table__    # does not recurse!
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  def __prototype_table_inject__ other
         | 
| 42 | 
            +
                    __prototype_table__.each do |ivar, value|
         | 
| 43 | 
            +
                      other.instance_variable_set ivar, value
         | 
| 44 | 
            +
                    end
         | 
| 45 | 
            +
                    __prototype_table__.clear
         | 
| 39 46 | 
             
                  end
         | 
| 40 47 |  | 
| 41 48 | 
             
                  def __prototype_eval__ &b
         | 
| @@ -112,17 +119,17 @@ class Prototype | |
| 112 119 | 
             
                    super
         | 
| 113 120 | 
             
                  end
         | 
| 114 121 |  | 
| 115 | 
            -
                  def __prototype_init__
         | 
| 116 | 
            -
                     | 
| 117 | 
            -
                      defined = instance_eval "defined? #{ ivar }"
         | 
| 118 | 
            -
                      unless defined
         | 
| 122 | 
            +
                  def __prototype_init__ c = self.class
         | 
| 123 | 
            +
                    c.__prototype_table__.each do |ivar, value|
         | 
| 124 | 
            +
                      #defined = instance_eval "defined? #{ ivar }"
         | 
| 125 | 
            +
                      #unless defined
         | 
| 119 126 | 
             
                        instance_variable_set ivar, value
         | 
| 120 | 
            -
                      end
         | 
| 127 | 
            +
                      #end
         | 
| 121 128 |  | 
| 122 129 | 
             
                      a = ivar[%r/\w+/]
         | 
| 123 130 | 
             
                      defined = respond_to? a 
         | 
| 124 131 | 
             
                      unless defined
         | 
| 125 | 
            -
                        self.class.module_eval{ attribute a  | 
| 132 | 
            +
                        self.class.module_eval{ attribute a }
         | 
| 126 133 | 
             
                      end
         | 
| 127 134 | 
             
                    end
         | 
| 128 135 | 
             
                  end
         | 
| @@ -168,10 +175,26 @@ class Prototype | |
| 168 175 |  | 
| 169 176 | 
             
                alias_method "exnihilo", "new"
         | 
| 170 177 | 
             
                alias_method "ex_nihilo", "new"
         | 
| 178 | 
            +
             | 
| 179 | 
            +
                def prototyping obj, *a, &b
         | 
| 180 | 
            +
                  c =
         | 
| 181 | 
            +
                    class << obj 
         | 
| 182 | 
            +
                      self
         | 
| 183 | 
            +
                    end
         | 
| 184 | 
            +
                  parent = c.class
         | 
| 185 | 
            +
                  c.extend Prototypical unless Prototypical === c
         | 
| 186 | 
            +
                  c.__prototype_table__.update parent.__prototype_table__ if
         | 
| 187 | 
            +
                    parent.respond_to? '__prototype_table__'
         | 
| 188 | 
            +
                  c.__prototype_prototype__ &b
         | 
| 189 | 
            +
                  obj.__prototype_init__ c
         | 
| 190 | 
            +
                  obj
         | 
| 191 | 
            +
                end
         | 
| 171 192 | 
             
              end
         | 
| 172 193 | 
             
            end
         | 
| 173 194 |  | 
| 174 195 | 
             
            class Object
         | 
| 175 196 | 
             
              def Prototype(*a, &b) Prototype.new *a, &b end
         | 
| 176 197 | 
             
              def prototype(*a, &b) Prototype.new *a, &b end
         | 
| 198 | 
            +
              def Prototyping(*a, &b) Prototype.prototyping self, *a, &b end
         | 
| 199 | 
            +
              def prototyping(*a, &b) Prototype.prototyping self, *a, &b end
         | 
| 177 200 | 
             
            end
         | 
    
        data/samples/i.rb
    ADDED
    
    | @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            require 'prototype'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            o = Object.new
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            o.prototyping do
         | 
| 6 | 
            +
              @a = 42
         | 
| 7 | 
            +
              attr 'a'
         | 
| 8 | 
            +
            end
         | 
| 9 | 
            +
            p o.a
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            o = prototype do
         | 
| 12 | 
            +
              @a = 42
         | 
| 13 | 
            +
              attr 'a'
         | 
| 14 | 
            +
            end
         | 
| 15 | 
            +
            p o.a
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            o.prototyping do
         | 
| 18 | 
            +
              @b = 42
         | 
| 19 | 
            +
              attr 'b'
         | 
| 20 | 
            +
            end
         | 
| 21 | 
            +
            p o.b
         | 
| 22 | 
            +
            o.prototyping do
         | 
| 23 | 
            +
              @b = 42.0
         | 
| 24 | 
            +
            end
         | 
| 25 | 
            +
            p o.b
         | 
    
        metadata
    CHANGED
    
    | @@ -3,8 +3,8 @@ rubygems_version: 0.8.11 | |
| 3 3 | 
             
            specification_version: 1
         | 
| 4 4 | 
             
            name: prototype
         | 
| 5 5 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 6 | 
            -
              version: 0. | 
| 7 | 
            -
            date: 2006- | 
| 6 | 
            +
              version: 0.3.0
         | 
| 7 | 
            +
            date: 2006-08-30 00:00:00.000000 -06:00
         | 
| 8 8 | 
             
            summary: prototype
         | 
| 9 9 | 
             
            require_paths: 
         | 
| 10 10 | 
             
              - lib
         | 
| @@ -36,9 +36,8 @@ files: | |
| 36 36 | 
             
              - README
         | 
| 37 37 | 
             
              - README.tmpl
         | 
| 38 38 | 
             
              - gen_readme.rb
         | 
| 39 | 
            -
              - prototype-0.2.0.gem
         | 
| 40 39 | 
             
              - lib/prototype.rb
         | 
| 41 | 
            -
              - lib/prototype-0. | 
| 40 | 
            +
              - lib/prototype-0.3.0.rb
         | 
| 42 41 | 
             
              - samples/c.rb
         | 
| 43 42 | 
             
              - samples/a.rb
         | 
| 44 43 | 
             
              - samples/b.rb
         | 
| @@ -47,6 +46,7 @@ files: | |
| 47 46 | 
             
              - samples/f.rb
         | 
| 48 47 | 
             
              - samples/g.rb
         | 
| 49 48 | 
             
              - samples/h.rb
         | 
| 49 | 
            +
              - samples/i.rb
         | 
| 50 50 | 
             
            test_files: []
         | 
| 51 51 | 
             
            rdoc_options: []
         | 
| 52 52 | 
             
            extra_rdoc_files: []
         | 
    
        data/prototype-0.2.0.gem
    DELETED
    
    | 
            File without changes
         |