js-routes 1.4.3 → 1.4.4
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/CHANGELOG.md +6 -0
- data/lib/js_routes/version.rb +1 -1
- data/lib/routes.js +26 -4
- data/lib/routes.js.coffee +21 -2
- data/spec/js_routes/rails_routes_compatibility_spec.rb +13 -0
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ac6b282ffedbbc45d553d26dfc28a36aa02539b3
         | 
| 4 | 
            +
              data.tar.gz: a229d137f55ca50b7871b43a0e39564b0824d0ab
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 620e07c9d22b14a9ae1a5a1008eb3336e4e72d83d29033b8f29fa6a737429661637d4fdb01e21ab42599b8698eae79233153acab6ef3d6c8d17ed359b02f435b
         | 
| 7 | 
            +
              data.tar.gz: 7fb670b7f0dd3970681afcc8d33fd96687a5a0ff1f9a4e7b8c4f3deca8e197c2abb889eb0a58afcda0f36c391d86a51c7f27bc33df6d884611350937bf5437e3
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/lib/js_routes/version.rb
    CHANGED
    
    
    
        data/lib/routes.js
    CHANGED
    
    | @@ -10,11 +10,33 @@ Based on Rails routes of APP_CLASS | |
| 10 10 |  | 
| 11 11 | 
             
              root = typeof exports !== "undefined" && exports !== null ? exports : this;
         | 
| 12 12 |  | 
| 13 | 
            -
              ParameterMissing  | 
| 14 | 
            -
                 | 
| 15 | 
            -
             | 
| 13 | 
            +
              function ParameterMissing(message, fileName, lineNumber) {
         | 
| 14 | 
            +
                var instance = new Error(message, fileName, lineNumber);
         | 
| 15 | 
            +
                if(Object.setPrototypeOf) {
         | 
| 16 | 
            +
                  Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
         | 
| 17 | 
            +
                } else {
         | 
| 18 | 
            +
                  instance.__proto__ = this.__proto__;
         | 
| 19 | 
            +
                }
         | 
| 20 | 
            +
                if (Error.captureStackTrace) {
         | 
| 21 | 
            +
                  Error.captureStackTrace(instance, ParameterMissing);
         | 
| 22 | 
            +
                }
         | 
| 23 | 
            +
                return instance;
         | 
| 24 | 
            +
              }
         | 
| 16 25 |  | 
| 17 | 
            -
              ParameterMissing.prototype =  | 
| 26 | 
            +
              ParameterMissing.prototype = Object.create(Error.prototype, {
         | 
| 27 | 
            +
                constructor: {
         | 
| 28 | 
            +
                  value: Error,
         | 
| 29 | 
            +
                  enumerable: false,
         | 
| 30 | 
            +
                  writable: true,
         | 
| 31 | 
            +
                  configurable: true
         | 
| 32 | 
            +
                }
         | 
| 33 | 
            +
              });
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              if (Object.setPrototypeOf){
         | 
| 36 | 
            +
                Object.setPrototypeOf(ParameterMissing, Error);
         | 
| 37 | 
            +
              } else {
         | 
| 38 | 
            +
                ParameterMissing.__proto__ = Error;
         | 
| 39 | 
            +
              }
         | 
| 18 40 |  | 
| 19 41 | 
             
              NodeTypes = NODE_TYPES;
         | 
| 20 42 |  | 
    
        data/lib/routes.js.coffee
    CHANGED
    
    | @@ -5,8 +5,27 @@ Based on Rails routes of APP_CLASS | |
| 5 5 | 
             
            # root is this
         | 
| 6 6 | 
             
            root = (exports ? this)
         | 
| 7 7 |  | 
| 8 | 
            -
            ParameterMissing = ( | 
| 9 | 
            -
             | 
| 8 | 
            +
            ParameterMissing = (message, fileName, lineNumber) ->
         | 
| 9 | 
            +
              instance = new Error(message, fileName, lineNumber)
         | 
| 10 | 
            +
              if Object.setPrototypeOf
         | 
| 11 | 
            +
                Object.setPrototypeOf instance, Object.getPrototypeOf(this)
         | 
| 12 | 
            +
              else
         | 
| 13 | 
            +
                instance.__proto__ = this.__proto__
         | 
| 14 | 
            +
              if Error.captureStackTrace
         | 
| 15 | 
            +
                Error.captureStackTrace instance, ParameterMissing
         | 
| 16 | 
            +
              instance
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            ParameterMissing.prototype = Object.create(Error.prototype, constructor:
         | 
| 19 | 
            +
              value: Error
         | 
| 20 | 
            +
              enumerable: false
         | 
| 21 | 
            +
              writable: true
         | 
| 22 | 
            +
              configurable: true
         | 
| 23 | 
            +
            )
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            if Object.setPrototypeOf
         | 
| 26 | 
            +
              Object.setPrototypeOf(ParameterMissing, Error)
         | 
| 27 | 
            +
            else
         | 
| 28 | 
            +
              ParameterMissing.__proto__ = Error
         | 
| 10 29 |  | 
| 11 30 | 
             
            NodeTypes = NODE_TYPES
         | 
| 12 31 | 
             
            SpecialOptionsKey = SPECIAL_OPTIONS_KEY
         | 
| @@ -25,6 +25,19 @@ describe JsRoutes, "compatibility with Rails"  do | |
| 25 25 | 
             
                  .to raise_error('Route parameter missing: title')
         | 
| 26 26 | 
             
              end
         | 
| 27 27 |  | 
| 28 | 
            +
              it "should produce error stacktraces including function names" do
         | 
| 29 | 
            +
                 stacktrace = evaljs("
         | 
| 30 | 
            +
                    (function(){
         | 
| 31 | 
            +
                      try {
         | 
| 32 | 
            +
                        Routes.thing_path()
         | 
| 33 | 
            +
                      } catch(e) {
         | 
| 34 | 
            +
                        return e.stack;
         | 
| 35 | 
            +
                      }
         | 
| 36 | 
            +
                    })()
         | 
| 37 | 
            +
                  ")
         | 
| 38 | 
            +
                expect(stacktrace).to include "thing_path"
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
             | 
| 28 41 | 
             
              it "should support 0 as a member parameter" do
         | 
| 29 42 | 
             
                expect(evaljs("Routes.inbox_path(0)")).to eq(test_routes.inbox_path(0))
         | 
| 30 43 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: js-routes
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.4. | 
| 4 | 
            +
              version: 1.4.4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Bogdan Gusiev
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2018-05-07 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: railties
         |