source_route 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -18
- data/examples/show_init_files_when_rails_server_start.rb +33 -0
- data/lib/source_route/tp_result.rb +7 -8
- data/lib/source_route/version.rb +1 -1
- data/lib/source_route/wrapper.rb +11 -7
- data/lib/source_route.rb +1 -1
- data/test/test_helper.rb +2 -2
- data/test/wrapper_test.rb +13 -5
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9a1ba833697d52c2138c558b5c94ec6dec3516d
|
4
|
+
data.tar.gz: 1635e5de83aaf367d91b9867c68b38fc269df07e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf1d68cce07fb6b22ba6e0a01b297ec383ae3bc82cd5ce98404207b649e0abaab1d5be2b491a59ad80f3c288cd1a2377fa0c816602c452239bc9142735d74be2
|
7
|
+
data.tar.gz: cefc0e26d83f5f9488f203ff12d28224cd02d7473b6af0bc07db6596f8a5d6f1773f8d119ff6abb9ee94ad68f2d51e9bff8d6ddbb32eeb7bbeea16d350d660bf
|
data/README.md
CHANGED
@@ -35,21 +35,4 @@ Or install it yourself as:
|
|
35
35
|
|
36
36
|
### TODO
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
|
42
|
-
files = []
|
43
|
-
tp = TracePoint.new(:line) do |tp|
|
44
|
-
if tp.path =~ /bole_api/
|
45
|
-
unless files.include? tp.path
|
46
|
-
puts "#{tp.path}".inspect
|
47
|
-
files.push(tp.path)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
tp.enable
|
52
|
-
|
53
|
-
```
|
54
|
-
|
55
|
-
It's better to add html output format, 'cause it can be kept.
|
38
|
+
Add debug option to provider more verbose messages of what has happened
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# copy this file content to bin/rails, then run ./bin/rails s, it should show init files in order
|
4
|
+
|
5
|
+
require 'source_route'
|
6
|
+
|
7
|
+
SourceRoute.enable do
|
8
|
+
file_paths = []
|
9
|
+
event :line
|
10
|
+
path 'your_rails_application_root_dir_name'
|
11
|
+
output_format do |tp|
|
12
|
+
unless file_paths.include? tp.path
|
13
|
+
puts tp.path
|
14
|
+
file_paths.push(tp.path)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# The above source route block defines similar trace point feature as following
|
20
|
+
# files = []
|
21
|
+
# tp = TracePoint.new(:line) do |tp|
|
22
|
+
# if tp.path =~ /your_rails_application_root_dir_name/
|
23
|
+
# unless files.include? tp.path
|
24
|
+
# puts "#{tp.path}".inspect
|
25
|
+
# files.push(tp.path)
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
# tp.enable
|
30
|
+
|
31
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
32
|
+
require_relative '../config/boot'
|
33
|
+
require 'rails/commands'
|
@@ -29,27 +29,26 @@ module SourceRoute
|
|
29
29
|
@collect_data
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
def output
|
32
|
+
def output(tp_ins)
|
34
33
|
|
35
|
-
format = @output_config[:output_format]
|
34
|
+
format = @output_config[:output_format]
|
35
|
+
format = format.to_sym if format.respond_to? :to_sym
|
36
36
|
|
37
37
|
case format
|
38
38
|
when :none
|
39
39
|
# do nothing
|
40
|
-
when :console
|
40
|
+
when :console # need @collect_data
|
41
41
|
console_put
|
42
42
|
when :html
|
43
43
|
# I cant solve the problem: to generate html at the end,
|
44
44
|
# I have to know when the application is end
|
45
45
|
when :test
|
46
46
|
# do nothing at now
|
47
|
-
when
|
48
|
-
|
49
|
-
# format.call(tp)
|
47
|
+
when Proc
|
48
|
+
format.call(tp_ins)
|
50
49
|
else
|
51
50
|
klass = "SourceRoute::Formats::#{format.to_s.capitalize}"
|
52
|
-
::SourceRoute.const_get(klass).render(self,
|
51
|
+
::SourceRoute.const_get(klass).render(self, tp_ins)
|
53
52
|
end
|
54
53
|
end
|
55
54
|
|
data/lib/source_route/version.rb
CHANGED
data/lib/source_route/wrapper.rb
CHANGED
@@ -13,7 +13,7 @@ module SourceRoute
|
|
13
13
|
# output_format can be console, html
|
14
14
|
def reset
|
15
15
|
@tp.disable if @tp
|
16
|
-
@conditions = OpenStruct.new(events: :call, negative: {}, positive: {},
|
16
|
+
@conditions = OpenStruct.new(events: [:call], negative: {}, positive: {},
|
17
17
|
result_config: { output_format: 'none',
|
18
18
|
selected_attrs: nil,
|
19
19
|
include_local_var: false,
|
@@ -27,6 +27,7 @@ module SourceRoute
|
|
27
27
|
@conditions.events = Array(v).map(&:to_sym) unless v.nil?
|
28
28
|
end
|
29
29
|
alias :event :events
|
30
|
+
|
30
31
|
def set_result_config(value)
|
31
32
|
unless value.is_a? Hash
|
32
33
|
conditions.result_config = value
|
@@ -34,15 +35,15 @@ module SourceRoute
|
|
34
35
|
end
|
35
36
|
|
36
37
|
def output_format(data = nil, &block)
|
37
|
-
conditions.result_config[:output_format] = if
|
38
|
+
conditions.result_config[:output_format] = if block_given?
|
38
39
|
block
|
39
40
|
else
|
40
41
|
data
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
|
-
def selected_attrs(
|
45
|
-
conditions.result_config[:selected_attrs] =
|
45
|
+
def selected_attrs(*attr)
|
46
|
+
conditions.result_config[:selected_attrs] = Array(attr)
|
46
47
|
end
|
47
48
|
|
48
49
|
def output_include_local_variables
|
@@ -79,9 +80,12 @@ module SourceRoute
|
|
79
80
|
end
|
80
81
|
next if positive_break
|
81
82
|
|
82
|
-
|
83
|
-
|
84
|
-
|
83
|
+
unless conditions[:result_config][:output_format].is_a? Proc
|
84
|
+
ret_data = tp_result.build(tp)
|
85
|
+
tp_attrs_results.push(ret_data)
|
86
|
+
end
|
87
|
+
|
88
|
+
tp_result.output(tp)
|
85
89
|
end
|
86
90
|
track.enable
|
87
91
|
self.tp = track
|
data/lib/source_route.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/wrapper_test.rb
CHANGED
@@ -39,7 +39,7 @@ module SourceRoute
|
|
39
39
|
assert @wrapper.tp_attrs_results.size > 0
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
42
|
+
def test_match_class_name
|
43
43
|
@source_route = SourceRoute.enable do
|
44
44
|
defined_class 'SampleApp'
|
45
45
|
end
|
@@ -67,12 +67,19 @@ module SourceRoute
|
|
67
67
|
assert_equal 0, @wrapper.tp_attrs_results.size
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
71
|
-
|
70
|
+
def test_source_route_with_block_only
|
71
|
+
paths = []
|
72
|
+
SourceRoute.enable 'nonsense' do
|
72
73
|
SampleApp.new.nonsense
|
74
|
+
output_format do |tp|
|
75
|
+
paths.push tp.path
|
76
|
+
end
|
73
77
|
end
|
74
|
-
|
75
|
-
|
78
|
+
SampleApp.new.nonsense
|
79
|
+
|
80
|
+
assert_equal 0, @wrapper.tp_attrs_results.size
|
81
|
+
assert_equal 1, paths.size
|
82
|
+
assert_includes paths.first, 'sample_app'
|
76
83
|
end
|
77
84
|
|
78
85
|
def test_trace_without_first_hash_option
|
@@ -94,6 +101,7 @@ module SourceRoute
|
|
94
101
|
def test_show_local_variables
|
95
102
|
SourceRoute.enable 'nonsense_with_params' do
|
96
103
|
output_include_local_variables
|
104
|
+
output_format :console
|
97
105
|
end
|
98
106
|
|
99
107
|
SampleApp.new.nonsense_with_params(88)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: source_route
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- raykin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- LICENSE.txt
|
108
108
|
- README.md
|
109
109
|
- Rakefile
|
110
|
+
- examples/show_init_files_when_rails_server_start.rb
|
110
111
|
- lib/source_route.rb
|
111
112
|
- lib/source_route/formats/html.rb
|
112
113
|
- lib/source_route/formats/html_template.slim
|
@@ -148,3 +149,4 @@ test_files:
|
|
148
149
|
- test/sample_app.rb
|
149
150
|
- test/test_helper.rb
|
150
151
|
- test/wrapper_test.rb
|
152
|
+
has_rdoc:
|