real 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.index ADDED
@@ -0,0 +1,56 @@
1
+ ---
2
+ type: ruby
3
+ revision: 2013
4
+ sources:
5
+ - var
6
+ authors:
7
+ - name: Thomas Sawyer
8
+ email: transfire@gmail.com
9
+ organizations: []
10
+ requirements:
11
+ - groups:
12
+ - build
13
+ development: true
14
+ name: detroit
15
+ - groups:
16
+ - test
17
+ development: true
18
+ name: qed
19
+ - groups:
20
+ - test
21
+ development: true
22
+ name: ae
23
+ conflicts: []
24
+ alternatives: []
25
+ resources:
26
+ - type: home
27
+ uri: http://rubyworks.github.com/real
28
+ label: Homepage
29
+ - type: docs
30
+ uri: http://rubydoc.info/gems/real
31
+ label: Documentation
32
+ - type: code
33
+ uri: http://github.com/rubyworks/real
34
+ label: Source Code
35
+ - type: mail
36
+ uri: http://groups.google.com/group/rubyworks-mailinglist
37
+ label: Mailing List
38
+ repositories:
39
+ - name: upstream
40
+ scm: git
41
+ uri: git://github.com/rubyworks/real.git
42
+ categories: []
43
+ load_path:
44
+ - lib
45
+ copyrights:
46
+ - holder: Thomas Sawyer, Rubyworks
47
+ year: '2009'
48
+ license: BSD-2-Clause
49
+ created: '2012-12-17'
50
+ summary: Real Reflections on Ruby Object
51
+ title: Real
52
+ version: 0.1.0
53
+ name: real
54
+ description: ! "Real makes true reflection possible for Ruby objects.\nThis can be
55
+ important to metaprogrammers who need to \nensure they have the true information."
56
+ date: '2012-12-17'
@@ -0,0 +1,7 @@
1
+ --title "Real Reflection API"
2
+ --protected
3
+ --private
4
+ lib/
5
+ -
6
+ [A-Z]*.*
7
+
@@ -0,0 +1,11 @@
1
+ # RELEASE HISTORY
2
+
3
+ ## 0.1.0 / 2012-12-17
4
+
5
+ First release of Real, a library to make object reflection dependable
6
+ as is possiblein pure Ruby.
7
+
8
+ Changes:
9
+
10
+ * Happy Release Day!!!
11
+
@@ -0,0 +1,22 @@
1
+ BSD-2-Clause License
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are
4
+ permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of
7
+ conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list
10
+ of conditions and the following disclaimer in the documentation and/or other materials
11
+ provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY Thomas Sawyer ``AS IS'' AND ANY EXPRESS OR IMPLIED
14
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
15
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Thomas Sawyer OR
16
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
18
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
21
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+
@@ -0,0 +1,49 @@
1
+ [![Build Status|align=right|float](https://secure.travis-ci.org/rubyworks/bang.png)](http://travis-ci.org/rubyworks/real)
2
+
3
+ [Homepage](http://rubyworks.github.com/real) |
4
+ [Support](http://github.com/rubyworks/real/issues) |
5
+ [Source Code](http://github.com/rubyworks/real)
6
+
7
+
8
+ # Real
9
+
10
+ There is a problem in the realm of Ruby metaprogramming --objects
11
+ can be liers. You see, there is no guaruntee that the return value of
12
+ a method is the "truth". Any object can play dirty tricks.
13
+
14
+ string = "Watch this..."
15
+
16
+ def string.class
17
+ nil
18
+ end
19
+
20
+ string.class #=> nil
21
+
22
+ We are never going to know what the *real* class of that object is
23
+ by asking it. So what can we do?
24
+
25
+ I've advocated for explict meta-programming methods be added to Ruby
26
+ for a long time. So far to no avail. Finally, I've decided I could
27
+ at least provide my own library that provides the functionality.
28
+
29
+ require 'real'
30
+
31
+ $real.class(string) #=> String
32
+
33
+
34
+ ### Installation
35
+
36
+ Putting the old RubyGems to work:
37
+
38
+ $ gem install real
39
+
40
+
41
+ ### Copyrights
42
+
43
+ Real is copyrighted open source software.
44
+
45
+ Copyright (c) 2012 Rubyworks (BSD-2-Clause)
46
+
47
+ You many redistribute or modify this work in accordance with the **BSD-2-Clause** license.
48
+
49
+ See LICENSE.txt for details.
@@ -0,0 +1,31 @@
1
+ # Real
2
+
3
+ ## Overview
4
+
5
+ There is a problem in the realm of Ruby metaprogramming --objects
6
+ can be liers. You see, there is no guaruntee that the return value of
7
+ a method is the "truth". Any object can play dirty tricks.
8
+
9
+ string = "Watch this..."
10
+
11
+ def string.class
12
+ nil
13
+ end
14
+
15
+ string.class #=> nil
16
+
17
+ We are never going to know what the *real* class of that object is
18
+ by asking it. So what can we do?
19
+
20
+ I've advocated for explict meta-programming methods be added to Ruby
21
+ for a long time. So far to no avail. Finally, I've decided I could
22
+ at least provide my own library that provides the functionality.
23
+
24
+ require 'real'
25
+
26
+ $real.class(string) #=> String
27
+
28
+ The use of global is just a reference to the `Real` module.
29
+
30
+ Real.class(string) #=> String
31
+
@@ -0,0 +1,109 @@
1
+ module Real
2
+ extend self
3
+
4
+ #####################
5
+ # Object Reflection #
6
+ #####################
7
+
8
+ # Get object's real id.
9
+ #
10
+ # @return [Integer]
11
+ def id(*a, &b)
12
+ bind_call(Object, :object_id, *a, &b)
13
+ end
14
+
15
+ # Get object's real class.
16
+ #
17
+ # @return [Class]
18
+ def class(*a, &b)
19
+ bind_call(Object, :class, *a, &b)
20
+ end
21
+
22
+ # Get object's real methods.
23
+ #
24
+ # @return [Array<Symbol>]
25
+ def methods(*a, &b)
26
+ bind_call(Object, :methods, *a, &b)
27
+ end
28
+
29
+ # Get object's real public methods.
30
+ #
31
+ # @return [Array<Symbol>]
32
+ def public_methods(*a, &b)
33
+ bind_call(Object, :public_methods, *a, &b)
34
+ end
35
+
36
+ # Get object's real protected methods.
37
+ #
38
+ # @return [Array<Symbol>]
39
+ def protected_methods(*a, &b)
40
+ bind_call(Object, :protected_methods, *a, &b)
41
+ end
42
+
43
+ # Get object's real private methods.
44
+ #
45
+ # @return [Array<Symbol>]
46
+ def private_methods(*a, &b)
47
+ bind_call(Object, :private_methods, *a, &b)
48
+ end
49
+
50
+ ###########################
51
+ # Class/Module Reflection #
52
+ ###########################
53
+
54
+ # Get class/module's real instance methods.
55
+ #
56
+ # @return [Array<Symbol>]
57
+ def instance_methods(*a, &b)
58
+ bind_call(Module, :instanance_methods, *a, &b)
59
+ end
60
+
61
+ # Get class/module's real public instance methods.
62
+ #
63
+ # @return [Array<Symbol>]
64
+ def public_instance_methods(*a, &b)
65
+ bind_call(Module, :public_instance_methods, *a, &b)
66
+ end
67
+
68
+ # Get class/module's real protected instance methods.
69
+ #
70
+ # @return [Array<Symbol>]
71
+ def protected_instance_methods(*a, &b)
72
+ bind_call(Module, :protected_instance_methods, *a, &b)
73
+ end
74
+
75
+ # Get class/module's real private instance methods.
76
+ #
77
+ # @return [Array<Symbol>]
78
+ def private_instance_methods(*a, &b)
79
+ bind_call(Module, :private_instance_methods, :class, *a, &b)
80
+ end
81
+
82
+ private
83
+
84
+ def bind_call(c, m, o, *a, &b)
85
+ im = c.instance_method(m)
86
+ im.bind(o).call(*a, &b)
87
+ end
88
+
89
+ #
90
+ # Access to project metadata, e.g. VERSION.
91
+ #
92
+ def self.const_missing(const_name)
93
+ name = const_name.to_s.downcase
94
+ index[name] || super(const_name)
95
+ end
96
+
97
+ #
98
+ # Load project metadata file.
99
+ #
100
+ def self.index
101
+ @index ||= (
102
+ require 'yaml'
103
+ YAML.load_file(File.join(File.dirname(__FILE__), 'real.yml'))
104
+ )
105
+ end
106
+ end
107
+
108
+ $real = Real
109
+
@@ -0,0 +1,56 @@
1
+ ---
2
+ type: ruby
3
+ revision: 2013
4
+ sources:
5
+ - var
6
+ authors:
7
+ - name: Thomas Sawyer
8
+ email: transfire@gmail.com
9
+ organizations: []
10
+ requirements:
11
+ - groups:
12
+ - build
13
+ development: true
14
+ name: detroit
15
+ - groups:
16
+ - test
17
+ development: true
18
+ name: qed
19
+ - groups:
20
+ - test
21
+ development: true
22
+ name: ae
23
+ conflicts: []
24
+ alternatives: []
25
+ resources:
26
+ - type: home
27
+ uri: http://rubyworks.github.com/real
28
+ label: Homepage
29
+ - type: docs
30
+ uri: http://rubydoc.info/gems/real
31
+ label: Documentation
32
+ - type: code
33
+ uri: http://github.com/rubyworks/real
34
+ label: Source Code
35
+ - type: mail
36
+ uri: http://groups.google.com/group/rubyworks-mailinglist
37
+ label: Mailing List
38
+ repositories:
39
+ - name: upstream
40
+ scm: git
41
+ uri: git://github.com/rubyworks/real.git
42
+ categories: []
43
+ load_path:
44
+ - lib
45
+ copyrights:
46
+ - holder: Thomas Sawyer, Rubyworks
47
+ year: '2009'
48
+ license: BSD-2-Clause
49
+ created: '2012-12-17'
50
+ summary: Real Reflections on Ruby Object
51
+ title: Real
52
+ version: 0.1.0
53
+ name: real
54
+ description: ! "Real makes true reflection possible for Ruby objects.\nThis can be
55
+ important to metaprogrammers who need to \nensure they have the true information."
56
+ date: '2012-12-17'
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: real
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Thomas Sawyer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: detroit
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: qed
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: ae
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: ! "Real makes true reflection possible for Ruby objects.\nThis can be
63
+ important to metaprogrammers who need to \nensure they have the true information."
64
+ email:
65
+ - transfire@gmail.com
66
+ executables: []
67
+ extensions: []
68
+ extra_rdoc_files:
69
+ - LICENSE.txt
70
+ - HISTORY.md
71
+ - README.md
72
+ files:
73
+ - .index
74
+ - .yardopts
75
+ - demo/01_overview.md
76
+ - lib/real.rb
77
+ - lib/real.yml
78
+ - LICENSE.txt
79
+ - HISTORY.md
80
+ - README.md
81
+ homepage: http://rubyworks.github.com/real
82
+ licenses:
83
+ - BSD-2-Clause
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 1.8.23
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Real Reflections on Ruby Object
106
+ test_files: []