procemon 0.6.2 → 0.6.3
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.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjZiMzE0OGY4ZWYzZGU5NmRlYTQxNWM0YTk5NjhiZGNjYjhlZjAzNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzQ0YWRkMDhkN2YzZmRiYzk0MTdiNDdlMWMwZTlkYzU5OTBkZTI1OQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjBmMGZkOTQ1NWNkMWU2MjgyMjM4NTJjNjA0MmNlOTVmZjFjMDQ3NDNiNjc3
|
10
|
+
YWY1Njc4Nzc4YjY1N2M4OTcyOGZjNTZiYTg4ODc5ZTk4M2E1MmU2ZWJkZWVj
|
11
|
+
MzQxNTQ1M2RhNThhNzg3YjI3ZmMxMmQwN2MxODdlY2MzYjllN2U=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODlhNzY0ZDc2MzJkN2FkYTg1YzAxMDg5ZDYwMDAyMjJlNDZlMzBlNzJlZjAz
|
14
|
+
OWRhNDJiZjMzZGEyYzg4M2Q3N2U5ZGVlYjdkYTllOWFhMWYyZThjODgzZjEw
|
15
|
+
ZWJmNDA0MDM4ODA0ZDc0YzUyY2JhNjFjOTNmMTczMmJmYzE5ZWY=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.3
|
@@ -6,28 +6,27 @@ class TestT
|
|
6
6
|
puts self
|
7
7
|
end
|
8
8
|
|
9
|
-
def test
|
10
|
-
puts self
|
9
|
+
def test string
|
10
|
+
puts self,string
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
14
14
|
|
15
|
-
TestT.inject_instance_method :test do
|
15
|
+
TestT.inject_instance_method :test do |str|
|
16
16
|
|
17
|
-
puts "hello world! instance"
|
17
|
+
puts "hello world! instance "+str
|
18
18
|
|
19
19
|
end
|
20
20
|
|
21
|
-
TestT.inject_singleton_method :test,
|
22
|
-
|
21
|
+
TestT.inject_singleton_method :test, add: "after" do
|
23
22
|
puts "hello world! singleton"
|
24
|
-
|
25
23
|
end
|
26
24
|
|
27
|
-
puts "
|
25
|
+
puts "---\nafter,singleton case:"
|
28
26
|
TestT.test
|
29
|
-
|
30
|
-
|
27
|
+
|
28
|
+
puts "---\nbefore,instance case:"
|
29
|
+
TestT.new.test "boogie man"
|
31
30
|
|
32
31
|
|
33
32
|
#after,singleton case:
|
@@ -1,10 +1,9 @@
|
|
1
|
-
|
1
|
+
module InjectMethods
|
2
2
|
|
3
3
|
# this will inject a code block to a target instance method
|
4
4
|
# by default the before or after sym is not required
|
5
5
|
#
|
6
6
|
# options can be:
|
7
|
-
# - params: "merged" -> if given than the block params and the original method params will be merged
|
8
7
|
# - add: 'before'/'after' add your code into method before the original part of after
|
9
8
|
#
|
10
9
|
# Test.inject_singleton_method :hello do |*args|
|
@@ -16,12 +15,21 @@ class Class
|
|
16
15
|
original_method= self.method(method).clone
|
17
16
|
self.singleton_class.__send__ :undef_method, method
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
# source code
|
19
|
+
begin
|
20
|
+
sources= nil
|
21
|
+
case options[:add].to_s.downcase[0]
|
22
|
+
when "a"
|
23
|
+
sources= [original_method.to_proc,block]
|
24
|
+
else
|
25
|
+
sources= [block,original_method.to_proc]
|
26
|
+
end
|
27
|
+
end
|
22
28
|
|
23
29
|
self.define_singleton_method method do |*arguments|
|
24
|
-
|
30
|
+
sources.each do |proc|
|
31
|
+
proc.call_with_binding(original_method.binding?,*arguments)
|
32
|
+
end
|
25
33
|
end
|
26
34
|
|
27
35
|
return nil
|
@@ -32,7 +40,6 @@ class Class
|
|
32
40
|
# by default the before or after sym is not required
|
33
41
|
#
|
34
42
|
# options can be:
|
35
|
-
# - params: "merged" -> if given than the block params and the original method params will be merged
|
36
43
|
# - add: 'before'/'after' add your code into method before the original part of after
|
37
44
|
#
|
38
45
|
# Test.inject_instance_method :hello, params: "merged" do |*args|
|
@@ -41,57 +48,40 @@ class Class
|
|
41
48
|
#
|
42
49
|
def inject_instance_method(method,options={},&block)
|
43
50
|
|
44
|
-
|
45
|
-
|
46
|
-
source_code= InjectMethodHelper.generate_source(
|
47
|
-
block,original_method,options
|
48
|
-
)
|
51
|
+
unbound_method= self.instance_method(method).clone
|
49
52
|
|
50
53
|
self.class_eval do
|
51
54
|
undef_method method
|
52
55
|
define_method(
|
53
|
-
|
54
|
-
|
56
|
+
method,
|
57
|
+
Proc.new { |*args|
|
58
|
+
|
59
|
+
begin
|
60
|
+
case options[:add].to_s.downcase[0]
|
61
|
+
when "a"
|
62
|
+
unbound_method.bind(self).call(*args)
|
63
|
+
block.call_with_binding(self.binding?,*args)
|
64
|
+
|
65
|
+
else
|
66
|
+
block.call_with_binding(self.binding?,*args)
|
67
|
+
unbound_method.bind(self).call(*args)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
}
|
55
72
|
)
|
56
73
|
end
|
57
74
|
|
58
75
|
end
|
59
|
-
|
60
76
|
alias :extend_instance_method :inject_instance_method
|
61
77
|
|
62
78
|
end
|
63
79
|
|
64
|
-
module InjectMethodHelper
|
65
|
-
|
66
|
-
def self.generate_source block,original_method,options
|
67
|
-
|
68
|
-
# source code
|
69
|
-
begin
|
70
|
-
source_code= nil
|
71
|
-
case options[:add].to_s.downcase[0]
|
72
|
-
when "a"
|
73
|
-
source_code= original_method.source.body+block.source.body
|
74
|
-
else
|
75
|
-
source_code= block.source.body+original_method.source.body
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# params
|
80
|
-
begin
|
81
|
-
source_params= nil
|
82
|
-
case options[:params].to_s.downcase[0]
|
83
|
-
when "m"
|
84
|
-
begin
|
85
|
-
source_params= (block.source.params+original_method.source.params)
|
86
|
-
end
|
87
|
-
else
|
88
|
-
begin
|
89
|
-
source_params= original_method.source.params
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
80
|
|
94
|
-
|
95
|
-
|
81
|
+
class Module
|
82
|
+
include InjectMethods
|
83
|
+
end
|
96
84
|
|
85
|
+
class Class
|
86
|
+
include InjectMethods
|
97
87
|
end
|
@@ -15,7 +15,7 @@ module MethodToProcSource
|
|
15
15
|
else
|
16
16
|
|
17
17
|
if self.source_location.nil?
|
18
|
-
return
|
18
|
+
return nil
|
19
19
|
end
|
20
20
|
|
21
21
|
File.open(File.expand_path(self.source_location[0])
|
@@ -38,7 +38,8 @@ module MethodToProcSource
|
|
38
38
|
return_string.sub!(args_to_replace,"|#{args_to_replace}|")
|
39
39
|
end
|
40
40
|
|
41
|
-
rescue TypeError,
|
41
|
+
rescue TypeError,NoMethodError
|
42
|
+
return nil
|
42
43
|
end
|
43
44
|
|
44
45
|
return_string.sub!(/\s*\bdef\s*[\w\S]*/,'Proc.new{')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: procemon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asynchronous
|