deprecations_detector 0.0.1

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.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +56 -0
  3. data/.rubocop.yml +22 -0
  4. data/Gemfile +6 -0
  5. data/LICENSE +21 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +74 -0
  8. data/Rakefile +28 -0
  9. data/deprecations_detector.gemspec +38 -0
  10. data/lib/deprecations_detector/active_support/deprecation_decorator.rb +17 -0
  11. data/lib/deprecations_detector/formatters/html/assets/javascripts/application.js +213 -0
  12. data/lib/deprecations_detector/formatters/html/assets/javascripts/libraries/jquery-1.6.2.min.js +18 -0
  13. data/lib/deprecations_detector/formatters/html/assets/javascripts/plugins/highlight.pack.js +1 -0
  14. data/lib/deprecations_detector/formatters/html/assets/javascripts/plugins/jquery.colorbox.js +1090 -0
  15. data/lib/deprecations_detector/formatters/html/assets/javascripts/plugins/jquery.dataTables.min.js +152 -0
  16. data/lib/deprecations_detector/formatters/html/assets/javascripts/plugins/jquery.timeago.js +141 -0
  17. data/lib/deprecations_detector/formatters/html/assets/javascripts/plugins/jquery.url.js +174 -0
  18. data/lib/deprecations_detector/formatters/html/assets/javascripts/settings.js +1 -0
  19. data/lib/deprecations_detector/formatters/html/assets/javascripts/treeview.js +261 -0
  20. data/lib/deprecations_detector/formatters/html/assets/stylesheets/application.css +4 -0
  21. data/lib/deprecations_detector/formatters/html/assets/stylesheets/plugins/highlight.css +129 -0
  22. data/lib/deprecations_detector/formatters/html/assets/stylesheets/plugins/jquery-ui-1.8.4.custom.css +295 -0
  23. data/lib/deprecations_detector/formatters/html/assets/stylesheets/plugins/jquery.colorbox.css +52 -0
  24. data/lib/deprecations_detector/formatters/html/assets/stylesheets/reset.css +103 -0
  25. data/lib/deprecations_detector/formatters/html/assets/stylesheets/screen.css.sass +249 -0
  26. data/lib/deprecations_detector/formatters/html/assets/stylesheets/treeview.css +12 -0
  27. data/lib/deprecations_detector/formatters/html/formatter.rb +169 -0
  28. data/lib/deprecations_detector/formatters/html/public/application.css +852 -0
  29. data/lib/deprecations_detector/formatters/html/public/application.js +2050 -0
  30. data/lib/deprecations_detector/formatters/html/public/colorbox/border.png +0 -0
  31. data/lib/deprecations_detector/formatters/html/public/colorbox/controls.png +0 -0
  32. data/lib/deprecations_detector/formatters/html/public/colorbox/loading.gif +0 -0
  33. data/lib/deprecations_detector/formatters/html/public/colorbox/loading_background.png +0 -0
  34. data/lib/deprecations_detector/formatters/html/public/favicon.png +0 -0
  35. data/lib/deprecations_detector/formatters/html/public/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  36. data/lib/deprecations_detector/formatters/html/public/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  37. data/lib/deprecations_detector/formatters/html/public/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  38. data/lib/deprecations_detector/formatters/html/public/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  39. data/lib/deprecations_detector/formatters/html/public/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  40. data/lib/deprecations_detector/formatters/html/public/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  41. data/lib/deprecations_detector/formatters/html/public/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  42. data/lib/deprecations_detector/formatters/html/public/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  43. data/lib/deprecations_detector/formatters/html/public/images/ui-icons_222222_256x240.png +0 -0
  44. data/lib/deprecations_detector/formatters/html/public/images/ui-icons_2e83ff_256x240.png +0 -0
  45. data/lib/deprecations_detector/formatters/html/public/images/ui-icons_454545_256x240.png +0 -0
  46. data/lib/deprecations_detector/formatters/html/public/images/ui-icons_888888_256x240.png +0 -0
  47. data/lib/deprecations_detector/formatters/html/public/images/ui-icons_cd0a0a_256x240.png +0 -0
  48. data/lib/deprecations_detector/formatters/html/public/loading.gif +0 -0
  49. data/lib/deprecations_detector/formatters/html/public/magnify.png +0 -0
  50. data/lib/deprecations_detector/formatters/html/public/settings.js +1 -0
  51. data/lib/deprecations_detector/formatters/html/views/file_list.erb +24 -0
  52. data/lib/deprecations_detector/formatters/html/views/layout.erb +39 -0
  53. data/lib/deprecations_detector/formatters/html/views/source_file.erb +24 -0
  54. data/lib/deprecations_detector/main.rb +113 -0
  55. data/lib/deprecations_detector/version.rb +5 -0
  56. data/lib/deprecations_detector.rb +10 -0
  57. data/lib/tasks/deprecations/combine.rake +30 -0
  58. data/lib/tasks/deprecations/format.rake +14 -0
  59. metadata +254 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 14223f744285f1f73bc7453f2de6a42a9a8f87b599393cb67fb9345043be5f14
4
+ data.tar.gz: e1879d540ed9af626488355929a378cfbb71b83b6b9775411a7420173f65dcfc
5
+ SHA512:
6
+ metadata.gz: 296a9a4345d4aa010f62cd1f967430d3cf40896dbb6361b50fd8b8f8c39e652ce2b44fb464ab91bb78f4c123a786f0702d3dc460d6428b9844457d6eb1ec8dcb
7
+ data.tar.gz: 14b1e67170d3e0586f6c56e7c9dd9573bc2998895aeb2f792c9afce7252dcc48e03c5c111473744b7f4f8906610652143622ef13181ad995b4a7e886f13fbb68
data/.gitignore ADDED
@@ -0,0 +1,56 @@
1
+ *.rbc
2
+ capybara-*.html
3
+ .rspec
4
+ .rspec_status
5
+ .rubocop-*
6
+ /log
7
+ /tmp
8
+ /db/*.sqlite3
9
+ /db/*.sqlite3-journal
10
+ /public/system
11
+ /coverage/
12
+ /spec/tmp
13
+ *.orig
14
+ rerun.txt
15
+ pickle-email-*.html
16
+
17
+ # TODO Comment out this rule if you are OK with secrets being uploaded to the repo
18
+ config/initializers/secret_token.rb
19
+ config/master.key
20
+
21
+ # Only include if you have production secrets in this file, which is no longer a Rails default
22
+ # config/secrets.yml
23
+
24
+ # dotenv
25
+ # TODO Comment out this rule if environment variables can be committed
26
+ .env
27
+
28
+ ## Environment normalization:
29
+ /.bundle
30
+ /vendor/bundle
31
+
32
+ # these should all be checked in to normalize the environment:
33
+ # Gemfile.lock, .ruby-version, .ruby-gemset
34
+ Gemfile.lock
35
+
36
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
37
+ .rvmrc
38
+
39
+ # if using bower-rails ignore default bower_components path bower.json files
40
+ /vendor/assets/bower_components
41
+ *.bowerrc
42
+ bower.json
43
+
44
+ # Ignore pow environment settings
45
+ .powenv
46
+
47
+ # Ignore Byebug command history file.
48
+ .byebug_history
49
+
50
+ # Ignore node_modules
51
+ node_modules/
52
+
53
+ # Others
54
+ spec/faked_project/tmp/deprecations_detector.yml
55
+
56
+ tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,22 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ inherit_from:
5
+ - https://relaxed.ruby.style/rubocop.yml
6
+
7
+ Metrics/BlockLength:
8
+ Exclude:
9
+ - config/routes.rb
10
+ - db/seeds/**/*
11
+ - spec/**/*
12
+
13
+ RSpec/MultipleExpectations:
14
+ Max: 5
15
+ # Default is 1
16
+
17
+ RSpec/ExampleLength:
18
+ Max: 20
19
+ # Default is 5
20
+
21
+ AllCops:
22
+ TargetRubyVersion: 1.9
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in deprecations_detector.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Nebulab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Nebulab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ [![Gem Version](https://badge.fury.io/rb/deprecations_detector.svg)](https://badge.fury.io/rb/deprecations_detector)
2
+
3
+ # DeprecationsDetector
4
+
5
+ The goal of this component is to collect and list all the deprecation of the project visually.
6
+
7
+ ## Installation
8
+
9
+ Add `gem 'deprecations_detector', git: 'https://github.com/nebulab/deprecations_detector'` to your application's Gemfile and execute `bundle`.
10
+
11
+ Put the following code under you specs configuration:
12
+
13
+ ```ruby
14
+ require 'deprecations_detector'
15
+
16
+ RSpec.configure do |config|
17
+ config.before(:suite) do
18
+ DeprecationsDetector::Main.start
19
+ end
20
+
21
+ config.around do |e|
22
+ e.run
23
+ DeprecationsDetector::Main.add(e)
24
+ end
25
+
26
+ config.after(:suite) do
27
+ DeprecationsDetector::Main.save_results
28
+ coverage_matrix = DeprecationsDetector::Main.coverage_matrix
29
+ DeprecationsDetector::Formatters::HTML::Formatter.new.format(coverage_matrix)
30
+ end
31
+ end
32
+ ```
33
+
34
+ # Run it on multiple jobs
35
+
36
+ Sometimes specs are run concurrently on multiple jobs. In order to collect the result on one file this gem provides some
37
+ helpful task to combine the result in one single file and then format it.
38
+
39
+ 1. Remove the formatter from the after(:suite) hook
40
+ 2. Make the task available on your application following the instruction under `Tasks` section.
41
+ 3. Save the coverage result on the same directory with different name for any job (e.g. tmp/deps/a.yml, tmp/deps/b.yml etc..)
42
+ 4. Run the task to combine the YAML files `bundle exec rake 'deprecations:combine[tmp/deps/,deprecations_detector.yml]'`
43
+ 5. Run the task to format the YAML to HTML `bundle exec rake 'deprecations:format[tmp/deps/,deprecations_detector.yml]'`
44
+
45
+ ## Tasks
46
+
47
+ Add the following lines on your Rakefile to make the DeprecationsDetector tasks available from your application:
48
+
49
+ ```
50
+ spec = Gem::Specification.find_by_name 'deprecations_detector'
51
+ load "#{spec.gem_dir}/lib/tasks/deprecations/combine.rake"
52
+ load "#{spec.gem_dir}/lib/tasks/deprecations/format.rake"
53
+ ```
54
+
55
+ ## Testing
56
+
57
+ Execute `bundle exec rspec` on the component root path, specs are based on an internal fake project.
58
+
59
+ ## Contributing
60
+
61
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nebulab/deprecations_detector. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
62
+
63
+ ## License
64
+
65
+ DeprecationsDetector is copyright © 2023 [Nebulab](http://nebulab.it/). It is free software, and may be redistributed under the terms specified in the [license](LICENSE.txt).
66
+ Inspired by ReverseCoverage
67
+
68
+ ## About
69
+
70
+ ![Nebulab](http://nebulab.it/assets/images/public/logo.svg)
71
+
72
+ DeprecationsDetector is funded and maintained by the [Nebulab](http://nebulab.it/) team.
73
+
74
+ We firmly believe in the power of open-source. [Contact us](http://nebulab.it/contact-us/) if you like our work and you need help with your project design or development.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'pry'
6
+ require 'yaml'
7
+
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ import './lib/tasks/deprecations/combine.rake'
11
+ import './lib/tasks/deprecations/format.rake'
12
+
13
+ task default: :spec
14
+
15
+ namespace :assets do
16
+ desc "Compiles all assets"
17
+ task :compile do
18
+ puts "Compiling assets"
19
+ require "sprockets"
20
+ base_path = 'lib/deprecations_detector/formatters/html'
21
+ assets = Sprockets::Environment.new
22
+ assets.append_path "#{base_path}/assets/javascripts"
23
+ assets.append_path "#{base_path}/assets/stylesheets"
24
+ assets["application.js"].write_to("#{base_path}/public/application.js")
25
+ assets["settings.js"].write_to("#{base_path}/public/settings.js")
26
+ assets["application.css"].write_to("#{base_path}/public/application.css")
27
+ end
28
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'deprecations_detector/version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'deprecations_detector'
10
+ spec.version = DeprecationsDetector::VERSION
11
+ spec.summary = 'A tool to find what specs examples cover a specific line of code'
12
+ spec.description = spec.summary
13
+ spec.license = 'MIT'
14
+ spec.authors = ['Daniele Palombo']
15
+ spec.email = ['danielepalombo@nebulab.com']
16
+ spec.homepage = 'https://github.com/nebulab/deprecations_detector'
17
+
18
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|extra)/}) }
20
+ end
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_runtime_dependency 'rspec', '~> 3.8'
26
+ spec.add_development_dependency 'activesupport'
27
+ spec.add_development_dependency 'pry'
28
+
29
+ spec.add_development_dependency 'bundler', '~> 2.0'
30
+ spec.add_development_dependency 'rake', '~> 10.0'
31
+ spec.add_development_dependency 'rspec', '~> 3.0'
32
+ spec.add_development_dependency 'rubocop', '~> 0.67.2'
33
+ spec.add_development_dependency 'rubocop-performance', '~> 1.1.0'
34
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.32.0'
35
+
36
+ spec.add_development_dependency 'sass', '~> 3.7.4' # TODO: replace with sassc
37
+ spec.add_development_dependency 'sprockets', '~> 3.7.2'
38
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DeprecationsDetector
4
+ module ActiveSupport
5
+ module DeprecationDecorator
6
+ def warn(message = nil, callstack = caller)
7
+ DeprecationsDetector::Main.add_deprecation(message, caller)
8
+
9
+ return if DeprecationsDetector::Main.suppress_deprecations
10
+
11
+ super(message, callstack)
12
+ end
13
+
14
+ ::ActiveSupport::Deprecation.prepend(self)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,213 @@
1
+ //= require_directory ./libraries/
2
+ //= require_directory ./plugins/
3
+ //= require treeview.js
4
+ //= require_self
5
+
6
+ $(document).ready(function() {
7
+ // Configuration for fancy sortable tables for source file groups
8
+ $('.file_list').dataTable({
9
+ "aaSorting": [[ 0, "asc" ]],
10
+ "bPaginate": false,
11
+ "bJQueryUI": true,
12
+ "aoColumns": [
13
+ null,
14
+ null,
15
+ null
16
+ ]
17
+ });
18
+
19
+ // Syntax highlight all files up front - deactivated
20
+ // $('.source_table pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
21
+
22
+ // Syntax highlight source files on first toggle of the file view popup
23
+ $("a.src_link").click(function() {
24
+ // Get the source file element that corresponds to the clicked element
25
+ var source_table = $($(this).attr('href'));
26
+
27
+ // If not highlighted yet, do it!
28
+ if (!source_table.hasClass('highlighted')) {
29
+ source_table.find('pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
30
+ source_table.addClass('highlighted');
31
+ };
32
+ });
33
+
34
+ var prev_anchor;
35
+ var curr_anchor;
36
+
37
+ // Set-up of popup for source file views
38
+ $("a.src_link").colorbox({
39
+ transition: "none",
40
+ inline: true,
41
+ opacity: 1,
42
+ width: "95%",
43
+ height: "95%",
44
+ onLoad: function() {
45
+ prev_anchor = curr_anchor ? curr_anchor : jQuery.url.attr('anchor');
46
+ curr_anchor = this.href.split('#')[1];
47
+ window.location.hash = curr_anchor;
48
+ },
49
+ onCleanup: function() {
50
+ if (prev_anchor && prev_anchor != curr_anchor) {
51
+ $('a[href="#'+prev_anchor+'"]').click();
52
+ curr_anchor = prev_anchor;
53
+ } else {
54
+ $('.group_tabs a:first').click();
55
+ prev_anchor = curr_anchor;
56
+ curr_anchor = "#_AllFiles";
57
+ }
58
+ window.location.hash = curr_anchor;
59
+ }
60
+ });
61
+
62
+ window.onpopstate = function(event){
63
+ if (location.hash.substring(0,2) == "#_") {
64
+ $.colorbox.close();
65
+ curr_anchor = jQuery.url.attr('anchor');
66
+ } else {
67
+ if ($('#colorbox').is(':hidden')) {
68
+ $('a.src_link[href="'+location.hash+'"]').colorbox({ open: true });
69
+ }
70
+ }
71
+ };
72
+
73
+ // Hide src files and file list container after load
74
+ $('.source_files').hide();
75
+ $('.file_list_container').hide();
76
+
77
+ // Add tabs based upon existing file_list_containers
78
+ $('.file_list_container h2').each(function(){
79
+ var container_id = $(this).parent().attr('id');
80
+ var group_name = $(this).find('.group_name').first().html();
81
+
82
+ $('.group_tabs').append('<li><a href="#' + container_id + '">' + group_name.substring(0, 30) + '</a></li>');
83
+ });
84
+
85
+ $('.group_tabs a').each( function() {
86
+ $(this).addClass($(this).attr('href').replace('#', ''));
87
+ });
88
+
89
+ // Make sure tabs don't get ugly focus borders when active
90
+ $('.group_tabs a').live('focus', function() { $(this).blur(); });
91
+
92
+ var favicon_path = $('link[rel="icon"]').attr('href');
93
+ $('.group_tabs a').live('click', function(){
94
+ if (!$(this).parent().hasClass('active')) {
95
+ $('.group_tabs a').parent().removeClass('active');
96
+ $(this).parent().addClass('active');
97
+ $('.file_list_container').hide();
98
+ $(".file_list_container" + $(this).attr('href')).show();
99
+ window.location.href = window.location.href.split('#')[0] + $(this).attr('href').replace('#', '#_');
100
+
101
+ // Force favicon reload - otherwise the location change containing anchor would drop the favicon...
102
+ // Works only on firefox, but still... - Anyone know a better solution to force favicon on local file?
103
+ $('link[rel="shortcut icon"]').remove();
104
+ $('head').append('<link rel="shortcut icon" type="image/png" href="'+ favicon_path +'" />');
105
+ };
106
+ return false;
107
+ });
108
+
109
+ if (jQuery.url.attr('anchor')) {
110
+ var anchor = jQuery.url.attr('anchor')
111
+ if (anchor.length == 40) {
112
+ $('a.src_link[href=#' + anchor + ']').click();
113
+ } else {
114
+ $('.group_tabs a.'+anchor.replace('_', '')).click();
115
+ }
116
+ } else {
117
+ $('.group_tabs a:first').click();
118
+ };
119
+
120
+ $("abbr.timeago").timeago();
121
+ $('#loading').fadeOut();
122
+ $('#wrapper').show();
123
+ $('.dataTables_filter input').focus();
124
+
125
+ // https://stackoverflow.com/a/34430701
126
+ window.getAbsoluteUrl = function (base, relative) {
127
+ var hashPosition = base.indexOf('#');
128
+ if (hashPosition > 0){
129
+ base = base.slice(0, hashPosition);
130
+ }
131
+
132
+ var stack = base.split("/"),
133
+ parts = relative.split("/");
134
+ stack.pop();
135
+ for (var i=0; i<parts.length; i++) {
136
+ if (parts[i] == ".")
137
+ continue;
138
+ if (parts[i] == "..")
139
+ stack.pop();
140
+ else
141
+ stack.push(parts[i]);
142
+ }
143
+ return stack.join("/");
144
+ }
145
+
146
+ window.traverseTreeData = function(treeData, paths) {
147
+ if(paths.length == 0) { return []; }
148
+
149
+ const currentNode = paths[0];
150
+
151
+ let nodeIndex = treeData.findIndex(function(node) { return node.name == currentNode.name });
152
+ if(nodeIndex == -1) {
153
+ let node = {
154
+ name: currentNode.name,
155
+ example: currentNode.example,
156
+ expanded: true,
157
+ children: traverseTreeData([], paths.slice(1))
158
+ };
159
+ treeData.push(node);
160
+
161
+ } else {
162
+ let node = treeData[nodeIndex];
163
+ node.children = traverseTreeData(node.children, paths.slice(1));
164
+ node.expanded = (node.children.length > 1) ? false : true;
165
+ treeData[nodeIndex] = node;
166
+ }
167
+
168
+ return treeData;
169
+ };
170
+
171
+ $('.source_table.highlighted li.covered').live('click', function() {
172
+ const exampleRefs = $(this).children('.deprecations_detector')[0].dataset.exampleRefs.split(",");
173
+ if(!$(this).children('.deprecations_detector').is(':visible')){
174
+ let treeData = [];
175
+ const self = this;
176
+ exampleRefs.forEach(function(ref) {
177
+ const example = window.examples[ref]
178
+ const treeNodes = []
179
+ example["file_path"].split('/').slice(1).forEach(function(node_path){
180
+ treeNodes.push({ name: node_path })
181
+ });
182
+ treeNodes.push({ example: example, name: example['full_description'] });
183
+
184
+ treeData = traverseTreeData(treeData, treeNodes)
185
+ })
186
+
187
+ const domElement = self.querySelector('.deprecations_detector');
188
+
189
+ let tree = new TreeView(treeData, domElement);
190
+ tree.on('select', function (node) {
191
+ const example = node.data.example;
192
+ const url = getAbsoluteUrl('', `${window.base_url}${example.file_path}#L${example.line_number}`);
193
+ window.open(url, '_blank');
194
+ });
195
+ $(this).children('.deprecations_detector').show();
196
+
197
+ let divMessages = document.createElement('div');
198
+ divMessages.className = 'messages';
199
+ domElement.prepend(divMessages);
200
+ deprecations = exampleRefs.map(function(ref) { return window.examples[ref]['deprecation_message'] });
201
+ [...new Set(deprecations)].forEach(function(message){
202
+ divMessages.append(message);
203
+ divMessages.append(document.createElement('br'));
204
+ })
205
+ } else {
206
+ $(this).children('.deprecations_detector').html('');
207
+ $(this).children('.deprecations_detector').hide();
208
+ }
209
+ });
210
+ $('.source_table.highlighted li.covered .deprecations_detector').live('click', function(event) {
211
+ event.stopPropagation();
212
+ });
213
+ });