overrides_tracker 0.1.5 → 0.1.6
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 +4 -4
- data/bin/overrides_tracker +1 -0
- data/lib/overrides_tracker/api.rb +2 -2
- data/lib/overrides_tracker/methods_collector.rb +28 -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: a349cfc8219a5e3c54b7fcf01e4c8bcb826ececedb3fa81e1b0a3217cbdc7cc4
         | 
| 4 | 
            +
              data.tar.gz: 6a602b0a8a08c566f461c8246858d2bf2204a672cff70db325bee4984906215a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: d43eb13bca15ad87a32c47183090a70a23d93d33fd6717f78c1c4c668a1a9c3254fec879771ddc15ab33a782ce03f716d949efbfc8dd9245ba92c2bd722ccac8
         | 
| 7 | 
            +
              data.tar.gz: db00cf8aed2a4a65b4536be2e7a075488db611b551f877f40682089e6ac13e390f4aeeae276f2ec01b5598974c219b0f09716398c48054ed5d52b26d5e83dae1
         | 
    
        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"
         | 
| @@ -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 | 
            -
             | 
| 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)
         | 
| 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 | 
            -
                           | 
| 84 | 
            -
             | 
| 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
         | 
    
        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.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- | 
| 11 | 
            +
            date: 2022-12-07 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: method_source
         |