pervasives 0.0.1 → 1.0.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 +3 -3
- data/README.tmpl +7 -0
- data/lib/pervasives-1.0.0.rb +32 -0
- data/lib/pervasives.rb +18 -47
- data/pervasives-1.0.0.gem +0 -0
- metadata +33 -26
- data/lib/pervasives-0.0.1.rb +0 -61
data/README
CHANGED
@@ -72,7 +72,7 @@ SAMPLES
|
|
72
72
|
|
73
73
|
{"instance_eval"=>42, "send"=>42, "object_id"=>42}
|
74
74
|
42
|
75
|
-
|
75
|
+
174950
|
76
76
|
42
|
77
77
|
"value"
|
78
78
|
42
|
@@ -105,7 +105,7 @@ SAMPLES
|
|
105
105
|
~ > ruby samples/b.rb
|
106
106
|
|
107
107
|
42
|
108
|
-
|
108
|
+
177470
|
109
109
|
|
110
110
|
|
111
111
|
<========< samples/c.rb >========>
|
@@ -130,7 +130,7 @@ SAMPLES
|
|
130
130
|
~ > ruby samples/c.rb
|
131
131
|
|
132
132
|
42
|
133
|
-
|
133
|
+
177540
|
134
134
|
|
135
135
|
|
136
136
|
<========< samples/d.rb >========>
|
data/README.tmpl
CHANGED
@@ -16,6 +16,13 @@ URIS
|
|
16
16
|
http://rubyforge.org/projects/codeforpeople/
|
17
17
|
http://codeforpeople.com/lib/ruby
|
18
18
|
|
19
|
+
HISTORY
|
20
|
+
|
21
|
+
1.0.0
|
22
|
+
|
23
|
+
is NOT backward compatible with any other pervasives version. the new
|
24
|
+
library is __greatly__ simplified
|
25
|
+
|
19
26
|
SAMPLES
|
20
27
|
|
21
28
|
@samples
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Pervasives
|
2
|
+
VERSION = "1.0.0"
|
3
|
+
def self.version() VERSION end
|
4
|
+
class ::Class
|
5
|
+
def __pervasive__ m, *a, &b
|
6
|
+
(( Class.instance_method(m) rescue Module.instance_method(m) rescue Object.instance_method(m) )).bind(self).call(*a, &b)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
class ::Module
|
10
|
+
def __pervasive__ m, *a, &b
|
11
|
+
(( Module.instance_method(m) rescue Object.instance_method(m) )).bind(self).call(*a, &b)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
class ::Object
|
15
|
+
def __pervasive__ m, *a, &b
|
16
|
+
(( Object.instance_method(m) )).bind(self).call(*a, &b)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Proxy
|
21
|
+
instance_methods.each{|m| undef_method m unless m[%r/__/]}
|
22
|
+
def initialize obj
|
23
|
+
@obj = obj
|
24
|
+
end
|
25
|
+
def method_missing m, *a, &b
|
26
|
+
@obj.__pervasive__ m, *a, &b
|
27
|
+
end
|
28
|
+
def __obj__
|
29
|
+
@obj
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/pervasives.rb
CHANGED
@@ -1,61 +1,32 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.0
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
type.instance_methods.each do |mname|
|
8
|
-
m = type.instance_method mname
|
9
|
-
METHODS[type][mname.to_s] = m
|
1
|
+
module Pervasives
|
2
|
+
VERSION = "1.0.0"
|
3
|
+
def self.version() VERSION end
|
4
|
+
class ::Class
|
5
|
+
def __pervasive__ m, *a, &b
|
6
|
+
(( Class.instance_method(m) rescue Module.instance_method(m) rescue Object.instance_method(m) )).bind(self).call(*a, &b)
|
10
7
|
end
|
11
8
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
search_path = case obj
|
21
|
-
when Class
|
22
|
-
[Class, Module, Object]
|
23
|
-
when Module
|
24
|
-
[Module, Object]
|
25
|
-
else
|
26
|
-
[Object]
|
27
|
-
end
|
28
|
-
type = search_path.detect{|type| METHODS[type]['#{ mname }']}
|
29
|
-
m = METHODS[type]['#{ mname }']
|
30
|
-
m.bind( obj ).call( *argv, &block )
|
31
|
-
end
|
32
|
-
code
|
9
|
+
class ::Module
|
10
|
+
def __pervasive__ m, *a, &b
|
11
|
+
(( Module.instance_method(m) rescue Object.instance_method(m) )).bind(self).call(*a, &b)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
class ::Object
|
15
|
+
def __pervasive__ m, *a, &b
|
16
|
+
(( Object.instance_method(m) )).bind(self).call(*a, &b)
|
33
17
|
end
|
34
18
|
end
|
35
19
|
|
36
20
|
class Proxy
|
37
|
-
alias_method "__class__", "class"
|
38
|
-
alias_method "__instance_eval__", "instance_eval"
|
39
21
|
instance_methods.each{|m| undef_method m unless m[%r/__/]}
|
40
22
|
def initialize obj
|
41
23
|
@obj = obj
|
42
24
|
end
|
43
25
|
def method_missing m, *a, &b
|
44
|
-
|
26
|
+
@obj.__pervasive__ m, *a, &b
|
27
|
+
end
|
28
|
+
def __obj__
|
29
|
+
@obj
|
45
30
|
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
module Kernel
|
53
|
-
def __ obj, &b
|
54
|
-
proxy = Pervasives::Proxy.new obj
|
55
|
-
b ? proxy.__instance_eval__(&b) : proxy
|
56
|
-
end
|
57
|
-
def __! obj, &b
|
58
|
-
proxy = Pervasives::Proxy.new obj
|
59
|
-
b ? proxy.__instance_eval__(&b) : proxy
|
60
31
|
end
|
61
32
|
end
|
File without changes
|
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: pervasives
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0
|
7
|
-
date: 2007-
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2007-09-08 00:00:00 -06:00
|
8
8
|
summary: pervasives
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: ara.t.howard@noaa.gov
|
12
12
|
homepage: http://codeforpeople.com/lib/ruby/pervasives/
|
13
13
|
rubyforge_project:
|
@@ -18,37 +18,44 @@ 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
|
-
|
32
|
+
- gemspec.rb
|
33
|
+
- gen_readme.rb
|
34
|
+
- install.rb
|
35
|
+
- lib
|
36
|
+
- lib/pervasives-1.0.0.rb
|
37
|
+
- lib/pervasives.rb
|
38
|
+
- pervasives-1.0.0.gem
|
39
|
+
- README
|
40
|
+
- README.tmpl
|
41
|
+
- samples
|
42
|
+
- samples/a.rb
|
43
|
+
- samples/b.rb
|
44
|
+
- samples/c.rb
|
45
|
+
- samples/d.rb
|
46
|
+
- test
|
47
|
+
- test/pervasives.rb
|
47
48
|
test_files:
|
48
|
-
|
49
|
+
- test/pervasives.rb
|
49
50
|
rdoc_options: []
|
51
|
+
|
50
52
|
extra_rdoc_files: []
|
53
|
+
|
51
54
|
executables: []
|
55
|
+
|
52
56
|
extensions: []
|
57
|
+
|
53
58
|
requirements: []
|
54
|
-
|
59
|
+
|
60
|
+
dependencies: []
|
61
|
+
|
data/lib/pervasives-0.0.1.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
class Pervasives
|
2
|
-
VERSION = "0.0.1"
|
3
|
-
|
4
|
-
METHODS = Hash.new{|h,k| h[k] = {}}
|
5
|
-
|
6
|
-
[Module, Class, Object].each do |type|
|
7
|
-
type.instance_methods.each do |mname|
|
8
|
-
m = type.instance_method mname
|
9
|
-
METHODS[type][mname.to_s] = m
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class << self
|
14
|
-
mnames = METHODS[Module].keys + METHODS[Class].keys + METHODS[Object].keys
|
15
|
-
|
16
|
-
mnames.each do |mname|
|
17
|
-
next if mname['__']
|
18
|
-
module_eval <<-code
|
19
|
-
def #{ mname } obj, *argv, &block
|
20
|
-
search_path = case obj
|
21
|
-
when Class
|
22
|
-
[Class, Module, Object]
|
23
|
-
when Module
|
24
|
-
[Module, Object]
|
25
|
-
else
|
26
|
-
[Object]
|
27
|
-
end
|
28
|
-
type = search_path.detect{|type| METHODS[type]['#{ mname }']}
|
29
|
-
m = METHODS[type]['#{ mname }']
|
30
|
-
m.bind( obj ).call( *argv, &block )
|
31
|
-
end
|
32
|
-
code
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class Proxy
|
37
|
-
alias_method "__class__", "class"
|
38
|
-
alias_method "__instance_eval__", "instance_eval"
|
39
|
-
instance_methods.each{|m| undef_method m unless m[%r/__/]}
|
40
|
-
def initialize obj
|
41
|
-
@obj = obj
|
42
|
-
end
|
43
|
-
def method_missing m, *a, &b
|
44
|
-
Pervasives.__send__ m, @obj, *a, &b
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
module Kernel
|
53
|
-
def __ obj, &b
|
54
|
-
proxy = Pervasives::Proxy.new obj
|
55
|
-
b ? proxy.__instance_eval__(&b) : proxy
|
56
|
-
end
|
57
|
-
def __! obj, &b
|
58
|
-
proxy = Pervasives::Proxy.new obj
|
59
|
-
b ? proxy.__instance_eval__(&b) : proxy
|
60
|
-
end
|
61
|
-
end
|