js-routes 1.4.12 → 1.4.13
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 +1 -1
- data/lib/js_routes/version.rb +1 -1
- data/lib/routes.js +7 -6
- data/lib/routes.js.coffee +9 -4
- data/spec/js_routes/amd_compatibility_spec.rb +0 -8
- data/spec/js_routes/common_js_compatibility_spec.rb +12 -0
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 597119aa17518bd0b078b80c99c5f2e2a4cb4f5fa58526872b8d960acb9b6102
         | 
| 4 | 
            +
              data.tar.gz: 285c6f0aca0c140822e89b65afead328bbddc6eb3a08ef85944b68e8c3068515
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 501157d25557db0b0511acaa3226ca0fefbb3520bbec48ca9f1005e7300eb2dc0c115e9eae42ef085c17a78c8f2c0822c8b226cb8df639f20a81d9b62de6a421
         | 
| 7 | 
            +
              data.tar.gz: fecba94667f0a316142d03b8c5b4ca3a95790278a65de6c2b247805d82c16adece41d1a5f395af38913dbd811cdd2c6ad4a8b80c3cae2b30ecc5eec96a27a1c3
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/lib/js_routes/version.rb
    CHANGED
    
    
    
        data/lib/routes.js
    CHANGED
    
    | @@ -4,12 +4,10 @@ Based on Rails RAILS_VERSION routes of APP_CLASS | |
| 4 4 | 
             
             */
         | 
| 5 5 |  | 
| 6 6 | 
             
            (function() {
         | 
| 7 | 
            -
              var DeprecatedGlobbingBehavior, NodeTypes, ParameterMissing, ReservedOptions, SpecialOptionsKey, UriEncoderSegmentRegex, Utils, result, | 
| 7 | 
            +
              var DeprecatedGlobbingBehavior, NodeTypes, ParameterMissing, ReservedOptions, SpecialOptionsKey, UriEncoderSegmentRegex, Utils, result,
         | 
| 8 8 | 
             
                hasProp = {}.hasOwnProperty,
         | 
| 9 9 | 
             
                slice = [].slice;
         | 
| 10 10 |  | 
| 11 | 
            -
              root = typeof exports !== "undefined" && exports !== null ? exports : this;
         | 
| 12 | 
            -
             | 
| 13 11 | 
             
              ParameterMissing = function(message, fileName, lineNumber) {
         | 
| 14 12 | 
             
                var instance;
         | 
| 15 13 | 
             
                instance = new Error(message, fileName, lineNumber);
         | 
| @@ -437,8 +435,8 @@ Based on Rails RAILS_VERSION routes of APP_CLASS | |
| 437 435 | 
             
                  return this._classToTypeCache;
         | 
| 438 436 | 
             
                },
         | 
| 439 437 | 
             
                get_object_type: function(obj) {
         | 
| 440 | 
            -
                  if ( | 
| 441 | 
            -
                    return  | 
| 438 | 
            +
                  if (this.jQuery && (this.jQuery.type != null)) {
         | 
| 439 | 
            +
                    return this.jQuery.type(obj);
         | 
| 442 440 | 
             
                  }
         | 
| 443 441 | 
             
                  if (obj == null) {
         | 
| 444 442 | 
             
                    return "" + obj;
         | 
| @@ -500,7 +498,6 @@ Based on Rails RAILS_VERSION routes of APP_CLASS | |
| 500 498 | 
             
                  routes.default_serializer = function(object, prefix) {
         | 
| 501 499 | 
             
                    return Utils.default_serializer(object, prefix);
         | 
| 502 500 | 
             
                  };
         | 
| 503 | 
            -
                  Utils.namespace(root, NAMESPACE, routes);
         | 
| 504 501 | 
             
                  return Object.assign({
         | 
| 505 502 | 
             
                    "default": routes
         | 
| 506 503 | 
             
                  }, routes);
         | 
| @@ -513,6 +510,10 @@ Based on Rails RAILS_VERSION routes of APP_CLASS | |
| 513 510 | 
             
                define([], function() {
         | 
| 514 511 | 
             
                  return result;
         | 
| 515 512 | 
             
                });
         | 
| 513 | 
            +
              } else if (typeof module !== "undefined" && module !== null) {
         | 
| 514 | 
            +
                module.exports = result;
         | 
| 515 | 
            +
              } else {
         | 
| 516 | 
            +
                Utils.namespace(this, NAMESPACE, result);
         | 
| 516 517 | 
             
              }
         | 
| 517 518 |  | 
| 518 519 | 
             
              return result;
         | 
    
        data/lib/routes.js.coffee
    CHANGED
    
    | @@ -2,7 +2,6 @@ | |
| 2 2 | 
             
            File generated by js-routes GEM_VERSION
         | 
| 3 3 | 
             
            Based on Rails RAILS_VERSION routes of APP_CLASS
         | 
| 4 4 | 
             
            ###
         | 
| 5 | 
            -
            root = (exports ? this)
         | 
| 6 5 |  | 
| 7 6 | 
             
            ParameterMissing = (message, fileName, lineNumber) ->
         | 
| 8 7 | 
             
              instance = new Error(message, fileName, lineNumber)
         | 
| @@ -363,7 +362,7 @@ Utils = | |
| 363 362 | 
             
                  @_classToTypeCache["[object #{name}]"] = name.toLowerCase()
         | 
| 364 363 | 
             
                @_classToTypeCache
         | 
| 365 364 | 
             
              get_object_type: (obj) ->
         | 
| 366 | 
            -
                return  | 
| 365 | 
            +
                return this.jQuery.type(obj) if this.jQuery and this.jQuery.type?
         | 
| 367 366 | 
             
                return "#{obj}" unless obj?
         | 
| 368 367 | 
             
                (if typeof obj is "object" or typeof obj is "function" then @_classToType()[Object::toString.call(obj)] or "object" else typeof obj)
         | 
| 369 368 |  | 
| @@ -395,13 +394,19 @@ Utils = | |
| 395 394 | 
             
                routes.config = -> Utils.config()
         | 
| 396 395 | 
             
                routes.default_serializer = (object, prefix) ->
         | 
| 397 396 | 
             
                  Utils.default_serializer(object, prefix)
         | 
| 398 | 
            -
                # Browser globals
         | 
| 399 | 
            -
                Utils.namespace(root, NAMESPACE, routes)
         | 
| 400 397 | 
             
                Object.assign({default: routes}, routes)
         | 
| 401 398 |  | 
| 402 399 | 
             
            result = Utils.make()
         | 
| 400 | 
            +
             | 
| 403 401 | 
             
            # Set up Routes appropriately for the environment.
         | 
| 404 402 | 
             
            if typeof define is "function" and define.amd
         | 
| 405 403 | 
             
              # AMD
         | 
| 406 404 | 
             
              define [], -> result
         | 
| 405 | 
            +
            else if module?
         | 
| 406 | 
            +
              # CommonJS
         | 
| 407 | 
            +
              module.exports = result
         | 
| 408 | 
            +
            else
         | 
| 409 | 
            +
              # Browser globals
         | 
| 410 | 
            +
              Utils.namespace(this, NAMESPACE, result)
         | 
| 411 | 
            +
             | 
| 407 412 | 
             
            return result
         | 
| @@ -27,14 +27,6 @@ EOF | |
| 27 27 | 
             
                evaljs(JsRoutes.generate({}))
         | 
| 28 28 | 
             
              end
         | 
| 29 29 |  | 
| 30 | 
            -
              it "should working from global scope" do
         | 
| 31 | 
            -
                expect(evaljs("Routes.inboxes_path()")).to eq(test_routes.inboxes_path())
         | 
| 32 | 
            -
              end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
              it "should working from define function" do
         | 
| 35 | 
            -
                expect(evaljs("Routes.inboxes_path()")).to eq(evaljs("GlobalCheck['js-routes'].inboxes_path()"))
         | 
| 36 | 
            -
              end
         | 
| 37 | 
            -
             | 
| 38 30 | 
             
              it "should working from require" do
         | 
| 39 31 | 
             
                expect(evaljs("require(['js-routes'], function(r){ return r.inboxes_path(); })")).to eq(test_routes.inboxes_path())
         | 
| 40 32 | 
             
              end
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            require "spec_helper"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe JsRoutes, "compatibility with CommonJS (node)"  do
         | 
| 4 | 
            +
              before(:each) do
         | 
| 5 | 
            +
                evaljs("module = { exports: null }")
         | 
| 6 | 
            +
                evaljs(JsRoutes.generate({}))
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              it "should define module exports" do
         | 
| 10 | 
            +
                expect(evaljs("module.exports.inboxes_path()")).to eq(test_routes.inboxes_path())
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
            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.13
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Bogdan Gusiev
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020-12- | 
| 11 | 
            +
            date: 2020-12-09 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: railties
         | 
| @@ -176,6 +176,7 @@ files: | |
| 176 176 | 
             
            - spec/dummy/app/assets/javascripts/.gitkeep
         | 
| 177 177 | 
             
            - spec/dummy/config/routes.rb
         | 
| 178 178 | 
             
            - spec/js_routes/amd_compatibility_spec.rb
         | 
| 179 | 
            +
            - spec/js_routes/common_js_compatibility_spec.rb
         | 
| 179 180 | 
             
            - spec/js_routes/default_serializer_spec.rb
         | 
| 180 181 | 
             
            - spec/js_routes/generated_javascript_spec.rb
         | 
| 181 182 | 
             
            - spec/js_routes/options_spec.rb
         |