overrides_tracker 0.1.8 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/Gemfile +12 -3
- data/README.md +15 -0
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/bin/overrides_tracker +39 -21
- data/lib/overrides_tracker/api.rb +47 -19
- data/lib/overrides_tracker/comparer.rb +309 -75
- data/lib/overrides_tracker/file_observer.rb +1 -1
- data/lib/overrides_tracker/methods_collector.rb +115 -83
- data/lib/overrides_tracker/string_colorizer.rb +3 -5
- data/lib/overrides_tracker/util.rb +22 -25
- data/lib/overrides_tracker/version.rb +1 -1
- data/lib/overrides_tracker.rb +17 -38
- data/overrides_tracker.gemspec +19 -19
- data/spec/overrides_tracker_spec.rb +1 -5
- data/spec/spec_helper.rb +21 -5
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66085bc82fe4b27b6fc5672a257751effdac97f3ee0492b2764b6a6ccd721ae3
|
4
|
+
data.tar.gz: 2f93dc7369c1b9dc2cf87c737d037167c44bc6e42e83e708aebd56d1b3b4d477
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 501e4191f85c326858b8dac38f5db8a6f434f2d0dd49131e0b8bd72ce276e652296a97bac278609424c25475d6626fec7101939a01294387da0376274455b2c4
|
7
|
+
data.tar.gz: de27da503a2ad558f38d186b1d3056771029e907cde457f2de62ff37857e5285a53a1849de67322e2e37ffb9ef97b17bb30d6c655d3474ae9eabdf9c5759a13e
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,6 +1,15 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
3
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem 'coveralls_reborn', '~> 0.25.0', require: false
|
7
|
+
gem 'rspec'
|
8
|
+
gem 'rspec_junit_formatter'
|
9
|
+
gem 'rubocop', require: false
|
10
|
+
gem 'simplecov', require: false
|
11
|
+
gem 'simplecov-lcov', '~> 0.8.0'
|
12
|
+
end
|
4
13
|
|
5
14
|
# Specify your gem's dependencies in overrides_tracker.gemspec
|
6
15
|
gemspec
|
@@ -11,4 +20,4 @@ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9')
|
|
11
20
|
else
|
12
21
|
gem 'vcr', '>= 2.9'
|
13
22
|
gem 'webmock', '>= 1.20'
|
14
|
-
end
|
23
|
+
end
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Overrides Tracker
|
2
2
|
Overrides Tracker keeps track of all overriding methods in your project and allows for comparison across branches.
|
3
3
|
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/overrides_tracker.svg)](https://badge.fury.io/rb/overrides_tracker)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/github/SyborgStudios/overrides_tracker/badge.svg?branch=master)](https://coveralls.io/github/SyborgStudios/overrides_tracker?branch=master)
|
6
|
+
[![CircleCI](https://dl.circleci.com/status-badge/img/gh/SyborgStudios/overrides_tracker/tree/master.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/SyborgStudios/overrides_tracker/tree/master)
|
7
|
+
|
4
8
|
## Contact
|
5
9
|
|
6
10
|
*Code and Bug Reports*
|
@@ -118,6 +122,17 @@ Getting started
|
|
118
122
|
15 source method bodies have changed
|
119
123
|
```
|
120
124
|
|
125
|
+
## GEM support
|
126
|
+
|
127
|
+
Overrides Tracker can also be used on GEMs. It will autoload all classes in the lib and app folders.
|
128
|
+
|
129
|
+
Sometimes that is not enough:
|
130
|
+
|
131
|
+
If you need further requirements, you can just add a .overrides_tracker folder and add a requirements.rb file to it.
|
132
|
+
In that one you can just require the classes your gem depends on.
|
133
|
+
|
134
|
+
You can also use the ['require_all'](https://github.com/jarmo/require_all) way to include complete folders, filter files etc..
|
135
|
+
|
121
136
|
## Ruby version compatibility
|
122
137
|
|
123
138
|
OverridesTracker is built in [Continuous Integration] on Ruby 2.3+.
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'overrides_tracker'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "overrides_tracker"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/bin/overrides_tracker
CHANGED
@@ -1,35 +1,53 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
if ARGV[0] ==
|
3
|
-
|
4
|
-
puts 'Reading all methods...'
|
5
|
-
OVERRIDES_TRACKER_TRACKING_ENABLED = true
|
6
|
-
require Dir.pwd+'/config/environment.rb'
|
7
|
-
require 'overrides_tracker'
|
2
|
+
if ARGV[0] == 'track'
|
3
|
+
# We set this constant so monkey patching of the gem is only done when checking the overrides
|
8
4
|
|
9
|
-
|
10
|
-
|
5
|
+
OVERRIDES_TRACKER_TRACKING_ENABLED = true
|
6
|
+
require 'overrides_tracker'
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
app_environment_file = Dir.pwd + '/config/environment.rb'
|
9
|
+
if File.exist?(app_environment_file)
|
10
|
+
#We are in a Rails app
|
11
|
+
puts 'Reading all methods...'
|
12
|
+
require app_environment_file
|
13
|
+
else
|
14
|
+
#We are in a gem
|
15
|
+
puts 'Looking for .overrides_tracker/requierements.rb file for extra requirements...'
|
16
|
+
require 'external/require_all'
|
17
|
+
gem_requirements_file = Dir.pwd + '/.overrides_tracker/requirements.rb'
|
18
|
+
|
19
|
+
if File.exist?(gem_requirements_file)
|
20
|
+
puts 'Reading all methods...'
|
21
|
+
require gem_requirements_file
|
16
22
|
else
|
17
|
-
|
18
|
-
#puts ''
|
19
|
-
#puts 'Have no idea what overrides.io is about? Check it out at https://www.overrides.com'
|
23
|
+
puts 'Reading all methods...'
|
20
24
|
end
|
21
25
|
|
22
|
-
|
26
|
+
|
27
|
+
require_all 'lib/**/*.rb', base_dir: Dir.pwd
|
28
|
+
require_all 'app/**/*.rb', base_dir: Dir.pwd
|
29
|
+
end
|
30
|
+
|
31
|
+
OverridesTracker::MethodsCollector.instance.build_overrides_hash
|
32
|
+
OverridesTracker::MethodsCollector.instance.save_to_file
|
33
|
+
|
34
|
+
if ENV['OVERRIDES_API_TOKEN']
|
35
|
+
OverridesTracker::MethodsCollector.instance.report(ENV['OVERRIDES_API_TOKEN'])
|
36
|
+
elsif !ARGV[1].nil?
|
37
|
+
OverridesTracker::MethodsCollector.instance.report(ARGV[1])
|
38
|
+
end
|
39
|
+
|
40
|
+
elsif ARGV[0] == 'compare'
|
23
41
|
require 'overrides_tracker'
|
24
42
|
OverridesTracker::Comparer.compare
|
25
43
|
|
26
44
|
unless ENV['OVERRIDES_API_TOKEN']
|
27
45
|
puts ''
|
28
|
-
#puts 'Have you heard of overrides.io?'
|
29
|
-
#puts 'It integrates with your CI pipeline and notifies you whenever original methods are changing or disappearing.'
|
30
|
-
#puts 'Check it out at https://www.overrides.com'
|
31
|
-
end
|
32
|
-
elsif ARGV[0] ==
|
46
|
+
# puts 'Have you heard of overrides.io?'
|
47
|
+
# puts 'It integrates with your CI pipeline and notifies you whenever original methods are changing or disappearing.'
|
48
|
+
# puts 'Check it out at https://www.overrides.com'
|
49
|
+
end
|
50
|
+
elsif ARGV[0] == 'report'
|
33
51
|
require 'overrides_tracker'
|
34
52
|
|
35
53
|
if ENV['OVERRIDES_API_TOKEN']
|
@@ -1,50 +1,78 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'net/https'
|
3
|
+
require 'digest'
|
3
4
|
|
4
5
|
class OverridesTracker::Api
|
5
|
-
|
6
|
-
|
7
|
-
API_PROTOCOL = ENV['OVERRIDES_TRACKER_DEVELOPMENT'] ? "http" : "https"
|
6
|
+
API_HOST = ENV['OVERRIDES_TRACKER_DEVELOPMENT'] ? 'localhost:3000' : 'www.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"
|
11
11
|
|
12
12
|
def self.report_build(api_token, branch_name, last_commit_id, last_commit_name, file_path)
|
13
|
-
|
14
13
|
disable_net_blockers!
|
15
14
|
|
16
|
-
uri = URI(API_DOMAIN)
|
17
|
-
client = build_client(uri)
|
18
|
-
|
19
|
-
request = Net::HTTP::Post.new('/api/v1/builds')
|
20
|
-
form_data = [['api_token',api_token], ['branch_name', branch_name],['build_provider_id', last_commit_id], ['build_name', last_commit_name], ['result_file', File.open(file_path)]]
|
21
|
-
request.set_form form_data, 'multipart/form-data'
|
22
|
-
|
23
15
|
puts ' '
|
24
16
|
puts '==========='
|
25
17
|
puts 'Sending report to Overrides.io...'
|
26
18
|
|
19
|
+
file_hash = Digest::SHA256.hexdigest(File.read(file_path))
|
20
|
+
|
21
|
+
if find_or_report_build(api_token, branch_name, last_commit_id, last_commit_name, file_hash)
|
22
|
+
puts 'Success.'.green
|
23
|
+
true
|
24
|
+
else
|
25
|
+
file = File.open(file_path)
|
26
|
+
form_data = [['api_token', api_token], ['branch_name', branch_name], ['build_provider_id', last_commit_id],
|
27
|
+
['build_name', last_commit_name], ['result_file', file], ['file_hash', file_hash]]
|
28
|
+
|
29
|
+
uri = URI(API_DOMAIN)
|
30
|
+
client = build_client(uri)
|
31
|
+
request = Net::HTTP::Post.new('/api/v1/builds')
|
32
|
+
request.set_form form_data, 'multipart/form-data'
|
33
|
+
|
34
|
+
begin
|
35
|
+
response = client.request(request)
|
36
|
+
puts 'Success.'.green
|
37
|
+
true
|
38
|
+
rescue SocketError => e
|
39
|
+
puts 'Failed to report to the Overrides API.'.red
|
40
|
+
false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.find_or_report_build(api_token, branch_name, last_commit_id, last_commit_name, file_hash)
|
46
|
+
uri = URI(API_DOMAIN)
|
47
|
+
client = build_client(uri)
|
48
|
+
|
49
|
+
form_data = [['api_token', api_token], ['branch_name', branch_name], ['build_provider_id', last_commit_id],
|
50
|
+
['build_name', last_commit_name], ['file_hash', file_hash]]
|
51
|
+
|
52
|
+
request = Net::HTTP::Post.new('/api/v1/builds/find_or_create')
|
53
|
+
request.set_form form_data
|
54
|
+
|
27
55
|
begin
|
28
56
|
response = client.request(request)
|
29
|
-
|
30
|
-
|
31
|
-
|
57
|
+
if response.code == '404'
|
58
|
+
false
|
59
|
+
else
|
60
|
+
true
|
61
|
+
end
|
62
|
+
rescue SocketError => e
|
32
63
|
puts 'Failed to report to the Overrides API.'.red
|
64
|
+
false
|
33
65
|
end
|
34
66
|
end
|
35
|
-
|
36
|
-
|
67
|
+
|
37
68
|
def self.build_client(uri)
|
38
69
|
client = Net::HTTP.new(uri.host, uri.port)
|
39
70
|
client.use_ssl = true if uri.port == 443
|
40
71
|
client.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
41
72
|
|
42
|
-
|
43
73
|
client
|
44
74
|
end
|
45
75
|
|
46
|
-
private
|
47
|
-
|
48
76
|
def self.disable_net_blockers!
|
49
77
|
begin
|
50
78
|
require 'webmock'
|