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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52e9e378077f48a8e7c3aa3d66c8263b0a382c880d6c9a4138ab43b3aa1258bc
4
- data.tar.gz: 9cc7d37a44eb61ef618dd90f1fe623c3e571760d3ace0af4f7f3a496dd79b196
3
+ metadata.gz: 697c58a5a0c9db02845d9812170b02f2a9dc9415db401db25edab2693476c639
4
+ data.tar.gz: d8962351ec1438b7d1a550fb0622b66e4d03e9e598cd8e704f25e3614d4f7dcf
5
5
  SHA512:
6
- metadata.gz: 0bde076e4319f7a6a7f3abb5f1f2b850e28bbdc2fa99839e7b34dc4670db06d80f5669747da423e97fa62c20d28fe1778f29a0252219edd0a3b44a2a11f43eb4
7
- data.tar.gz: cf8043ee35322037a673915b51241a2d7ec6f3ac4dafbeaca97700b8e2c24bcd8dd1a5e148d68eb0e0a7a243f990706cba027643afe01ee49a25960dc5650501
6
+ metadata.gz: f88b7b5eeeb80b6ac306908b5e810d0c17cef5573da16a778c361594e18f7fb6cb2e6c1a7a9121d4279dfc5e9596b6958d297c22b15ef0f83a486718697cc480
7
+ data.tar.gz: 5b469f55caed226a3deca1fd93a9a7e3b15e8d4a5e0fdf1f6bba128850c40740a1e72a488a7d31868ed8ad92aa0261aaabd19ee4df997fe00cb1c76c8a3e85db
@@ -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"
@@ -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
- 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)
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
- 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
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
@@ -1,3 +1,3 @@
1
1
  module OverridesTracker
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.7"
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.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-06 00:00:00.000000000 Z
11
+ date: 2022-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: method_source