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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc40deadd4e5c6c0331f2a0cec0377451c90521c
4
- data.tar.gz: f50279d201ea4b3e557540208fff7184fe7f57b1
3
+ metadata.gz: ef693fb21afdd2a78339e0e3ac653c63fd76c65f
4
+ data.tar.gz: e751ff04f72ec5e66d42c01181d080a821c74427
5
5
  SHA512:
6
- metadata.gz: 7aedb9089e33bfc2f44685980561d9c28e32104c52bf9f5162fec51ad0720c77f2dbe4f76cb9fb33984e69df5d6b5f6c1a5cbb1834677469e7c2ab35ed233b9e
7
- data.tar.gz: be4f4d6b28574a2d524a791a0ad6485f9a7922a61f53de3fa3a2ae025600ccb2ac6454b8fd4cf8f102f0476439d2770e83926c8019588c53cdf84b3988c87acf
6
+ metadata.gz: 16c1a45ce1e2a6d8d68a2852fd0fc3cda3061d1dbff73217b69ad0fcc39ee7104b62ab32f9e28d984a6c6be8cfdf3c0bff4fca2e4009bad7246d6b8dd5e86985
7
+ data.tar.gz: 9e3d3bbc2d9659093f78f71950eaa467be62add8a49a2df8eaa63d47f394886d9132d2be86acec12420ce32efb993c27b6544d90fc95edb06ebeb4e641da9603
@@ -1,5 +1,5 @@
1
1
  module Kantox
2
2
  module Chronoscope
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
5
5
  end
@@ -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}”",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kantox-chronoscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kantox