open_code-rails 0.3.0 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac340cbee917db96ba7cfa83c00849badd21dc922f38a199602a0423de957ac5
4
- data.tar.gz: b493f03dd96915c4276929d5cc37c96a6e7bef8063e3ac3ead4b9caf35bfe33e
3
+ metadata.gz: 5cab12220ce096856bb5513b33ebc3a79945c240fedc8f4ed70e8dc48f296a14
4
+ data.tar.gz: 521be2a9f86a5205c3f06631928745dfa3f373d32e2e7429da76ef150b1a65f0
5
5
  SHA512:
6
- metadata.gz: 6487b7e205aa51e52a4336faebeebfe5e8e6516afdcadc9e9800f02337cf10893b88b51adb51e7ce22394b1c5efae40008b9d133d4fdd839cd3884b4af721e88
7
- data.tar.gz: 75e8833be7373d620486c53c1306a055a174cfffdf072f584b8dfbe86b3f8c291c5740643f722c76d40566eb0fdf5d961ebdcd1f71bddee5fc978a29f31cc6cd
6
+ metadata.gz: 7abbdd875653c94807aa09ddd6966583fce3a2889381985b93b542d054b791676afdee50c29675ba6285ba796df9c34c73ca1814ac17352ceb9cd3a77c2c8b68
7
+ data.tar.gz: e3281d678ab8b9880494a872753ffcfd32cb73faecd790eec24ddf5f65bb66713a1be5ce226fc2250d914a59587f871a461153db8e491f2ada24f6093abec248
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- open_code-rails (0.3.0)
4
+ open_code-rails (0.4.0)
5
5
  railties (>= 4.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -12,6 +12,10 @@ Add links in exception page to open Application Trace file to line in VSCode. No
12
12
  ![to_line](screenshots/to_line.png)
13
13
  - Custom Settings and Full Trace
14
14
  ![config_full_trace](screenshots/config_full_trace.png)
15
+ - Display URLs in console/log files
16
+ ![logger_url](screenshots/logger_url.png)
17
+ - Per browser settings in localStorage
18
+ ![browser_settings](screenshots/browser_settings.png)
15
19
 
16
20
  ## Installation
17
21
 
@@ -70,6 +74,12 @@ You should put settings in `config/environments/development.rb` because this gem
70
74
  end
71
75
  ```
72
76
 
77
+ 4. `config.open_code.logger_url` - default: `false`
78
+
79
+ Display VSCode/VSCodium urls rather than relative filenames in Rails Logger. So you should see URLs in dev mode console and `development.log`.
80
+
81
+ > This option directly replaces the results of `::Rails.backtrace_cleaner.clean`.
82
+
73
83
  ### Advanced
74
84
 
75
85
  #### Environment Variables
@@ -96,6 +106,14 @@ Some flexibility is probably required for cooperation. Different people may have
96
106
 
97
107
  $ /usr/bin/env FORCE_OPEN_CODE_ROOT_DIR='/my/project/path' rails s
98
108
 
109
+ 4. `FORCE_OPEN_CODE_LOGGER_URL`
110
+
111
+ When is not blank, `config.open_code.logger_url` will be overridden.
112
+
113
+ Set to `false`, `off` or `disabled` to disable this functionality. Blank value will be ignored. All other values will enable this functionality.
114
+
115
+ $ /usr/bin/env FORCE_OPEN_CODE_LOGGER_URL=on rails s
116
+
99
117
  #### Browser
100
118
 
101
119
  This functionality requires [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
@@ -127,3 +145,5 @@ This functionality requires [localStorage](https://developer.mozilla.org/en-US/d
127
145
  - `_openCode.reset()`
128
146
 
129
147
  Reset all settings - back to default.
148
+
149
+ > Changing this settings only applies to the current browser. It does not have any impacts to Rails app.
@@ -5,6 +5,7 @@ module OpenCode
5
5
  class Railtie < ::Rails::Railtie
6
6
  config.open_code = ActiveSupport::OrderedOptions.new
7
7
  config.open_code.editor = 'vscode'
8
+ config.open_code.logger_url = false
8
9
 
9
10
  initializer "open_code.initialize" do
10
11
  abort('open_code-rails should not be used in production mode!') if ::Rails.env.production?
@@ -24,6 +25,30 @@ module OpenCode
24
25
  next unless Middleware.loadable?(cfg)
25
26
 
26
27
  app.middleware.insert_before(ActionDispatch::DebugExceptions, Middleware)
28
+
29
+ logger_url = ENV['FORCE_OPEN_CODE_LOGGOR_URL']
30
+ logger_url = if logger_url.blank?
31
+ cfg.logger_url
32
+ else
33
+ !%w[OFF FALSE DISABLED].include?(logger_url.upcase)
34
+ end
35
+ next unless logger_url
36
+
37
+ scheme = cfg.editor
38
+ root_dir = cfg.root_dir
39
+
40
+ bc = ::Rails.backtrace_cleaner
41
+ bc.class_eval { alias_method :vcr_clean, :clean }
42
+ bc.define_singleton_method(:clean) do |*args|
43
+ vcr_clean(*args).map do |ln|
44
+ begin
45
+ next ln unless ln =~ %r(^\w+\/.+?:in)
46
+ " #{scheme}://file/#{root_dir}/#{ln.split(':in').join(' in')}"
47
+ rescue => _e
48
+ ln
49
+ end
50
+ end
51
+ end
27
52
  end
28
53
  end
29
54
  end
@@ -35,6 +35,19 @@
35
35
 
36
36
  var cssStyle = null;
37
37
 
38
+ function removeLoggerUri() {
39
+ var items = document.querySelectorAll('#Application-Trace .trace-frames, #Full-Trace .trace-frames');
40
+ var rootPath = defaults.rootDir + '/';
41
+ for (var i = 0; i < items.length; i += 1) {
42
+ var item = items[i];
43
+ var line = item.innerText;
44
+ if (line.indexOf(rootPath) < 0) continue;
45
+
46
+ var parts = line.split(rootPath);
47
+ item.innerText = parts[parts.length - 1];
48
+ }
49
+ }
50
+
38
51
  function generateLinks() {
39
52
  if (cssStyle == null) {
40
53
  cssStyle = document.querySelector('style#_open-code-rails_') || false;
@@ -68,7 +81,10 @@
68
81
  }
69
82
  }
70
83
 
71
- setTimeout(generateLinks, 0);
84
+ setTimeout(function () {
85
+ removeLoggerUri();
86
+ generateLinks();
87
+ }, 0);
72
88
  if (!window.localStorage) return;
73
89
 
74
90
  var ROOT_KEY = '_dbg-open_code_';
@@ -123,6 +139,7 @@
123
139
  var val = current[key]
124
140
  r[key] = val == null ? defaults[key] : val;
125
141
  }
142
+ if (r.placeHolder) r.iconUrl = null;
126
143
  return r;
127
144
  },
128
145
  getValue: function (key) {
@@ -1,5 +1,5 @@
1
1
  module OpenCode
2
2
  module Rails
3
- VERSION = "0.3.0".freeze
3
+ VERSION = "0.4.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_code-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Chen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-19 00:00:00.000000000 Z
11
+ date: 2019-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties