trace_graph 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd780ac25e119f53019469ce53d16566fb3acbe251ca04eec7f275b5170bcdae
4
- data.tar.gz: d0055ce4f5bf0c69d384b40b4fb72b88584de876bc830084c3b527fc290a3e88
3
+ metadata.gz: 5e2e5ebf7e939d4bf028dad7f11ff1afe26ee16f69925b007413a5f81f63ae76
4
+ data.tar.gz: 863b4f213222ee2fdf1c22c3d2dd504e9e5a169adadfbf99ad44265b5c7d4a87
5
5
  SHA512:
6
- metadata.gz: 45e82dac33a5477f396d3f4bff13f4eef95bc4ad6435f63a16d94a9268ae08e83009a4e2420e2e7a67b15b8db2c68f27bd141ee6aaed94d35d48085ce562da52
7
- data.tar.gz: 8b4066d99e34ea38b1e1cb4957a6a732b795fa001b1912337f8da12d2926c5351eb495c2df3c630c806fe6be80b2eaca70c2366e7fecb9192e143304b9701fc7
6
+ metadata.gz: 724f8e037289823034a7ff94e8fa49b6839a43d22e29d5bab8b32def090ea4fc98b855502c057c8ee206610b6f1699c906fd999e2265f3a58fadbd7ea8d8ff97
7
+ data.tar.gz: 6c38689b930461cb9ab57c1b86522a73c65fd0a75ee7ec25c3ef1154fadf5f7a6fbaaa36d707bc74aeb6d88df2a5dfdfc95c6a138467a17a8837df656b519fc7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trace_graph (0.1.0)
4
+ trace_graph (0.1.1)
5
5
  ruby-graphviz
6
6
  tree_graph
7
7
 
data/README.md CHANGED
@@ -5,12 +5,55 @@ trying to form a mental picture of it, let TraceGraph draw you a picture like th
5
5
 
6
6
  ![Document Worker Trace](docs/images/document_worker_trace.png)
7
7
 
8
+ Or it can generate a text based graph, like this:
9
+
10
+ ```
11
+ trace
12
+ └─DocumentGenerationWorker#perform
13
+ └─DocumentGenerator#generate_and_store_documents
14
+ └─OutputGenerationWorker#perform
15
+ └─OutputGenerator#generate_and_store_output
16
+ ├─OutputOwnerUtils#current_output
17
+ │ └─OutputOwnerUtils#current_outputs
18
+ ├─OutputGenerator#find_creator
19
+ ├─OutputUtils#local_path
20
+ │ └─Output#local_file_prefix
21
+ ├─Output#s3_path
22
+ │ └─OutputUtils#s3_filename
23
+ └─OutputGenerator#generate_and_store_output_implementation
24
+ ├─OutputUtils#markdown_path
25
+ │ └─Output#local_file_prefix (#2)
26
+ ├─OutputGenerator#generate_output
27
+ │ ├─Style#template_variable_hash
28
+ │ │ ├─Style#template_variables
29
+ │ │ └─Style#template
30
+ │ ├─Document#importurlsupported
31
+ │ ├─Account#current_subscription
32
+ │ │ └─Account#active_subscriptions
33
+ │ ├─Account#current_subscription (#2)
34
+ │ │ └─Account#active_subscriptions (#2)
35
+ │ ├─OutputUtils#markdown_path (#2)
36
+ │ │ └─Output#local_file_prefix (#3)
37
+ │ └─PdfCreator#create_pdf
38
+ │ ├─PdfCreator#localize_images
39
+ │ │ └─PdfCreator#find_image_tags_and_urls
40
+ │ ├─PdfCreator#process_liquid
41
+ │ ├─LatexHelper#make_dollars_safe
42
+ │ └─PdfCreator#build_pandoc_string
43
+ │ ├─PdfCreator#merged_variable_options
44
+ │ ├─PdfCreator#class_options
45
+ │ └─PdfCreator#add_pandoc_options
46
+ └─OutputGenerator#notify_output
47
+ └─PusherOutputNotifier#notify_output
48
+ └─Account#pusher_channel
49
+ ```
50
+
8
51
  ## Installation
9
52
 
10
53
  Add this line to your application's Gemfile:
11
54
 
12
55
  ```ruby
13
- gem 'trace_graph'
56
+ gem 'trace_graph', group: [:development, :test]
14
57
  ```
15
58
 
16
59
  And then execute:
@@ -76,7 +119,8 @@ in the graph.
76
119
  * `excluded_paths` - A list of paths to exclude. Maybe `["my_app/some_utility_helper"]`. Default
77
120
  value is `nil`.
78
121
 
79
- * `png` - A string path where to write a png graph.
122
+ * `png` - A string path where to write a png graph. If no value is passed a png will not be generated
123
+ and only a text representation will be written to standar out.
80
124
 
81
125
  * `mark_duplicate_calls` - Either `true` or `false`. Default value is `false`. When `true` any
82
126
  repeat calls to a method will be marked with a count, and will be colored red on the png.
@@ -92,8 +136,8 @@ A robust tracer might look like this:
92
136
 
93
137
  ```ruby
94
138
  tracer = TraceGraph::Tracer.new({
95
- included_paths: ["my_app/app"], # See everything local to a rails app
96
- excluded_paths: ["my_app/app/helpers"], # Except the helpers
139
+ included_paths: ["my_app/app", "my_app/lib"], # See everything local to a rails app
140
+ excluded_paths: ["my_app/app/helpers"], # Except the helpers
97
141
  mark_duplicate_calls: true,
98
142
  show_arguments: true,
99
143
  show_return_values: true,
@@ -6,14 +6,16 @@ module TraceGraph
6
6
  attr_accessor :label
7
7
  attr_accessor :sub_nodes
8
8
  attr_accessor :is_duplicate
9
+ attr_accessor :class_name
9
10
 
10
11
  alias_method :label_for_tree_graph, :label
11
12
  alias_method :children_for_tree_graph, :sub_nodes
12
13
 
13
- def initialize(label, is_duplicate: false)
14
+ def initialize(label, is_duplicate: false, class_name: nil)
14
15
  self.label = label
15
16
  self.is_duplicate = is_duplicate
16
17
  self.sub_nodes = []
18
+ self.class_name = class_name
17
19
  end
18
20
 
19
21
  def << child_node
@@ -11,6 +11,7 @@ module TraceGraph
11
11
  @mark_duplicate_calls = options.key?(:mark_duplicate_calls) ? options[:mark_duplicate_calls] : true
12
12
  @show_arguments = options[:show_arguments] || false
13
13
  @show_return_values = options[:show_return_values] || false
14
+ @only_class_transitions = options[:only_class_transitions] || false
14
15
 
15
16
  @trace_point = build_trace_point
16
17
  @top_node = TraceGraph::TraceNode.new("trace")
@@ -90,6 +91,10 @@ module TraceGraph
90
91
 
91
92
  def build_node_label(tp, for_call: true)
92
93
  label = "#{tp.defined_class}##{tp.method_id}"
94
+ if tp.defined_class.name != tp.self.class.name
95
+ label = "#{tp.self.class.name} -> #{label}"
96
+ end
97
+
93
98
  args = extract_arguments(tp)
94
99
  if @show_arguments && args.any?
95
100
  label = "#{label} →(#{args})"
@@ -112,9 +117,15 @@ module TraceGraph
112
117
  end
113
118
 
114
119
  def handle_call(tp)
120
+ if @only_class_transitions
121
+ last_node = @stack.last
122
+ if last_node && last_node.class_name == tp.self.class.name
123
+ return
124
+ end
125
+ end
115
126
  parent = @stack.last
116
127
  label, is_duplicate = build_node_label(tp)
117
- new_node = TraceGraph::TraceNode.new(label, is_duplicate: is_duplicate)
128
+ new_node = TraceGraph::TraceNode.new(label, is_duplicate: is_duplicate, class_name: tp.self.class.name)
118
129
  @stack << new_node
119
130
  @all_nodes << new_node
120
131
  if parent
@@ -160,6 +171,7 @@ module TraceGraph
160
171
  unless public_methods.include?(method) || @include_protected
161
172
  should_include = false
162
173
  end
174
+
163
175
  return should_include
164
176
  end
165
177
  end
@@ -1,3 +1,3 @@
1
1
  module TraceGraph
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trace_graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Green
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-12 00:00:00.000000000 Z
11
+ date: 2020-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tree_graph