waypoints 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/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +17 -0
- data/config/routes.rb +2 -0
- data/lib/tasks/waypoints_tasks.rake +4 -0
- data/lib/waypoints.rb +4 -0
- data/lib/waypoints/engine.rb +9 -0
- data/lib/waypoints/middleware.rb +17 -0
- data/lib/waypoints/tracer.rb +104 -0
- data/lib/waypoints/version.rb +3 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d9c5a2181ad2ec718f2fc5f489c5cb09c9fddc74
|
4
|
+
data.tar.gz: f3a1bb9ec7e12f59e7c1207d01b5b9133398a04a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dd598569cf7b8f53777957cb89d148066f94099a397e06ee0832aa3a6d337ec346a76938b7a86423241b2ff41a7105ee062922b695563f560615d4c476f47d60
|
7
|
+
data.tar.gz: 5b10bd9a4bfe961b95b4f343ebc46c6367bba7450368dd0877d4f7b30cc91c0c1f4bc343f4b283461b022467adb468c4b5772d7703281ae5a9d8d07a40b7f85f
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Erol Fornoles
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Waypoints
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'waypoints'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install waypoints
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Waypoints'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'bundler/gem_tasks'
|
data/config/routes.rb
ADDED
data/lib/waypoints.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "waypoints/tracer"
|
2
|
+
|
3
|
+
module Waypoints
|
4
|
+
class Middleware
|
5
|
+
def initialize(app)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
filepath = File.join(Rails.root, "log", "waypoint-#{Time.now.to_i}-#{env["REQUEST_URI"].parameterize}.png")
|
11
|
+
|
12
|
+
Waypoints::Tracer.trace filepath do
|
13
|
+
@app.call(env)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require "graphviz"
|
2
|
+
|
3
|
+
module Waypoints
|
4
|
+
module Tracer
|
5
|
+
class << self
|
6
|
+
def rootpath
|
7
|
+
Regexp.new("^#{Rails.root}/").freeze
|
8
|
+
end
|
9
|
+
|
10
|
+
def key(event)
|
11
|
+
klass = event.defined_class.to_s
|
12
|
+
method = event.method_id
|
13
|
+
action =
|
14
|
+
if event.self.instance_of? Class
|
15
|
+
"#{event.self}.#{method}"
|
16
|
+
else
|
17
|
+
"#{event.self.class}##{method}"
|
18
|
+
end
|
19
|
+
|
20
|
+
path = event.path.gsub(rootpath, "")
|
21
|
+
line = event.lineno
|
22
|
+
location =
|
23
|
+
if rootpath.match? event.path
|
24
|
+
"#{path}:#{line}"
|
25
|
+
else
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
if klass == "ActionView::CompiledTemplates"
|
30
|
+
action = nil
|
31
|
+
location = path
|
32
|
+
end
|
33
|
+
|
34
|
+
[action, location].compact.join("|")
|
35
|
+
end
|
36
|
+
|
37
|
+
def trace?(event)
|
38
|
+
return true if rootpath.match? event.path
|
39
|
+
|
40
|
+
false
|
41
|
+
end
|
42
|
+
|
43
|
+
def trace(filepath)
|
44
|
+
graph = GraphViz.new :G, type: :digraph
|
45
|
+
|
46
|
+
graph.node[:fontname] = "Arial, Helvetica, SansSerif"
|
47
|
+
graph.node[:style] = "rounded, filled"
|
48
|
+
graph.node[:color] = "#000000"
|
49
|
+
graph.node[:fillcolor] = "#FFFFFF"
|
50
|
+
graph.node[:fontcolor] = "#000000"
|
51
|
+
|
52
|
+
graph.edge[:fontname] = "Helvetica Neue Thin, Helvetica, Arial, SansSerif"
|
53
|
+
graph.edge[:fontsize] = 12
|
54
|
+
|
55
|
+
stack = []
|
56
|
+
roots = []
|
57
|
+
nodes = {}
|
58
|
+
|
59
|
+
request = graph.add_node "Request", shape: "circle"
|
60
|
+
|
61
|
+
trace = TracePoint.new :call, :return do |event|
|
62
|
+
next unless trace? event
|
63
|
+
|
64
|
+
case event.event
|
65
|
+
when :return
|
66
|
+
stack.pop
|
67
|
+
|
68
|
+
when :call
|
69
|
+
caller =
|
70
|
+
if stack.last
|
71
|
+
nodes.fetch stack.last do |_key|
|
72
|
+
nodes[_key] = graph.add_node _key, shape: "record"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
callee =
|
77
|
+
if key(event)
|
78
|
+
nodes.fetch key(event) do |_key|
|
79
|
+
nodes[_key] = graph.add_node _key, shape: "record"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
graph.add_edge caller, callee if caller && callee
|
84
|
+
|
85
|
+
roots << callee if stack.empty?
|
86
|
+
stack << key(event)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
trace.enable
|
91
|
+
result = yield
|
92
|
+
trace.disable
|
93
|
+
|
94
|
+
roots.each do |root|
|
95
|
+
graph.add_edge request, root
|
96
|
+
end
|
97
|
+
|
98
|
+
graph.output png: filepath
|
99
|
+
|
100
|
+
result
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: waypoints
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Erol Fornoles
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.0.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.0.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ruby-graphviz
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.2.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Waypoints
|
56
|
+
email:
|
57
|
+
- erol.fornoles@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- config/routes.rb
|
66
|
+
- lib/tasks/waypoints_tasks.rake
|
67
|
+
- lib/waypoints.rb
|
68
|
+
- lib/waypoints/engine.rb
|
69
|
+
- lib/waypoints/middleware.rb
|
70
|
+
- lib/waypoints/tracer.rb
|
71
|
+
- lib/waypoints/version.rb
|
72
|
+
homepage: https://github.com/Erol/waypoints
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.6.8
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Waypoints
|
96
|
+
test_files: []
|