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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +20 -0
- data/lib/open_code/rails/railtie.rb +25 -0
- data/lib/open_code/rails/vcr.js +18 -1
- data/lib/open_code/rails/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5cab12220ce096856bb5513b33ebc3a79945c240fedc8f4ed70e8dc48f296a14
         | 
| 4 | 
            +
              data.tar.gz: 521be2a9f86a5205c3f06631928745dfa3f373d32e2e7429da76ef150b1a65f0
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 7abbdd875653c94807aa09ddd6966583fce3a2889381985b93b542d054b791676afdee50c29675ba6285ba796df9c34c73ca1814ac17352ceb9cd3a77c2c8b68
         | 
| 7 | 
            +
              data.tar.gz: e3281d678ab8b9880494a872753ffcfd32cb73faecd790eec24ddf5f65bb66713a1be5ce226fc2250d914a59587f871a461153db8e491f2ada24f6093abec248
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        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 | 
             
                
         | 
| 13 13 | 
             
            - Custom Settings and Full Trace
         | 
| 14 14 | 
             
                
         | 
| 15 | 
            +
            - Display URLs in console/log files
         | 
| 16 | 
            +
                
         | 
| 17 | 
            +
            - Per browser settings in localStorage
         | 
| 18 | 
            +
                
         | 
| 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
         | 
    
        data/lib/open_code/rails/vcr.js
    CHANGED
    
    | @@ -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( | 
| 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) {
         | 
    
        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. | 
| 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- | 
| 11 | 
            +
            date: 2019-03-21 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: railties
         |