trace_location 0.9.3 → 0.9.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -70,9 +70,13 @@ module TraceLocation
70
70
 
71
71
  def extract_method_from(trace_point)
72
72
  if trace_point.self.is_a?(Module)
73
- ::Module.instance_method(:method).bind(trace_point.self).call(trace_point.method_id)
73
+ ::Module.instance_method(:method)
74
+ .bind(trace_point.self)
75
+ .call(trace_point.method_id)
74
76
  else
75
- ::Kernel.instance_method(:method).bind(trace_point.self).call(trace_point.method_id)
77
+ ::Kernel.instance_method(:method)
78
+ .bind(trace_point.self)
79
+ .call(trace_point.method_id)
76
80
  end
77
81
  end
78
82
 
@@ -2,10 +2,10 @@
2
2
 
3
3
  module TraceLocation
4
4
  class Config # :nodoc:
5
- attr_accessor :gems_dir, :dest_dir, :default_format
5
+ attr_accessor :current_dir, :dest_dir, :default_format
6
6
 
7
7
  def initialize
8
- @gems_dir = File.join(Gem.path[0], 'gems')
8
+ @current_dir = Dir.pwd
9
9
  @dest_dir = Dir.pwd
10
10
  @default_format = :markdown
11
11
  end
@@ -9,6 +9,7 @@ module TraceLocation
9
9
 
10
10
  def initialize(events, return_value, options)
11
11
  super
12
+ @current_dir = ::TraceLocation.config.current_dir
12
13
  @dest_dir = options.fetch(:dest_dir) { ::TraceLocation.config.dest_dir }
13
14
  @file_path = File.join(@dest_dir, "trace_location-#{Time.now.strftime('%Y%m%d%H%m%s')}.csv")
14
15
  end
@@ -21,7 +22,7 @@ module TraceLocation
21
22
 
22
23
  private
23
24
 
24
- attr_reader :events, :return_value, :dest_dir, :file_path
25
+ attr_reader :events, :return_value, :current_dir, :dest_dir, :file_path
25
26
 
26
27
  def setup_dir
27
28
  FileUtils.mkdir_p(dest_dir)
@@ -32,7 +33,16 @@ module TraceLocation
32
33
  csv << ATTRIBUTES
33
34
 
34
35
  events.each do |event|
35
- csv << ATTRIBUTES.map { |attr| event.public_send(attr) }
36
+ csv << [
37
+ event.id,
38
+ event.event,
39
+ event.path.to_s.gsub(%r{#{current_dir}/}, ''),
40
+ event.lineno,
41
+ event.caller_path.to_s.gsub(%r{#{current_dir}/}, ''),
42
+ event.caller_lineno,
43
+ event.owner_with_name,
44
+ event.hierarchy
45
+ ]
36
46
  end
37
47
  end
38
48
  end
@@ -11,7 +11,7 @@ module TraceLocation
11
11
 
12
12
  def initialize(events, return_value, options)
13
13
  super
14
- @gems_dir = ::TraceLocation.config.gems_dir
14
+ @current_dir = ::TraceLocation.config.current_dir
15
15
  @dest_dir = options.fetch(:dest_dir) { ::TraceLocation.config.dest_dir }
16
16
  @current = Time.now
17
17
  @filename = "trace_location-#{@current.strftime('%Y%m%d%H%m%s')}.log"
@@ -26,7 +26,7 @@ module TraceLocation
26
26
 
27
27
  private
28
28
 
29
- attr_reader :events, :return_value, :gems_dir, :dest_dir, :current, :filename, :file_path
29
+ attr_reader :events, :return_value, :current_dir, :dest_dir, :current, :filename, :file_path
30
30
 
31
31
  def setup_dir
32
32
  FileUtils.mkdir_p(dest_dir)
@@ -46,12 +46,11 @@ module TraceLocation
46
46
  end
47
47
 
48
48
  def format_events(events)
49
- events.select(&:valid?).map do |e|
50
- indent = indent(e.hierarchy)
51
- event = EVENTS[e.event]
52
- path = e.path.to_s.gsub(%r{#{gems_dir}/}, '')
49
+ events.select(&:valid?).map do |event|
50
+ indent = indent(event.hierarchy)
51
+ path = event.path.to_s.gsub(%r{#{current_dir}/}, '')
53
52
 
54
- %(#{indent}#{event} #{path}:#{e.lineno} [#{e.owner_with_name}])
53
+ %(#{indent}#{EVENTS[event.event]} #{path}:#{event.lineno} [#{event.owner_with_name}])
55
54
  end
56
55
  end
57
56
 
@@ -5,7 +5,7 @@ module TraceLocation
5
5
  class Markdown < Base # :nodoc:
6
6
  def initialize(events, return_value, options)
7
7
  super
8
- @gems_dir = ::TraceLocation.config.gems_dir
8
+ @current_dir = ::TraceLocation.config.current_dir
9
9
  @dest_dir = options.fetch(:dest_dir) { ::TraceLocation.config.dest_dir }
10
10
  @current = Time.now
11
11
  @filename = "trace_location-#{@current.strftime('%Y%m%d%H%m%s')}.md"
@@ -20,7 +20,7 @@ module TraceLocation
20
20
 
21
21
  private
22
22
 
23
- attr_reader :events, :return_value, :gems_dir, :dest_dir, :current, :filename, :file_path
23
+ attr_reader :events, :return_value, :current_dir, :dest_dir, :current, :filename, :file_path
24
24
 
25
25
  def setup_dir
26
26
  FileUtils.mkdir_p(dest_dir)
@@ -34,8 +34,9 @@ module TraceLocation
34
34
  MARKDOWN
35
35
 
36
36
  events.select(&:call?).each do |e|
37
- path = e.path.to_s.gsub(%r{#{gems_dir}/}, '')
38
- caller_path = e.caller_path.to_s.gsub(%r{#{gems_dir}/}, '')
37
+ path = e.path.to_s.gsub(%r{#{current_dir}/}, '')
38
+ caller_path = e.caller_path.to_s.gsub(%r{#{current_dir}/}, '')
39
+
39
40
  io.write <<~MARKDOWN
40
41
  <details open>
41
42
  <summary>#{path}:#{e.lineno}</summary>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TraceLocation
4
- VERSION = '0.9.3'
4
+ VERSION = '0.9.3.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trace_location
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshiyuki Hirano
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-06 00:00:00.000000000 Z
11
+ date: 2019-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: binding_of_caller
@@ -92,7 +92,6 @@ files:
92
92
  - ".rspec"
93
93
  - ".rubocop.yml"
94
94
  - ".travis.yml"
95
- - CHANGELOG.md
96
95
  - Gemfile
97
96
  - Gemfile.lock
98
97
  - LICENSE.txt
@@ -100,6 +99,21 @@ files:
100
99
  - Rakefile
101
100
  - bin/console
102
101
  - bin/setup
102
+ - examples/active_record_establish_connection/result.csv
103
+ - examples/active_record_establish_connection/result.log
104
+ - examples/active_record_establish_connection/result.md
105
+ - examples/active_record_validation_process/result.csv
106
+ - examples/active_record_validation_process/result.log
107
+ - examples/active_record_validation_process/result.md
108
+ - examples/has_secure_password/result.csv
109
+ - examples/has_secure_password/result.log
110
+ - examples/has_secure_password/result.md
111
+ - examples/lifecycle_of_rails_application/result.csv
112
+ - examples/lifecycle_of_rails_application/result.log
113
+ - examples/lifecycle_of_rails_application/result.md
114
+ - examples/rendering_process/result.csv
115
+ - examples/rendering_process/result.log
116
+ - examples/rendering_process/result.md
103
117
  - lib/trace_location.rb
104
118
  - lib/trace_location/collector.rb
105
119
  - lib/trace_location/config.rb
data/CHANGELOG.md DELETED
@@ -1,19 +0,0 @@
1
- ## v0.3.0
2
-
3
- - Log path is shorten
4
- - Use gems_dir instead of root_dir
5
- - Don't collect not including gems_dir
6
- - Fix Regexp
7
-
8
- ## v0.2.0
9
-
10
- - Refactoring: Separate Collector/Report/Generator
11
- - Display class method or instance method
12
-
13
- ## v0.1.1
14
-
15
- - Update README
16
-
17
- ## v0.1.0
18
-
19
- - Initial Release