overrides_tracker 0.1.5 → 0.1.6

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
  SHA256:
3
- metadata.gz: 52e9e378077f48a8e7c3aa3d66c8263b0a382c880d6c9a4138ab43b3aa1258bc
4
- data.tar.gz: 9cc7d37a44eb61ef618dd90f1fe623c3e571760d3ace0af4f7f3a496dd79b196
3
+ metadata.gz: a349cfc8219a5e3c54b7fcf01e4c8bcb826ececedb3fa81e1b0a3217cbdc7cc4
4
+ data.tar.gz: 6a602b0a8a08c566f461c8246858d2bf2204a672cff70db325bee4984906215a
5
5
  SHA512:
6
- metadata.gz: 0bde076e4319f7a6a7f3abb5f1f2b850e28bbdc2fa99839e7b34dc4670db06d80f5669747da423e97fa62c20d28fe1778f29a0252219edd0a3b44a2a11f43eb4
7
- data.tar.gz: cf8043ee35322037a673915b51241a2d7ec6f3ac4dafbeaca97700b8e2c24bcd8dd1a5e148d68eb0e0a7a243f990706cba027643afe01ee49a25960dc5650501
6
+ metadata.gz: d43eb13bca15ad87a32c47183090a70a23d93d33fd6717f78c1c4c668a1a9c3254fec879771ddc15ab33a782ce03f716d949efbfc8dd9245ba92c2bd722ccac8
7
+ data.tar.gz: db00cf8aed2a4a65b4536be2e7a075488db611b551f877f40682089e6ac13e390f4aeeae276f2ec01b5598974c219b0f09716398c48054ed5d52b26d5e83dae1
@@ -5,6 +5,7 @@ if ARGV[0] == "track"
5
5
  OVERRIDES_TRACKER_TRACKING_ENABLED = true
6
6
  require Dir.pwd+'/config/environment.rb'
7
7
  require 'overrides_tracker'
8
+
8
9
  OverridesTracker::MethodsCollector.instance.build_overrides_hash
9
10
  OverridesTracker::MethodsCollector.instance.save_to_file
10
11
 
@@ -3,8 +3,8 @@ require 'net/https'
3
3
 
4
4
  class OverridesTracker::Api
5
5
 
6
- API_HOST = false ? "localhost:3000" : "overrides.io"
7
- API_PROTOCOL = false ? "http" : "https"
6
+ API_HOST = ENV['OVERRIDES_TRACKER_DEVELOPMENT'] ? "localhost:3000" : "overrides.io"
7
+ API_PROTOCOL = ENV['OVERRIDES_TRACKER_DEVELOPMENT'] ? "http" : "https"
8
8
  API_DOMAIN = "#{API_PROTOCOL}://#{API_HOST}"
9
9
 
10
10
  API_BASE = "#{API_DOMAIN}/api/v1"
@@ -56,34 +56,49 @@ class OverridesTracker::MethodsCollector
56
56
  methods = []
57
57
  if methods_type == :instance_methods
58
58
  methods = clazz.instance_methods(false)
59
+ clazz.ancestors.each do |ancestor|
60
+ if ancestor.class == Class
61
+ break
62
+ end
63
+ methods = methods + ancestor.instance_methods(false)
64
+ end
59
65
  else
60
66
  methods = clazz.singleton_methods(false)
67
+ clazz.ancestors.each do |ancestor|
68
+ if ancestor.class == Class
69
+ break
70
+ end
71
+ methods = methods + ancestor.singleton_methods(false)
72
+ end
61
73
  end
62
74
 
63
75
  methods.each do |method_name|
64
- if method_name != nil
76
+ if method_name != nil && method_name != :overrides_tracker_finished_file
65
77
  method_hash = class_methods[methods_type][method_name]
78
+ begin
79
+ if methods_type == :instance_methods
80
+ method_to_check = clazz.instance_method(method_name)
81
+ else
82
+ method_to_check = clazz.singleton_method(method_name)
83
+ end
66
84
 
67
- if methods_type == :instance_methods
68
- method_to_check = clazz.instance_method(method_name)
69
- else
70
- method_to_check = clazz.singleton_method(method_name)
71
- end
72
-
73
- method_to_check_hash = OverridesTracker::Util.method_hash(method_to_check)
74
-
75
- if method_to_check_hash[:location] != nil
76
- if (method_to_check_hash[:location][0].include? working_directory)
85
+ method_to_check_hash = OverridesTracker::Util.method_hash(method_to_check)
86
+
87
+ if method_to_check_hash[:location] != nil
77
88
  if method_hash != nil
78
89
  if method_to_check_hash[:location] != method_hash[:location]
79
90
  mark_method_as_override(methods_type, clazz.name, method_name, method_to_check, method_to_check_hash)
80
91
  puts "#{method_name} of class #{clazz.name} was overridden".green
81
92
  end
82
93
  else
83
- mark_method_as_added("added_#{methods_type}".to_sym, clazz.name, method_name, method_to_check, method_to_check_hash)
84
- puts "#{method_name} of class #{clazz.name} was added".green
94
+ if (method_to_check_hash[:location][0].include? working_directory)
95
+ mark_method_as_added("added_#{methods_type}".to_sym, clazz.name, method_name, method_to_check, method_to_check_hash)
96
+ puts "#{method_name} of class #{clazz.name} was added".green
97
+ end
85
98
  end
86
99
  end
100
+ rescue Exception => e
101
+ #puts "Error processing #{method_name} of class #{clazz.name}".red
87
102
  end
88
103
  end
89
104
  end
@@ -1,3 +1,3 @@
1
1
  module OverridesTracker
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -42,9 +42,11 @@ if defined? OVERRIDES_TRACKER_TRACKING_ENABLED
42
42
 
43
43
  single_methods = clazz.singleton_methods(false)
44
44
  single_methods.each do |single_method|
45
- method = clazz.singleton_method(single_method)
46
- method_hash = OverridesTracker::Util.method_hash(method)
47
- OverridesTracker::MethodsCollector.instance.add_singleton_method_for_class(clazz.name, single_method, method_hash)
45
+ if single_method != :overrides_tracker_finished_file
46
+ method = clazz.singleton_method(single_method)
47
+ method_hash = OverridesTracker::Util.method_hash(method)
48
+ OverridesTracker::MethodsCollector.instance.add_singleton_method_for_class(clazz.name, single_method, method_hash)
49
+ end
48
50
  end
49
51
  end
50
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overrides_tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Meyborg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-06 00:00:00.000000000 Z
11
+ date: 2022-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: method_source