domesticate_monkeys 0.0.3 → 0.0.4

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f902eff70d48a89d2483cf1f41381dfab4fc139a729e492006ba34ed1ea14ff
4
- data.tar.gz: 8a638249a12af0b8719c4ca175c4b636b996935ae5e46ac56999def8d07cac11
3
+ metadata.gz: a51442a6e936ba6fab104101071df5308e93da83c4382e745531ea552220d999
4
+ data.tar.gz: 18851cbc055822ca541ca188925df2979475f9afc4a76264b9e18a6a9650263c
5
5
  SHA512:
6
- metadata.gz: 83416e748a909aa85cb993f7255224eb662bda9c910068dcc0ad4183f54d8977b6b20d55476814257a0f5287035710f921395f1e5f2cd914f2a6a7bf4f4ab124
7
- data.tar.gz: 0dbbc129cd9b32ca6a5d55c0e0a03a98a4b56c7e4a2b9b41c050d9d170e723c898207d6c832f9d45c6913479a2953f7b113c515ef70bde40869507fea00b1adc
6
+ metadata.gz: 6eb06a87b50d24b65aacfba77b94c8ce262e3f1f0104cc5babe42017fe49764482f4ca4d3f77056a8dd72b114bedb748491ba4106c976dc54751fed35b825c75
7
+ data.tar.gz: 2b1cccbd6f2c7f6bb7dffcc14e94b775a8137d3870818b0082850605491c8a049d587a7dff3d3392941abee6becb6b3975f0461e86bf2858f07280e552be7dc0
@@ -15,10 +15,12 @@ module DomesticateMonkeys
15
15
 
16
16
  class << self
17
17
 
18
- def add(unbound_method)
19
-
20
- name = format_method_name(unbound_method)
18
+ def add(unbound_method, method_type)
19
+
20
+ name = format_method_name(unbound_method, method_type)
21
21
  source = read_method_source(unbound_method)
22
+
23
+ puts "name=#{name}, source=#{source}" unless name && source
22
24
  return unless name && source
23
25
 
24
26
  # Find the existing track for the given method, or create a new track
@@ -37,28 +39,22 @@ module DomesticateMonkeys
37
39
  return
38
40
  end
39
41
 
40
- def format_method_name(unbound_method)
41
-
42
- # The formatted method name serves as the uniquely identifying key for
43
- # all operations, with a distinguishing '#' for instance methods and a
44
- # '.' for singleton methods.
45
-
42
+ def format_method_name(unbound_method, method_type)
46
43
  name = unbound_method.to_s
47
44
 
48
- return format_instance_method(name) if name.include?('UnboundMethod')
49
- return format_singleton_method(name) if name.include?('Method')
45
+ return format_instance_method(name) if method_type == :instance
46
+ return format_singleton_method(name) if method_type == :singleton
50
47
  end
51
48
 
52
- def format_instance_method(name)
53
- name.slice(/(?<=#<UnboundMethod: )[^(]*/)
54
- .gsub(/\(.*\)/,'')
55
- .delete('>')
49
+ def format_instance_method(name)
50
+ regex = /.*?<UnboundMethod: ([a-zA-Z:_]{1,}).*(?>([#]))([#.a-zA-Z_?]{1,})/
51
+ name.scan(regex).flatten.join
56
52
  end
57
53
 
58
54
  def format_singleton_method(name)
59
- name.slice(/(?<=#<Method: )[^(]*/)
60
- .gsub(/\(.*\)/,'')
61
- .delete('>')
55
+ # regex = /.*?<Method:[^a-zA-Z:]{0,}([a-zA-Z:]{1,})[>]{0,1}([a-zA-Z_.]{1,})/
56
+ regex = /.*?<Method:[^a-zA-Z:]{0,}([a-zA-Z:]{1,})[^\.]*([.A-Za-z_]{1,})/
57
+ name.scan(regex).flatten.join
62
58
  end
63
59
 
64
60
  def read_method_source(unbound_method)
@@ -40,7 +40,7 @@ module DomesticateMonkeys
40
40
 
41
41
  def filter_tracks_by_path(tracks, path_filter)
42
42
  tracks.select do |_method, track|
43
- track.sources.any? { |source| source.snakecase.include?(path_filter.snakecase) }
43
+ track.sources.any? { |source| source.snakecase.include?(path_filter.snakecase) && source.exclude?("/vendor/") }
44
44
  end
45
45
  end
46
46
 
@@ -1,3 +1,4 @@
1
+ require "pry"
1
2
 
2
3
  class Module
3
4
 
@@ -16,13 +17,13 @@ class Module
16
17
  # orignal definition.
17
18
 
18
19
  def method_added(_method)
19
- unbound_method = instance_method(_method)
20
- DomesticateMonkeys::Track.add(unbound_method)
20
+ unbound_method = self.instance_method(_method)
21
+ DomesticateMonkeys::Track.add(unbound_method, :instance)
21
22
  end
22
23
 
23
24
  def self.singleton_method_added(_method)
24
- unbound_method = singleton_method(_method)
25
- DomesticateMonkeys::Track.add(unbound_method)
25
+ unbound_method = self.method(_method)
26
+ DomesticateMonkeys::Track.add(unbound_method, :singleton)
26
27
  end
27
28
 
28
29
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module DomesticateMonkeys
3
3
 
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
 
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domesticate_monkeys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurriaan Schrofer