prototype 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +17 -7
- data/README.tmpl +11 -1
- data/a.rb +7 -0
- data/lib/{prototype-0.3.0.rb → prototype-1.0.0.rb} +7 -3
- data/lib/prototype.rb +7 -3
- data/prototype-1.0.0.gem +0 -0
- data/samples/e.rb +1 -1
- data/samples/f.rb +3 -3
- metadata +44 -37
data/README
CHANGED
@@ -17,7 +17,17 @@ SYNOPSIS
|
|
17
17
|
|
18
18
|
WHY
|
19
19
|
|
20
|
-
prototype based programming
|
20
|
+
prototype based programming looks very nice ;-)
|
21
|
+
|
22
|
+
also, there are many problems that a genuine singleton object with cloning
|
23
|
+
abilities can illuminate clearly
|
24
|
+
|
25
|
+
HISTORY
|
26
|
+
|
27
|
+
1.0.0
|
28
|
+
|
29
|
+
cleanup up a small error where bareword syntax errors in a prototype block
|
30
|
+
were silently ignored
|
21
31
|
|
22
32
|
SAMPLES
|
23
33
|
|
@@ -64,7 +74,7 @@ SAMPLES
|
|
64
74
|
|
65
75
|
~ > ruby samples/b.rb
|
66
76
|
|
67
|
-
#<#<Class:
|
77
|
+
#<#<Class:0x10f8948>:0x10f7fac @port=4242, @host="localhost", @conn_string="localhost:4242">
|
68
78
|
"localhost"
|
69
79
|
4242
|
70
80
|
"localhost:4242"
|
@@ -108,7 +118,7 @@ SAMPLES
|
|
108
118
|
"42"
|
109
119
|
"42"
|
110
120
|
42.0
|
111
|
-
samples/c.rb:24: undefined method `method3' for #<#<Class:
|
121
|
+
samples/c.rb:24: undefined method `method3' for #<#<Class:0x10fb79c>:0x10fb42c> (NoMethodError)
|
112
122
|
|
113
123
|
|
114
124
|
<========< samples/d.rb >========>
|
@@ -147,7 +157,7 @@ SAMPLES
|
|
147
157
|
|
148
158
|
require 'prototype'
|
149
159
|
|
150
|
-
proto = prototype{
|
160
|
+
proto = Object.prototype{
|
151
161
|
@a = 40
|
152
162
|
@b = 2
|
153
163
|
}
|
@@ -165,11 +175,11 @@ SAMPLES
|
|
165
175
|
|
166
176
|
require 'prototype'
|
167
177
|
|
168
|
-
a = prototype{ attributes 'a' => 4, 'b' => 10, 'c' => 2}
|
178
|
+
a = Object.prototype{ attributes 'a' => 4, 'b' => 10, 'c' => 2}
|
169
179
|
|
170
|
-
b = prototype{ a 4; b 10; c 2 }
|
180
|
+
b = Object.prototype{ a 4; b 10; c 2 }
|
171
181
|
|
172
|
-
c = prototype{ @a = 4; @b = 10; @c = 2 }
|
182
|
+
c = Object.prototype{ @a = 4; @b = 10; @c = 2 }
|
173
183
|
|
174
184
|
[a, b, c].each{|obj| p(obj.a * obj.b + obj.c) }
|
175
185
|
|
data/README.tmpl
CHANGED
@@ -17,7 +17,17 @@ SYNOPSIS
|
|
17
17
|
|
18
18
|
WHY
|
19
19
|
|
20
|
-
prototype based programming
|
20
|
+
prototype based programming looks very nice ;-)
|
21
|
+
|
22
|
+
also, there are many problems that a genuine singleton object with cloning
|
23
|
+
abilities can illuminate clearly
|
24
|
+
|
25
|
+
HISTORY
|
26
|
+
|
27
|
+
1.0.0
|
28
|
+
|
29
|
+
cleanup up a small error where bareword syntax errors in a prototype block
|
30
|
+
were silently ignored
|
21
31
|
|
22
32
|
SAMPLES
|
23
33
|
|
data/a.rb
ADDED
@@ -26,7 +26,8 @@ end
|
|
26
26
|
#
|
27
27
|
|
28
28
|
class Prototype
|
29
|
-
VERSION = '0.
|
29
|
+
VERSION = '1.0.0'
|
30
|
+
def version() VERSION end
|
30
31
|
|
31
32
|
module Prototypical
|
32
33
|
module ClassMethods
|
@@ -65,12 +66,14 @@ class Prototype
|
|
65
66
|
define_method m, *a, &b
|
66
67
|
else
|
67
68
|
ivar = "@#{ m }"
|
69
|
+
tid = Thread.current.object_id.abs
|
70
|
+
missing = "__method_missing_#{ tid }__"
|
68
71
|
if a.size == 0
|
69
|
-
defined?
|
72
|
+
eval("defined? #{ ivar }") ? instance_variable_get(ivar) : method(missing).call(m, *a, &b)
|
70
73
|
elsif a.size == 1
|
71
74
|
instance_variable_set ivar, a.shift
|
72
75
|
else
|
73
|
-
|
76
|
+
method(missing).call(m, *a, &b)
|
74
77
|
end
|
75
78
|
end
|
76
79
|
end
|
@@ -147,6 +150,7 @@ class Prototype
|
|
147
150
|
def clone *a, &b
|
148
151
|
obj = prototype(self.class, *a, &b)
|
149
152
|
instance_variables.each do |ivar|
|
153
|
+
next if obj.instance_eval("defined? #{ ivar }")
|
150
154
|
value = instance_variable_get ivar
|
151
155
|
obj.instance_variable_set ivar, value
|
152
156
|
end
|
data/lib/prototype.rb
CHANGED
@@ -26,7 +26,8 @@ end
|
|
26
26
|
#
|
27
27
|
|
28
28
|
class Prototype
|
29
|
-
VERSION = '0.
|
29
|
+
VERSION = '1.0.0'
|
30
|
+
def version() VERSION end
|
30
31
|
|
31
32
|
module Prototypical
|
32
33
|
module ClassMethods
|
@@ -65,12 +66,14 @@ class Prototype
|
|
65
66
|
define_method m, *a, &b
|
66
67
|
else
|
67
68
|
ivar = "@#{ m }"
|
69
|
+
tid = Thread.current.object_id.abs
|
70
|
+
missing = "__method_missing_#{ tid }__"
|
68
71
|
if a.size == 0
|
69
|
-
defined?
|
72
|
+
eval("defined? #{ ivar }") ? instance_variable_get(ivar) : method(missing).call(m, *a, &b)
|
70
73
|
elsif a.size == 1
|
71
74
|
instance_variable_set ivar, a.shift
|
72
75
|
else
|
73
|
-
|
76
|
+
method(missing).call(m, *a, &b)
|
74
77
|
end
|
75
78
|
end
|
76
79
|
end
|
@@ -147,6 +150,7 @@ class Prototype
|
|
147
150
|
def clone *a, &b
|
148
151
|
obj = prototype(self.class, *a, &b)
|
149
152
|
instance_variables.each do |ivar|
|
153
|
+
next if obj.instance_eval("defined? #{ ivar }")
|
150
154
|
value = instance_variable_get ivar
|
151
155
|
obj.instance_variable_set ivar, value
|
152
156
|
end
|
data/prototype-1.0.0.gem
ADDED
File without changes
|
data/samples/e.rb
CHANGED
data/samples/f.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'prototype'
|
2
2
|
|
3
|
-
a = prototype{ attributes 'a' => 4, 'b' => 10, 'c' => 2}
|
3
|
+
a = Object.prototype{ attributes 'a' => 4, 'b' => 10, 'c' => 2}
|
4
4
|
|
5
|
-
b = prototype{ a 4; b 10; c 2 }
|
5
|
+
b = Object.prototype{ a 4; b 10; c 2 }
|
6
6
|
|
7
|
-
c = prototype{ @a = 4; @b = 10; @c = 2 }
|
7
|
+
c = Object.prototype{ @a = 4; @b = 10; @c = 2 }
|
8
8
|
|
9
9
|
[a, b, c].each{|obj| p(obj.a * obj.b + obj.c) }
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.2
|
3
3
|
specification_version: 1
|
4
4
|
name: prototype
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date:
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2007-05-24 00:00:00 -06:00
|
8
8
|
summary: prototype
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: ara.t.howard@noaa.gov
|
12
12
|
homepage: http://codeforpeople.com/lib/ruby/prototype/
|
13
13
|
rubyforge_project:
|
@@ -18,49 +18,56 @@ bindir: bin
|
|
18
18
|
has_rdoc: false
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
25
24
|
version:
|
26
25
|
platform: ruby
|
27
26
|
signing_key:
|
28
27
|
cert_chain:
|
28
|
+
post_install_message:
|
29
29
|
authors:
|
30
|
-
|
30
|
+
- Ara T. Howard
|
31
31
|
files:
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
32
|
+
- a.rb
|
33
|
+
- gemspec.rb
|
34
|
+
- gen_readme.rb
|
35
|
+
- install.rb
|
36
|
+
- lib
|
37
|
+
- lib/prototype-1.0.0.rb
|
38
|
+
- lib/prototype.rb
|
39
|
+
- prototype-1.0.0.gem
|
40
|
+
- README
|
41
|
+
- README.tmpl
|
42
|
+
- samples
|
43
|
+
- samples/a.rb
|
44
|
+
- samples/b.rb
|
45
|
+
- samples/c.rb
|
46
|
+
- samples/d.rb
|
47
|
+
- samples/e.rb
|
48
|
+
- samples/f.rb
|
49
|
+
- samples/g.rb
|
50
|
+
- samples/h.rb
|
51
|
+
- samples/i.rb
|
50
52
|
test_files: []
|
53
|
+
|
51
54
|
rdoc_options: []
|
55
|
+
|
52
56
|
extra_rdoc_files: []
|
57
|
+
|
53
58
|
executables: []
|
59
|
+
|
54
60
|
extensions: []
|
61
|
+
|
55
62
|
requirements: []
|
63
|
+
|
56
64
|
dependencies:
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: attributes
|
67
|
+
version_requirement:
|
68
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "3.0"
|
73
|
+
version:
|