kantox-chronoscope 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kantox/chronoscope/version.rb +1 -1
- data/lib/kantox/chronoscope.rb +22 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef693fb21afdd2a78339e0e3ac653c63fd76c65f
|
4
|
+
data.tar.gz: e751ff04f72ec5e66d42c01181d080a821c74427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16c1a45ce1e2a6d8d68a2852fd0fc3cda3061d1dbff73217b69ad0fcc39ee7104b62ab32f9e28d984a6c6be8cfdf3c0bff4fca2e4009bad7246d6b8dd5e86985
|
7
|
+
data.tar.gz: 9e3d3bbc2d9659093f78f71950eaa467be62add8a49a2df8eaa63d47f394886d9132d2be86acec12420ce32efb993c27b6544d90fc95edb06ebeb4e641da9603
|
data/lib/kantox/chronoscope.rb
CHANGED
@@ -46,9 +46,10 @@ module Kantox
|
|
46
46
|
# `methods` parameter accepts:
|
47
47
|
# none for all instance methods
|
48
48
|
# :method for explicit method
|
49
|
-
def attach(klazz, *methods)
|
49
|
+
def attach(klazz, *methods, cms: nil)
|
50
50
|
klazz = Kernel.const_get(klazz) unless klazz.is_a?(Class)
|
51
51
|
methods = klazz.instance_methods(false) if methods.empty?
|
52
|
+
do_log = !option(ENV, 'options.silent')
|
52
53
|
|
53
54
|
methods.each do |m|
|
54
55
|
next if m.to_s =~ /\A#{CHAIN_PREFIX}/ # skip wrappers
|
@@ -56,7 +57,6 @@ module Kantox
|
|
56
57
|
next if (klazz.instance_method(m).parameters.to_h[:block] rescue false) # FIXME: report
|
57
58
|
|
58
59
|
receiver, arg_string = m.to_s.end_with?('=') ? ['self.', 'arg'] : [nil, '*args'] # to satisfy setter
|
59
|
-
do_log = !option(ENV, 'options.silent')
|
60
60
|
|
61
61
|
klazz.class_eval %Q|
|
62
62
|
alias_method :'#{CHAIN_PREFIX}#{m}', :'#{m}'
|
@@ -65,6 +65,26 @@ module Kantox
|
|
65
65
|
end
|
66
66
|
|
|
67
67
|
end
|
68
|
+
|
69
|
+
# class methods now
|
70
|
+
return unless cms
|
71
|
+
cms = [*cms]
|
72
|
+
cms = klazz.methods(false) if cms.empty?
|
73
|
+
cms.each do |m|
|
74
|
+
next if m.to_s =~ /\A#{CHAIN_PREFIX}/ # skip wrappers
|
75
|
+
next if methods.include?("#{CHAIN_PREFIX}#{m}".to_sym) # skip already wrapped functions
|
76
|
+
next if (klazz.instance_method(m).parameters.to_h[:block] rescue false) # FIXME: report
|
77
|
+
|
78
|
+
klazz.class_eval %Q|
|
79
|
+
class << self
|
80
|
+
alias_method :'#{CHAIN_PREFIX}#{m}', :'#{m}'
|
81
|
+
def #{m}(*args)
|
82
|
+
⌚('#{klazz}::#{m}', #{do_log}) { #{klazz}.#{CHAIN_PREFIX}#{m} *args }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
|
86
|
+
end
|
87
|
+
|
68
88
|
rescue NameError
|
69
89
|
Generic::LOGGER.debug [
|
70
90
|
" #{Generic::COLOR_WARN}[#{Generic::LOGGER_TAG}] ERROR#{Generic::COLOR_NONE} #{Generic::BM_DELIMITER} “#{Generic::COLOR_WARN}#{e.message}#{Generic::COLOR_NONE}”",
|