meta_request 0.7.1 → 0.7.2

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: 49547952caa2d8244dc0342d0068ef44f2d8f2d5d98c6a6aa8ecac22df3e9122
4
- data.tar.gz: d12d541968366874869350e81c716cb818966c6d3e897cb4081f8478b58bfb4a
3
+ metadata.gz: 40d50e7981aca25dd87449d817b7a6e223491be3cb2155ad3ee82e081afce02f
4
+ data.tar.gz: 8fa75570b5c5b41b546f71aa883bd9df3bdf9b76e4a6a38f5498aa3af641e0fd
5
5
  SHA512:
6
- metadata.gz: 37d7b6d8f7475c6e4774e8c98484e19076a462122cd1f9861bd32772e3a8effa758bb08a57d09816f3b56af49ebe26deae2cdd6ae6e3dc605fb2d57fe404cc56
7
- data.tar.gz: 82ee0cd01dfcf01d4e5c8b276f2c9d899bdd2f0aa59e97fe1dcb5a0b4619aacb04d55ca3e28516d9ed364d4e9ef2c1babe2454a5e6aaa679d1e5435c931a12e9
6
+ metadata.gz: 22764f1ec9e723a596e56993c802e541263ce1c7902b88c30902d69701a4b47705c404ce85fd3d2240f5fda7f5d1e85f0512f192647d181e10f30a5f13c6e6a0
7
+ data.tar.gz: 4c62d0983519f5ae3779759aeba06354e6cb9d4c920feb42f9966be91d0615ca8439c7749109435c3d916f1a40d3718b7c9c5dc99d88b50a04ee44b243b74374
data/README.md CHANGED
@@ -35,6 +35,18 @@ end
35
35
 
36
36
  List of available attributes and defaults can be found in [lib/meta_request/config.rb](lib/meta_request/config.rb).
37
37
 
38
+ ## Docker
39
+
40
+ Apps runing in Docker container will have filepaths of the container so links to editor would not work. To fix this, you need to propagate working directory through enviroment variable `SOURCE_PATH`. With docker-compose it can be done like this:
41
+
42
+ ```yaml
43
+ services:
44
+ app:
45
+ environment:
46
+ - SOURCE_PATH=$PWD
47
+ # ...
48
+ ```
49
+
38
50
  ## Development
39
51
 
40
52
  Run all tests:
@@ -24,11 +24,8 @@ module MetaRequest
24
24
  payload[:options][k] = payload.delete(k) unless k.in? CACHE_KEY_COLUMNS
25
25
  end
26
26
 
27
- dev_callsite = Utils.dev_callsite(caller)
28
-
29
- if dev_callsite
30
- payload.merge!(:line => dev_callsite.line, :filename => dev_callsite.filename, :method => dev_callsite.method)
31
- end
27
+ callsite = Utils.dev_callsite(caller)
28
+ payload.merge!(callsite) if callsite
32
29
 
33
30
  Event.new(name, start, ending, transaction_id, payload)
34
31
  }
@@ -43,14 +40,19 @@ module MetaRequest
43
40
 
44
41
  SQL_BLOCK = Proc.new {|*args|
45
42
  name, start, ending, transaction_id, payload = args
46
- dev_callsite = Utils.dev_callsite(caller)
47
-
48
- if dev_callsite
49
- payload.merge!(:line => dev_callsite.line, :filename => dev_callsite.filename, :method => dev_callsite.method)
50
- end
43
+ callsite = Utils.dev_callsite(caller)
44
+ payload.merge!(callsite) if callsite
51
45
 
52
46
  Event.new(SQL_EVENT_NAME, start, ending, transaction_id, payload)
53
47
  }
48
+
49
+ VIEW_BLOCK = Proc.new {|*args|
50
+ name, start, ending, transaction_id, payload = args
51
+ payload[:identifier] = MetaRequest::Utils.sub_source_path(payload[:identifier])
52
+
53
+ Event.new(name, start, ending, transaction_id, payload)
54
+ }
55
+
54
56
  # Subscribe to all events relevant to RailsPanel
55
57
  #
56
58
  def self.subscribe
@@ -58,8 +60,8 @@ module MetaRequest
58
60
  subscribe("meta_request.log").
59
61
  subscribe("sql.active_record", &SQL_BLOCK).
60
62
  subscribe("sql.sequel", &SQL_BLOCK).
61
- subscribe("render_partial.action_view").
62
- subscribe("render_template.action_view").
63
+ subscribe("render_partial.action_view", &VIEW_BLOCK).
64
+ subscribe("render_template.action_view", &VIEW_BLOCK).
63
65
  subscribe("process_action.action_controller.exception").
64
66
  subscribe("process_action.action_controller") do |*args|
65
67
  name, start, ending, transaction_id, payload = args
@@ -1,6 +1,6 @@
1
1
  module MetaRequest
2
2
  class Config
3
- attr_writer :logger, :storage_pool_size
3
+ attr_writer :logger, :storage_pool_size, :source_path
4
4
 
5
5
  # logger used for reporting gem's fatal errors
6
6
  def logger
@@ -12,5 +12,9 @@ module MetaRequest
12
12
  def storage_pool_size
13
13
  @storage_pool_size ||= 20
14
14
  end
15
+
16
+ def source_path
17
+ @source_path ||= ENV['SOURCE_PATH'] || Rails.root.to_s
18
+ end
15
19
  end
16
20
  end
@@ -31,12 +31,11 @@ module MetaRequest
31
31
  super
32
32
  end
33
33
 
34
-
35
34
  private
36
35
  def push_event(level, message)
37
- dev_callsite = AppRequest.current && Utils.dev_callsite(caller[1])
38
- if dev_callsite
39
- payload = {:message => message, :level => level, :line => dev_callsite.line, :filename => dev_callsite.filename, :method => dev_callsite.method}
36
+ callsite = AppRequest.current && Utils.dev_callsite(caller.drop(1))
37
+ if callsite
38
+ payload = callsite.merge(message: message, level: level)
40
39
  AppRequest.current.events << Event.new('meta_request.log', 0, 0, 0, payload)
41
40
  end
42
41
  rescue Exception => e
@@ -1,13 +1,25 @@
1
- require 'callsite'
2
-
3
1
  module MetaRequest
4
2
  module Utils
5
3
  extend self
6
4
 
7
- # @return [Callsite::Line, nil]
8
5
  def dev_callsite(caller)
9
- app_line = Array(caller).detect { |c| c.start_with? MetaRequest.rails_root }
10
- Callsite.parse(app_line) if app_line
6
+ app_line = caller.detect { |c| c.start_with? MetaRequest.rails_root }
7
+ return nil unless app_line
8
+
9
+ _, filename, _, line, _, method = app_line.split(/^(.*?)(:(\d+))(:in `(.*)')?$/)
10
+
11
+ {
12
+ filename: sub_source_path(filename),
13
+ line: line.to_i,
14
+ method: method
15
+ }
16
+ end
17
+
18
+ def sub_source_path(path)
19
+ rails_root = MetaRequest.rails_root
20
+ source_path = MetaRequest.config.source_path
21
+ return path if rails_root == source_path
22
+ path.sub(rails_root, source_path)
11
23
  end
12
24
  end
13
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta_request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dejan Simic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-02 00:00:00.000000000 Z
11
+ date: 2019-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -50,26 +50,6 @@ dependencies:
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '3'
53
- - !ruby/object:Gem::Dependency
54
- name: callsite
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '0.0'
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 0.0.11
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '0.0'
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 0.0.11
73
53
  description: Supporting gem for Rails Panel (Google Chrome extension for Rails development)
74
54
  email: desimic@gmail.com
75
55
  executables: []