js-routes 1.4.12 → 1.4.13

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: 87926593b4aa4a92ce85269fafd11238dbba0e8354bd4f4cffd03c56a765f519
4
- data.tar.gz: ad3ee96de22c9b10c89ad38e96eede4ef1fa040051e37cb75e4697a4ecd366e4
3
+ metadata.gz: 597119aa17518bd0b078b80c99c5f2e2a4cb4f5fa58526872b8d960acb9b6102
4
+ data.tar.gz: 285c6f0aca0c140822e89b65afead328bbddc6eb3a08ef85944b68e8c3068515
5
5
  SHA512:
6
- metadata.gz: 2a7309d0f38ab6a923d23571869da7206e0e1aa4541fff1354e15e8fffe3fe634001ee3959dc6033e30044010e63c7e9c910145fdea0f9c0a14f63b391314954
7
- data.tar.gz: ca121924d248b98c5429c1b0a4e2052dd22d48b43eb97ca78b6d18caf29f79b2bb51b78a190c7cecbb2cdd20d2c772f3c137a0ddd11fe49cdd8f525ac9b087e0
6
+ metadata.gz: 501157d25557db0b0511acaa3226ca0fefbb3520bbec48ca9f1005e7300eb2dc0c115e9eae42ef085c17a78c8f2c0822c8b226cb8df639f20a81d9b62de6a421
7
+ data.tar.gz: fecba94667f0a316142d03b8c5b4ca3a95790278a65de6c2b247805d82c16adece41d1a5f395af38913dbd811cdd2c6ad4a8b80c3cae2b30ecc5eec96a27a1c3
@@ -1,6 +1,6 @@
1
1
  ## master
2
2
 
3
- ## v1.4.12
3
+ ## v1.4.13
4
4
 
5
5
  * Improve compatibility with node environment #269.
6
6
  * Change default file location configuration to Webpacker if both Webpacker and Sprockets are loaded
@@ -1,3 +1,3 @@
1
1
  class JsRoutes
2
- VERSION = "1.4.12"
2
+ VERSION = "1.4.13"
3
3
  end
@@ -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, root,
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 (root.jQuery && (root.jQuery.type != null)) {
441
- return root.jQuery.type(obj);
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;
@@ -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 root.jQuery.type(obj) if root.jQuery and root.jQuery.type?
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.12
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-07 00:00:00.000000000 Z
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