neolytics 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 +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +50 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/neo4apis/neolytics.rb +160 -0
- data/lib/neo4apis/neolytics/trace_point_helpers.rb +75 -0
- data/lib/neolytics.rb +14 -0
- data/lib/neolytics/recorder.rb +129 -0
- data/lib/neolytics/version.rb +3 -0
- data/neolytics.gemspec +28 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b9f88458d8ba044e986867ec1e740f292dce0961
|
4
|
+
data.tar.gz: 22b7537a706c4f377102f7e205d9a834e09bde12
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 96424597969051fa96d53b6e0e26796b4519542f2c2bce900c9b28cfd14816f0af3c0f8034b78d9517e6ebee7806cb53464ff592dc83444fded90b6a65993160
|
7
|
+
data.tar.gz: 350a7ff4d6edbf45794aeae147f2ab8ee7229ec4a4aa59bf6c978b32eda3c14a1d4e6dabc84a573d1ca1597d6c19d5c55445135ec3d2bdcc0330dfad5267507c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at public@brian-underwood.codes. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
|
45
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
46
|
+
version 1.3.0, available at
|
47
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
48
|
+
|
49
|
+
[homepage]: http://contributor-covenant.org
|
50
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Brian Underwood
|
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,41 @@
|
|
1
|
+
# Neolytics
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/neolytics`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'neolytics'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install neolytics
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/neolytics. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "neolytics"
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'neo4apis/neolytics/trace_point_helpers'
|
2
|
+
|
3
|
+
module Neo4Apis
|
4
|
+
class Neolytics < Base
|
5
|
+
common_label :Neolytics
|
6
|
+
|
7
|
+
uuid :Object, :ruby_object_id
|
8
|
+
uuid :TracePoint, :uuid
|
9
|
+
uuid :ASTNode, :uuid
|
10
|
+
uuid :File, :path
|
11
|
+
|
12
|
+
batch_size 10000
|
13
|
+
|
14
|
+
IMPORTED_OBJECT_NODES = {}
|
15
|
+
|
16
|
+
importer :Object do |object|
|
17
|
+
next IMPORTED_OBJECT_NODES[object.object_id] if IMPORTED_OBJECT_NODES.key?(object.object_id)
|
18
|
+
|
19
|
+
object_node = add_node(:Object) do |node|
|
20
|
+
node.ruby_object_id = object.object_id
|
21
|
+
node.ruby_inspect = object.inspect[0,500]
|
22
|
+
node._extra_labels = []
|
23
|
+
node._extra_labels << 'Class' if object.class == Class
|
24
|
+
node._extra_labels << 'Module' if object.class == Module
|
25
|
+
end
|
26
|
+
|
27
|
+
IMPORTED_OBJECT_NODES[object.object_id] = object_node
|
28
|
+
|
29
|
+
class_node = import :Object, object.class
|
30
|
+
add_relationship :IS_A, object_node, class_node if class_node
|
31
|
+
|
32
|
+
if object.respond_to?(:superclass) && object.superclass
|
33
|
+
superclass_node = import :Object, object.superclass
|
34
|
+
add_relationship :HAS_SUPERCLASS, object_node, superclass_node if superclass_node
|
35
|
+
end
|
36
|
+
|
37
|
+
if object.respond_to?(:included_modules)
|
38
|
+
object.included_modules.each do |mod|
|
39
|
+
module_node = import :Object, mod
|
40
|
+
add_relationship :INCLUDES_MODULE, object_node, module_node if module_node
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
object.instance_variables.each do |variable|
|
45
|
+
value = object.instance_variable_get(variable)
|
46
|
+
other_object_node = import :Object, value
|
47
|
+
add_relationship :INSTANCE_VARIABLE, object_node, other_object_node, variable: variable
|
48
|
+
end
|
49
|
+
|
50
|
+
object_node
|
51
|
+
end
|
52
|
+
|
53
|
+
importer :TracePoint do |tp, execution_time, execution_index, last_tracepoint_node, parent, associated_call|
|
54
|
+
next nil if tp.method_id.blank? && tp.defined_class.blank?
|
55
|
+
|
56
|
+
trace_point_node = add_node :TracePoint, tp, %i(event lineno method_id) do |node|
|
57
|
+
node.uuid = SecureRandom.uuid
|
58
|
+
node.defined_class = tp.defined_class.to_s
|
59
|
+
node.execution_time = execution_time if execution_time
|
60
|
+
node.execution_index = execution_index
|
61
|
+
|
62
|
+
node.path = Pathname.new(tp.path).realpath.to_s
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
if [:return, :c_return].include?(tp.event)
|
67
|
+
returned_object_node = import :Object, tp.return_value
|
68
|
+
add_relationship :RETURNED, trace_point_node, returned_object_node
|
69
|
+
end
|
70
|
+
|
71
|
+
unless tp == tp.self
|
72
|
+
begin
|
73
|
+
ruby_object_node = import :Object, tp.self
|
74
|
+
add_relationship :FROM_OBJECT, trace_point_node, ruby_object_node
|
75
|
+
rescue Exception
|
76
|
+
nil
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
if tp.event == :line
|
81
|
+
TracePointHelpers.each_referenced_variable(tp) do |var, value|
|
82
|
+
object_node = import :Object, value
|
83
|
+
add_relationship :HAS_VARIABLE_VALUE, trace_point_node, object_node, variable_name: var
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
if tp.event == :call
|
88
|
+
TracePointHelpers.each_received_arguments(tp) do |argument, value|
|
89
|
+
object_node = import :Object, value
|
90
|
+
add_relationship :RECEIVED_ARGUMENT, trace_point_node, object_node, argument_name: argument
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
add_relationship :NEXT, last_tracepoint_node, trace_point_node if last_tracepoint_node
|
95
|
+
add_relationship :HAS_PARENT, trace_point_node, parent if parent
|
96
|
+
add_relationship :STARTED_AT, trace_point_node, associated_call if associated_call
|
97
|
+
|
98
|
+
trace_point_node
|
99
|
+
end
|
100
|
+
|
101
|
+
AST_METHODS = %i(
|
102
|
+
keyword operator expression name argument
|
103
|
+
double_colon in else assoc dot selector
|
104
|
+
begin end
|
105
|
+
)
|
106
|
+
|
107
|
+
def extract_code_range(code, rangy_obj)
|
108
|
+
code[rangy_obj.begin_pos..rangy_obj.end_pos - 1] if rangy_obj
|
109
|
+
end
|
110
|
+
|
111
|
+
importer :ASTNode do |node, file_node, parent_db_entry = nil|
|
112
|
+
next nil if !node.respond_to?(:loc)
|
113
|
+
|
114
|
+
node_node = add_node :ASTNode do |n|
|
115
|
+
n.uuid = SecureRandom.uuid
|
116
|
+
|
117
|
+
n.file_path = file_node.props[:path]
|
118
|
+
n.type = node.type if node.respond_to?(:type)
|
119
|
+
|
120
|
+
loc = node.loc
|
121
|
+
n.line = node.line if node.respond_to?(:line)
|
122
|
+
n.column = node.column if node.respond_to?(:column)
|
123
|
+
|
124
|
+
n.loc_class = loc.class.to_s
|
125
|
+
|
126
|
+
if loc.respond_to?(:expression)
|
127
|
+
e = loc.expression
|
128
|
+
%i(first_line last_line begin_loc end_loc).each do |method|
|
129
|
+
n[method] = e.send(method) if e.respond_to?(method)
|
130
|
+
end
|
131
|
+
|
132
|
+
AST_METHODS.each do |method|
|
133
|
+
n[method] = extract_code_range(file_node.props[:content], loc.send(method)) if loc.respond_to?(method)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
n.each_pair {|k, v| n.delete_field(k) if v.nil? }
|
138
|
+
end
|
139
|
+
|
140
|
+
add_relationship :HAS_PARENT, node_node, parent_db_entry if parent_db_entry
|
141
|
+
|
142
|
+
add_relationship :FROM_FILE, node_node, file_node
|
143
|
+
|
144
|
+
if node.respond_to?(:children)
|
145
|
+
node.children.compact.each do |child|
|
146
|
+
import :ASTNode, child, file_node, node_node
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
node_node
|
151
|
+
end
|
152
|
+
|
153
|
+
importer :File do |full_path, content|
|
154
|
+
add_node :File do |node|
|
155
|
+
node.path = full_path
|
156
|
+
node.content = content
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Neo4Apis
|
2
|
+
class Neolytics < Base
|
3
|
+
module TracePointHelpers
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
FILE_LINES = {}
|
8
|
+
|
9
|
+
def each_received_arguments(tp)
|
10
|
+
# Can't just use #method method because some objects implement a #method method
|
11
|
+
method = if tp.self.class.instance_method(:method).source_location.nil?
|
12
|
+
tp.self.method(tp.method_id)
|
13
|
+
else
|
14
|
+
tp.self.class.instance_method(tp.method_id)
|
15
|
+
end
|
16
|
+
parameter_names = method.parameters.map {|_, name| name }
|
17
|
+
arguments = parameter_names.each_with_object({}) do |name, arguments|
|
18
|
+
catch :not_found do
|
19
|
+
arguments[name] = get_trace_point_var(tp, name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
arguments.each do |name, object|
|
23
|
+
value = RubyObject.from_object(object)
|
24
|
+
yield name, value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def each_referenced_variable(tp)
|
29
|
+
line = get_file_line(tp.path, tp.lineno)
|
30
|
+
root = Parser::CurrentRuby.parse(line)
|
31
|
+
extract_variables(root).each do |variable|
|
32
|
+
catch :not_found do
|
33
|
+
value = get_trace_point_var(tp, variable)
|
34
|
+
yield variable, value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
rescue Parser::SyntaxError
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def extract_variables(ast_node)
|
44
|
+
if ast_node.is_a?(Parser::AST::Node)
|
45
|
+
if ast_node.type == :send &&
|
46
|
+
ast_node.children.size == 2 &&
|
47
|
+
ast_node.children[0].nil?
|
48
|
+
[ast_node.children[1]]
|
49
|
+
else
|
50
|
+
ast_node.children.flat_map do |child|
|
51
|
+
extract_variables(child)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
else
|
55
|
+
[]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_file_line(path, lineno)
|
60
|
+
FILE_LINES[path] ||= File.read(path).lines
|
61
|
+
|
62
|
+
FILE_LINES[path][lineno - 1]
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_trace_point_var(tp, var_name)
|
66
|
+
begin
|
67
|
+
tp.binding.local_variable_get(variable)
|
68
|
+
rescue NameError
|
69
|
+
throw :not_found
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/neolytics.rb
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'parser/current'
|
3
|
+
require 'neo4apis'
|
4
|
+
require 'neo4apis/neolytics'
|
5
|
+
|
6
|
+
module Neolytics
|
7
|
+
class Recorder
|
8
|
+
def initialize(neo4j_session)
|
9
|
+
@neo4j_session = neo4j_session
|
10
|
+
@neo4apis_session = Neo4Apis::Neolytics.new(neo4j_session)
|
11
|
+
end
|
12
|
+
|
13
|
+
def record(&block)
|
14
|
+
@neo4apis_session.batch do
|
15
|
+
record_execution_trace do
|
16
|
+
begin
|
17
|
+
block.call
|
18
|
+
rescue Exception => e
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
file_paths = @neo4j_session.query("MATCH (tp) WHERE NOT(tp.path IS NULL) RETURN DISTINCT tp.path AS path").map(&:path)
|
24
|
+
file_paths.each(&method(:record_ast))
|
25
|
+
|
26
|
+
link_query = <<QUERY
|
27
|
+
MATCH (tp:TracePoint), (node:ASTNode)
|
28
|
+
WHERE
|
29
|
+
node.file_path = tp.path AND
|
30
|
+
node.first_line = tp.lineno AND
|
31
|
+
node.name = tp.method_id AND
|
32
|
+
node.type = 'def'
|
33
|
+
MERGE (tp)-[:HAS_AST_NODE]->(node)
|
34
|
+
QUERY
|
35
|
+
@neo4j_session.query(link_query)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def record_ast(file_path)
|
41
|
+
full_path = Pathname.new(file_path).realpath.to_s
|
42
|
+
|
43
|
+
code = File.read(full_path)
|
44
|
+
|
45
|
+
require 'parser/current'
|
46
|
+
root = Parser::CurrentRuby.parse(code)
|
47
|
+
|
48
|
+
file_node = @neo4apis_session.import :File, full_path, code
|
49
|
+
node_node = @neo4apis_session.import :ASTNode, root, file_node
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def record_execution_trace
|
54
|
+
execution_index = 0
|
55
|
+
indent = 0
|
56
|
+
output = ''
|
57
|
+
last_tracepoint_node = nil
|
58
|
+
last_start_time = nil
|
59
|
+
ancestor_stack = []
|
60
|
+
run_time_stack = []
|
61
|
+
|
62
|
+
last_tracepoint_end_time = nil
|
63
|
+
last_run_time = nil
|
64
|
+
|
65
|
+
trace = TracePoint.new do |tp|
|
66
|
+
begin
|
67
|
+
last_run_time = 1_000_000.0 * (Time.now - last_tracepoint_end_time) if last_tracepoint_end_time
|
68
|
+
|
69
|
+
output << tracepoint_string(tp, indent)
|
70
|
+
|
71
|
+
last_method_time = nil
|
72
|
+
if [:call, :c_call].include?(tp.event)
|
73
|
+
run_time_stack.push(0)
|
74
|
+
elsif [:return, :c_return].include?(tp.event)
|
75
|
+
last_method_time = run_time_stack.pop
|
76
|
+
else
|
77
|
+
run_time_stack[-1] += last_run_time if run_time_stack[-1] && last_run_time
|
78
|
+
end
|
79
|
+
|
80
|
+
associated_call = nil
|
81
|
+
if [:return, :c_return].include?(tp.event) && indent.nonzero?
|
82
|
+
indent -= 1
|
83
|
+
associated_call = ancestor_stack.pop
|
84
|
+
elsif [:call, :c_call].include?(tp.event)
|
85
|
+
indent += 1
|
86
|
+
end
|
87
|
+
|
88
|
+
last_tracepoint_node = @neo4apis_session.import :TracePoint, tp,
|
89
|
+
last_method_time,
|
90
|
+
(execution_index += 1),
|
91
|
+
last_tracepoint_node,
|
92
|
+
ancestor_stack.last,
|
93
|
+
associated_call
|
94
|
+
|
95
|
+
if [:call, :c_call].include?(tp.event)
|
96
|
+
ancestor_stack.push(last_tracepoint_node)
|
97
|
+
end
|
98
|
+
|
99
|
+
last_tracepoint_end_time = Time.now
|
100
|
+
rescue Exception => e
|
101
|
+
puts 'EXCEPTION!!'
|
102
|
+
puts e.message
|
103
|
+
puts e.backtrace
|
104
|
+
exit!
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
trace.enable
|
109
|
+
yield
|
110
|
+
ensure
|
111
|
+
trace.disable
|
112
|
+
puts output
|
113
|
+
end
|
114
|
+
|
115
|
+
private
|
116
|
+
|
117
|
+
CYAN = "\e[36m"
|
118
|
+
CLEAR = "\e[0m"
|
119
|
+
GREEN = "\e[32m"
|
120
|
+
|
121
|
+
def tracepoint_string(tp, indent)
|
122
|
+
parts = []
|
123
|
+
parts << "#{'| ' * indent}"
|
124
|
+
parts << "#{CYAN if tp.event == :call}%-8s#{CLEAR}"
|
125
|
+
parts << "%s:%-4d %-18s\n"
|
126
|
+
parts.join(' ') % [tp.event, tp.path, tp.lineno, tp.defined_class.to_s + '#' + GREEN + tp.method_id.to_s + CLEAR]
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
data/neolytics.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'neolytics/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "neolytics"
|
8
|
+
spec.version = Neolytics::VERSION
|
9
|
+
spec.authors = ["Brian Underwood"]
|
10
|
+
spec.email = ["public@brian-underwood.codes"]
|
11
|
+
|
12
|
+
spec.summary = %q{Dumps Ruby code analysis data to Neo4j}
|
13
|
+
spec.description = %q{Dumps Ruby code analysis data to Neo4j}
|
14
|
+
spec.homepage = "http://github.com/neo4jrb/neolytics"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency 'neo4apis', '~> 0.8.2'
|
23
|
+
spec.add_dependency 'neo4j-rake_tasks', '~> 0.3.0'
|
24
|
+
spec.add_dependency 'parser', '~> 2.2.3.0'
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neolytics
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Underwood
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: neo4apis
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.2
|
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.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: neo4j-rake_tasks
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.3.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.3.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: parser
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.2.3.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.2.3.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Dumps Ruby code analysis data to Neo4j
|
98
|
+
email:
|
99
|
+
- public@brian-underwood.codes
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".travis.yml"
|
107
|
+
- CODE_OF_CONDUCT.md
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- lib/neo4apis/neolytics.rb
|
115
|
+
- lib/neo4apis/neolytics/trace_point_helpers.rb
|
116
|
+
- lib/neolytics.rb
|
117
|
+
- lib/neolytics/recorder.rb
|
118
|
+
- lib/neolytics/version.rb
|
119
|
+
- neolytics.gemspec
|
120
|
+
homepage: http://github.com/neo4jrb/neolytics
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 2.4.5.1
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: Dumps Ruby code analysis data to Neo4j
|
144
|
+
test_files: []
|
145
|
+
has_rdoc:
|