overrides_tracker 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/overrides_tracker +1 -0
- data/lib/overrides_tracker/api.rb +2 -2
- data/lib/overrides_tracker/methods_collector.rb +29 -13
- data/lib/overrides_tracker/version.rb +1 -1
- data/lib/overrides_tracker.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 697c58a5a0c9db02845d9812170b02f2a9dc9415db401db25edab2693476c639
|
4
|
+
data.tar.gz: d8962351ec1438b7d1a550fb0622b66e4d03e9e598cd8e704f25e3614d4f7dcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f88b7b5eeeb80b6ac306908b5e810d0c17cef5573da16a778c361594e18f7fb6cb2e6c1a7a9121d4279dfc5e9596b6958d297c22b15ef0f83a486718697cc480
|
7
|
+
data.tar.gz: 5b469f55caed226a3deca1fd93a9a7e3b15e8d4a5e0fdf1f6bba128850c40740a1e72a488a7d31868ed8ad92aa0261aaabd19ee4df997fe00cb1c76c8a3e85db
|
data/bin/overrides_tracker
CHANGED
@@ -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 =
|
7
|
-
API_PROTOCOL =
|
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"
|
@@ -36,6 +36,7 @@ class OverridesTracker::MethodsCollector
|
|
36
36
|
@overridden_methods_collection[class_name][method_type][method_name] = @methods_collection[class_name][method_type][method_name]
|
37
37
|
@overridden_methods_collection[class_name][method_type][method_name][:overriding_location] = overriding_method.source_location
|
38
38
|
@overridden_methods_collection[class_name][method_type][method_name][:overriding_body] = method_hash[:body]
|
39
|
+
@overridden_methods_collection[class_name][method_type][method_name][:overriding_sha] = method_hash[:sha]
|
39
40
|
end
|
40
41
|
|
41
42
|
def mark_method_as_added_instance(class_name, method_name, overriding_method, method_hash)
|
@@ -56,34 +57,49 @@ class OverridesTracker::MethodsCollector
|
|
56
57
|
methods = []
|
57
58
|
if methods_type == :instance_methods
|
58
59
|
methods = clazz.instance_methods(false)
|
60
|
+
clazz.ancestors.each do |ancestor|
|
61
|
+
if ancestor.class == Class
|
62
|
+
break
|
63
|
+
end
|
64
|
+
methods = methods + ancestor.instance_methods(false)
|
65
|
+
end
|
59
66
|
else
|
60
67
|
methods = clazz.singleton_methods(false)
|
68
|
+
clazz.ancestors.each do |ancestor|
|
69
|
+
if ancestor.class == Class
|
70
|
+
break
|
71
|
+
end
|
72
|
+
methods = methods + ancestor.singleton_methods(false)
|
73
|
+
end
|
61
74
|
end
|
62
75
|
|
63
76
|
methods.each do |method_name|
|
64
|
-
if method_name != nil
|
77
|
+
if method_name != nil && method_name != :overrides_tracker_finished_file
|
65
78
|
method_hash = class_methods[methods_type][method_name]
|
79
|
+
begin
|
80
|
+
if methods_type == :instance_methods
|
81
|
+
method_to_check = clazz.instance_method(method_name)
|
82
|
+
else
|
83
|
+
method_to_check = clazz.singleton_method(method_name)
|
84
|
+
end
|
66
85
|
|
67
|
-
|
68
|
-
|
69
|
-
|
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)
|
86
|
+
method_to_check_hash = OverridesTracker::Util.method_hash(method_to_check)
|
87
|
+
|
88
|
+
if method_to_check_hash[:location] != nil
|
77
89
|
if method_hash != nil
|
78
90
|
if method_to_check_hash[:location] != method_hash[:location]
|
79
91
|
mark_method_as_override(methods_type, clazz.name, method_name, method_to_check, method_to_check_hash)
|
80
92
|
puts "#{method_name} of class #{clazz.name} was overridden".green
|
81
93
|
end
|
82
94
|
else
|
83
|
-
|
84
|
-
|
95
|
+
if (method_to_check_hash[:location][0].include? working_directory)
|
96
|
+
mark_method_as_added("added_#{methods_type}".to_sym, clazz.name, method_name, method_to_check, method_to_check_hash)
|
97
|
+
puts "#{method_name} of class #{clazz.name} was added".green
|
98
|
+
end
|
85
99
|
end
|
86
100
|
end
|
101
|
+
rescue Exception => e
|
102
|
+
#puts "Error processing #{method_name} of class #{clazz.name}".red
|
87
103
|
end
|
88
104
|
end
|
89
105
|
end
|
data/lib/overrides_tracker.rb
CHANGED
@@ -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
|
-
|
46
|
-
|
47
|
-
|
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.
|
4
|
+
version: 0.1.7
|
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-
|
11
|
+
date: 2022-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: method_source
|