load_tracer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +39 -0
- data/LICENSE.txt +21 -0
- data/README.md +47 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/load_tracer.rb +124 -0
- data/lib/load_tracer/version.rb +3 -0
- data/load_tracer.gemspec +31 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: eeeeceacbdb0493b22b4bc6555f8132aca31920261fc2aa2a17d96627c972a63
|
4
|
+
data.tar.gz: 844f00b03f9f2d871bce7e0705c1bac12c99923838ff047dec41127a0ccd54c5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b389012cc1aee3159a000c86675095529401e8761db4dbfb5db79d574bce7794857509d8e29fa7014d41a2521a279834923ef92bc3a6d0c12b69df645755033c
|
7
|
+
data.tar.gz: 43bfbda30363e9ca0e686b378d6f551f1897460c4794d18272158e51125e43e8612e3954b017dc7bdca76e70d2db2632da6bcc20fc381d68f5d3ac6ebd89811d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at tmshuichi@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
load_tracer (0.1.0)
|
5
|
+
binding_of_caller (~> 0.8.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
binding_of_caller (0.8.0)
|
11
|
+
debug_inspector (>= 0.0.1)
|
12
|
+
debug_inspector (0.0.3)
|
13
|
+
diff-lcs (1.3)
|
14
|
+
rake (12.3.2)
|
15
|
+
rspec (3.8.0)
|
16
|
+
rspec-core (~> 3.8.0)
|
17
|
+
rspec-expectations (~> 3.8.0)
|
18
|
+
rspec-mocks (~> 3.8.0)
|
19
|
+
rspec-core (3.8.0)
|
20
|
+
rspec-support (~> 3.8.0)
|
21
|
+
rspec-expectations (3.8.2)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.8.0)
|
24
|
+
rspec-mocks (3.8.0)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.8.0)
|
27
|
+
rspec-support (3.8.0)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
bundler (~> 1.17.3)
|
34
|
+
load_tracer!
|
35
|
+
rake (~> 12.3.2)
|
36
|
+
rspec (~> 3.8.0)
|
37
|
+
|
38
|
+
BUNDLED WITH
|
39
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Shuichi Tamayose
|
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,47 @@
|
|
1
|
+
# LoadTracer
|
2
|
+
|
3
|
+
This gem can check the dependency files.
|
4
|
+
|
5
|
+
require `RUBY_VERSION` >= 2.7.0
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
clone this repository.
|
10
|
+
|
11
|
+
```
|
12
|
+
git clone https://github.com/siman-man/load_tracer.git
|
13
|
+
```
|
14
|
+
|
15
|
+
build gem.
|
16
|
+
|
17
|
+
```
|
18
|
+
bundle exec rake build
|
19
|
+
```
|
20
|
+
|
21
|
+
install gem.
|
22
|
+
|
23
|
+
```
|
24
|
+
gem install pkg/load_tracer-0.1.0.gem
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'load_tracer'
|
33
|
+
|
34
|
+
report = LoadTracer.trace do
|
35
|
+
require 'net/http'
|
36
|
+
end
|
37
|
+
|
38
|
+
pp report
|
39
|
+
```
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
44
|
+
|
45
|
+
## Code of Conduct
|
46
|
+
|
47
|
+
Everyone interacting in the LoadTracer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/load_tracer/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "load_tracer"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/load_tracer.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'binding_of_caller'
|
2
|
+
require 'load_tracer/version'
|
3
|
+
|
4
|
+
module Kernel
|
5
|
+
unless defined?(__original_require__)
|
6
|
+
alias __original_require__ require
|
7
|
+
private :__original_require__
|
8
|
+
end
|
9
|
+
|
10
|
+
unless defined?(__original_require_relative__)
|
11
|
+
alias __original_require_relative__ require_relative
|
12
|
+
private :__original_require_relative__
|
13
|
+
end
|
14
|
+
|
15
|
+
unless defined?(__original_load__)
|
16
|
+
alias __original_load__ load
|
17
|
+
private :__original_load__
|
18
|
+
end
|
19
|
+
|
20
|
+
unless defined?(__original_autoload__)
|
21
|
+
alias __original_autoload__ autoload
|
22
|
+
private :__original_autoload__
|
23
|
+
end
|
24
|
+
|
25
|
+
def require(feature)
|
26
|
+
__original_require__(feature)
|
27
|
+
end
|
28
|
+
|
29
|
+
def require_relative(relative_feature)
|
30
|
+
binding.of_caller(1).eval("__original_require_relative__('#{relative_feature}')")
|
31
|
+
end
|
32
|
+
|
33
|
+
def load(file, priv = false)
|
34
|
+
__original_load__(file, priv)
|
35
|
+
end
|
36
|
+
|
37
|
+
def autoload(const_name, feature)
|
38
|
+
__original_autoload__(const_name, feature)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class LoadTracer
|
43
|
+
FileSpec = Struct.new(:name, :path, :dependencies, :reverse_dependencies, keyword_init: true)
|
44
|
+
|
45
|
+
LOAD_METHODS = %i(require require_relative load autoload)
|
46
|
+
|
47
|
+
def self.trace
|
48
|
+
instance = new
|
49
|
+
instance.tracer.enable { yield }
|
50
|
+
instance.report
|
51
|
+
end
|
52
|
+
|
53
|
+
def initialize
|
54
|
+
@dependencies = Hash.new { |hash, key| hash[key] = [] }
|
55
|
+
@reverse_dependencies = Hash.new { |hash, key| hash[key] = [] }
|
56
|
+
end
|
57
|
+
|
58
|
+
def tracer
|
59
|
+
TracePoint.new(:call) do |tp|
|
60
|
+
next unless LOAD_METHODS.include?(tp.method_id)
|
61
|
+
next if tp.defined_class != ::Kernel
|
62
|
+
next if tp.path != __FILE__
|
63
|
+
|
64
|
+
case tp.event
|
65
|
+
when :call
|
66
|
+
bl = caller_locations[1]
|
67
|
+
|
68
|
+
feature = get_feature(tp)
|
69
|
+
path = find_path(feature) || find_path(File.expand_path(feature, File.dirname(bl.path)))
|
70
|
+
|
71
|
+
raise LoadError.new("cannot load such file -- #{feature}") if path.nil?
|
72
|
+
|
73
|
+
@dependencies[bl.path] << path
|
74
|
+
@reverse_dependencies[path] << bl.path
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def report
|
80
|
+
file_specs = @dependencies.map do |path, deps|
|
81
|
+
FileSpec.new(
|
82
|
+
name: File.basename(path),
|
83
|
+
path: path,
|
84
|
+
dependencies: deps,
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
@reverse_dependencies.each do |path, rdeps|
|
89
|
+
fs = file_specs.find { |fs| fs.path == path }
|
90
|
+
|
91
|
+
if fs.nil?
|
92
|
+
file_specs << FileSpec.new(
|
93
|
+
name: File.basename(path),
|
94
|
+
path: path,
|
95
|
+
dependencies: [],
|
96
|
+
reverse_dependencies: rdeps
|
97
|
+
)
|
98
|
+
else
|
99
|
+
fs.reverse_dependencies = rdeps
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
file_specs
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def get_feature(tp)
|
109
|
+
params = tp.self.method(tp.method_id).parameters
|
110
|
+
|
111
|
+
case tp.method_id
|
112
|
+
when :require, :require_relative, :load
|
113
|
+
tp.binding.local_variable_get(params.first.last)
|
114
|
+
when :autoload
|
115
|
+
tp.binding.local_variable_get(params.last.last)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def find_path(feature)
|
120
|
+
RubyVM.resolve_feature_path(feature).last
|
121
|
+
rescue LoadError
|
122
|
+
nil
|
123
|
+
end
|
124
|
+
end
|
data/load_tracer.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'load_tracer/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'load_tracer'
|
7
|
+
spec.version = LoadTracer::VERSION
|
8
|
+
spec.authors = ['Shuichi Tamayose']
|
9
|
+
spec.email = ['tmshuichi@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = %q{TBD}
|
12
|
+
spec.description = %q{TBD}
|
13
|
+
spec.homepage = 'https://github.com/siman-man/load_tracer'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '> 2.6.99'
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = 'exe'
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
|
26
|
+
spec.add_runtime_dependency 'binding_of_caller', '~> 0.8.0'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.17.3'
|
29
|
+
spec.add_development_dependency 'rake', '~> 12.3.2'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.8.0'
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: load_tracer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shuichi Tamayose
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: binding_of_caller
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.17.3
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.17.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 12.3.2
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 12.3.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.8.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.8.0
|
69
|
+
description: TBD
|
70
|
+
email:
|
71
|
+
- tmshuichi@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CODE_OF_CONDUCT.md
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- lib/load_tracer.rb
|
88
|
+
- lib/load_tracer/version.rb
|
89
|
+
- load_tracer.gemspec
|
90
|
+
homepage: https://github.com/siman-man/load_tracer
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.6.99
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubygems_version: 3.0.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: TBD
|
113
|
+
test_files: []
|