ruby_patch 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,23 +1,22 @@
|
|
1
1
|
class Module
|
2
|
-
UnintendedOverrideError = Class.new(StandardError)
|
3
2
|
|
4
3
|
private
|
5
4
|
|
6
5
|
def new_methods(*names)
|
7
6
|
unless (buf = names.select{|m| instance_methods.include?(m)}).empty?
|
8
|
-
raise UnintendedOverrideError, "Unintended public/protected method(s) override: #{buf.join(' ')}"
|
7
|
+
raise ::RubyPatch::CoreExt::UnintendedOverrideError, "Unintended public/protected method(s) override: #{buf.join(' ')}"
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
12
11
|
def new_private_methods(*names)
|
13
12
|
unless (buf = names.select{|m| private_instance_methods.include?(m)}).empty?
|
14
|
-
raise UnintendedOverrideError, "Unintended private method(s) override: #{buf.join(' ')}"
|
13
|
+
raise ::RubyPatch::CoreExt::UnintendedOverrideError, "Unintended private method(s) override: #{buf.join(' ')}"
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
18
17
|
def new_singleton_methods(*names)
|
19
18
|
unless (buf = names.select{|m| singleton_methods.include?(m)}).empty?
|
20
|
-
raise UnintendedOverrideError, "Unintended singleton method(s) override: #{buf.join(' ')}"
|
19
|
+
raise ::RubyPatch::CoreExt::UnintendedOverrideError, "Unintended singleton method(s) override: #{buf.join(' ')}"
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Object
|
2
2
|
new_methods :exception?, :deep_clone
|
3
|
-
new_private_methods :parse_caller, :__DIR__, :__METHOD__, :check_type
|
3
|
+
new_private_methods :parse_caller, :called_from, :__DIR__, :__METHOD__, :check_type
|
4
4
|
|
5
5
|
def exception?()
|
6
6
|
self.class.posterity_of?(Exception)
|
@@ -27,14 +27,18 @@ class Object
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
# @return [Hash] Information about where called from.
|
31
|
+
def called_from
|
32
|
+
parse_caller(caller(2).first)
|
33
|
+
end
|
34
|
+
|
30
35
|
def __DIR__()
|
31
|
-
|
32
|
-
dir = File.dirname(called_from)
|
36
|
+
dir = File.dirname(called_from[:file])
|
33
37
|
File.expand_path(dir)
|
34
38
|
end
|
35
39
|
|
36
40
|
def __METHOD__()
|
37
|
-
|
41
|
+
called_from[:method]
|
38
42
|
end
|
39
43
|
|
40
44
|
# Check type of var.
|
data/lib/ruby_patch/core_ext.rb
CHANGED
data/lib/ruby_patch/version.rb
CHANGED
@@ -34,7 +34,7 @@ describe ::Module do
|
|
34
34
|
class DummyClass1
|
35
35
|
new_methods :public_c1
|
36
36
|
end
|
37
|
-
}.should raise_error ::
|
37
|
+
}.should raise_error ::RubyPatch::CoreExt::UnintendedOverrideError
|
38
38
|
end
|
39
39
|
|
40
40
|
it do
|
@@ -52,7 +52,7 @@ describe ::Module do
|
|
52
52
|
class DummyClass1
|
53
53
|
new_private_methods :private_c1
|
54
54
|
end
|
55
|
-
}.should raise_error ::
|
55
|
+
}.should raise_error ::RubyPatch::CoreExt::UnintendedOverrideError
|
56
56
|
end
|
57
57
|
|
58
58
|
it do
|
@@ -70,7 +70,7 @@ describe ::Module do
|
|
70
70
|
class DummyClass1
|
71
71
|
new_singleton_methods :single_c1
|
72
72
|
end
|
73
|
-
}.should raise_error ::
|
73
|
+
}.should raise_error ::RubyPatch::CoreExt::UnintendedOverrideError
|
74
74
|
end
|
75
75
|
|
76
76
|
it do
|
@@ -89,7 +89,7 @@ describe ::Module do
|
|
89
89
|
module DummyModule1
|
90
90
|
new_private_methods :function_m1
|
91
91
|
end
|
92
|
-
}.should raise_error ::
|
92
|
+
}.should raise_error ::RubyPatch::CoreExt::UnintendedOverrideError
|
93
93
|
end
|
94
94
|
|
95
95
|
it do
|
@@ -107,7 +107,7 @@ describe ::Module do
|
|
107
107
|
module DummyModule1
|
108
108
|
new_singleton_methods :function_m1
|
109
109
|
end
|
110
|
-
}.should raise_error ::
|
110
|
+
}.should raise_error ::RubyPatch::CoreExt::UnintendedOverrideError
|
111
111
|
end
|
112
112
|
|
113
113
|
it do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_patch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157105620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.10'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2157105620
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: simplecov
|
27
|
-
requirement: &
|
27
|
+
requirement: &2157104840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0.6'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2157104840
|
36
36
|
description: Monkey patches used by kshramt's libraries.
|
37
37
|
email:
|
38
38
|
executables: []
|