method_call_tree 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c4c4e0142f0e00f9a5565a4edb904d15923839617ad703ddcb0d716ebc1dfa27
4
+ data.tar.gz: 9c971a0fcb81356ae5ca73d93c4ed602abe43a29319dae326585293764d4a77c
5
+ SHA512:
6
+ metadata.gz: 100b54a6b4d8c331eeea670201913b79e08e26571d2696844459d3414040bbd47df5525a9f0e3d778f43a7d72fd75dcd3f6d3e7eab7f779119ef139664e602d6
7
+ data.tar.gz: a4149e7778145c68ccdda5bc282c4614c6965527a6485ef32dcffe2110c00f2048c612eb345f8f007263524dcc4dc6b123a093aaa642eba8fdab6313845c8a3e
checksums.yaml.gz.sig ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.1.10
5
+ - 2.2.9
6
+ - 2.3.6
7
+ - 2.4.3
8
+ - 2.5.0
9
+ before_install: gem install bundler -v 1.16.1
@@ -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
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in method_call_tree.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ method_call_tree (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rake (10.5.0)
11
+ rspec (3.7.0)
12
+ rspec-core (~> 3.7.0)
13
+ rspec-expectations (~> 3.7.0)
14
+ rspec-mocks (~> 3.7.0)
15
+ rspec-core (3.7.0)
16
+ rspec-support (~> 3.7.0)
17
+ rspec-expectations (3.7.0)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.7.0)
20
+ rspec-mocks (3.7.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.7.0)
23
+ rspec-support (3.7.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.16)
30
+ method_call_tree!
31
+ rake (~> 10.0)
32
+ rspec (~> 3.0)
33
+
34
+ BUNDLED WITH
35
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 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,57 @@
1
+ [![Build Status](https://travis-ci.org/siman-man/method_call_tree.svg?branch=master)](https://travis-ci.org/siman-man/method_call_tree)
2
+
3
+ # MethodCallTree
4
+
5
+ MethodCallTree is like tree command for method call stack.
6
+
7
+ ## Installation
8
+
9
+ ```ruby
10
+ gem 'method_call_tree'
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ruby
16
+ require 'method_call_tree'
17
+
18
+ class Foo
19
+ def foo
20
+ bar
21
+ baz
22
+ end
23
+
24
+ def bar
25
+ end
26
+
27
+ def baz
28
+ hoge
29
+ end
30
+
31
+ def hoge
32
+ end
33
+ end
34
+
35
+ tree = MethodCallTree.create do
36
+ Foo.new.foo
37
+ end
38
+
39
+ puts tree
40
+ ```
41
+
42
+ result
43
+
44
+ ```
45
+ Foo::foo
46
+ ├───── Foo::bar
47
+ └───── Foo::baz
48
+ └───── Foo::hoge
49
+ ```
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
54
+
55
+ ## Code of Conduct
56
+
57
+ Everyone interacting in the MethodCallTree project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/siman-man/method_call_tree/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "method_call_tree"
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ class MethodCallTree
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,64 @@
1
+ require 'method_call_tree/version'
2
+
3
+ class MethodCallTree
4
+ SPACE_SIZE = 8
5
+ T_LINE = '├─────'
6
+ I_LINE = '│'
7
+ L_LINE = '└─────'
8
+
9
+ def self.create(&block)
10
+ new(&block)
11
+ end
12
+
13
+ def initialize
14
+ @tree = Hash.new
15
+ @queue = []
16
+
17
+ tracer.enable { yield }
18
+
19
+ @tree.each do |root, tree|
20
+ walk(root, tree)
21
+ end
22
+ end
23
+
24
+ def to_s
25
+ @queue.join
26
+ end
27
+
28
+ private
29
+
30
+ def tracer
31
+ id = 0
32
+ call_stack = []
33
+
34
+ TracePoint.new(:call, :return) do |tp|
35
+ case tp.event
36
+ when :call
37
+ key = "#{tp.defined_class}::#{tp.method_id}_#{id}"
38
+ id += 1
39
+
40
+ call_stack.inject(@tree, :[])[key] = {}
41
+ call_stack.push(key)
42
+ when :return
43
+ call_stack.pop
44
+ end
45
+ end
46
+ end
47
+
48
+ def get_line(end_line:, space:)
49
+ end_line ? "#{space}#{L_LINE} " : "#{space}#{T_LINE} "
50
+ end
51
+
52
+ def get_space(end_line:)
53
+ end_line ? ' ' * SPACE_SIZE : I_LINE + ' ' * (SPACE_SIZE - 1)
54
+ end
55
+
56
+ def walk(parent, tree, space = "")
57
+ @queue << "#{parent.gsub(/_\d+/, '')}\n"
58
+
59
+ while node = tree.shift
60
+ @queue << get_line(end_line: tree.empty?, space: space)
61
+ walk(*node, space + get_space(end_line: tree.empty?))
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "method_call_tree/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "method_call_tree"
7
+ spec.version = MethodCallTree::VERSION
8
+ spec.authors = ["Shuichi Tamayose"]
9
+ spec.email = ["tmshuichi@gmail.com"]
10
+
11
+ spec.summary = %q{method call tree}
12
+ spec.description = %q{method call tree}
13
+ spec.homepage = "https://github.com/siman-man/method_call_tree"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.1.0"
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+
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_development_dependency "bundler", "~> 1.16"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ end
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: method_call_tree
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Shuichi Tamayose
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIID0jCCArqgAwIBAgIBATANBgkqhkiG9w0BAQUFADBoMRAwDgYDVQQDDAdrMTI4
14
+ NTg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dACt1LoufAUIxytIkqdXtBtNuM
30
+ zT1+OBWvES2aeKcx+g7gcbAc5DicNMtdLHCbenjhR1glcHWXdasoKQ6HrVekm2fp
31
+ zzZxEHIvijfuL7FyNm9YraQd10vNG433pLsTMxIry/d29pssgbq+T6V3ez560If8
32
+ FDRi8p0CR5Kr8eZGeaIfpMKn4nbQQq4w5wLzNxnecBb26xn4EPHn3dVLF24+NJkf
33
+ BLzd24MyvHKRaGDWAmiJAd9Z04Vkyw==
34
+ -----END CERTIFICATE-----
35
+ date: 2017-12-28 00:00:00.000000000 Z
36
+ dependencies:
37
+ - !ruby/object:Gem::Dependency
38
+ name: bundler
39
+ requirement: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.16'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '1.16'
51
+ - !ruby/object:Gem::Dependency
52
+ name: rake
53
+ requirement: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '10.0'
58
+ type: :development
59
+ prerelease: false
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - "~>"
63
+ - !ruby/object:Gem::Version
64
+ version: '10.0'
65
+ - !ruby/object:Gem::Dependency
66
+ name: rspec
67
+ requirement: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '3.0'
72
+ type: :development
73
+ prerelease: false
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - "~>"
77
+ - !ruby/object:Gem::Version
78
+ version: '3.0'
79
+ description: method call tree
80
+ email:
81
+ - tmshuichi@gmail.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - ".gitignore"
87
+ - ".rspec"
88
+ - ".travis.yml"
89
+ - CODE_OF_CONDUCT.md
90
+ - Gemfile
91
+ - Gemfile.lock
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - bin/console
96
+ - bin/setup
97
+ - lib/method_call_tree.rb
98
+ - lib/method_call_tree/version.rb
99
+ - method_call_tree.gemspec
100
+ homepage: https://github.com/siman-man/method_call_tree
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 2.1.0
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.7.3
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: method call tree
124
+ test_files: []
metadata.gz.sig ADDED
Binary file