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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2c1645c670a1b3417f9bac488213b59772d6e8a
4
- data.tar.gz: c24fc47bafda9d30316f217cc056c40a06400b25
3
+ metadata.gz: ac6b282ffedbbc45d553d26dfc28a36aa02539b3
4
+ data.tar.gz: a229d137f55ca50b7871b43a0e39564b0824d0ab
5
5
  SHA512:
6
- metadata.gz: fae588fedc1ead98cd02f9bee3157d33044f788486137ae261195121bd020169f765fa82d14aced99db170a97c78b54c918f000a369c20f881b928acece283f5
7
- data.tar.gz: e19c02689bb0c08eaa4ce6a47fb480020f2e00d1fb09daef4ff82593ef7a831fecda97999d817443b42bab8397f50985f239fc693822a0721032ec95621f2540
6
+ metadata.gz: 620e07c9d22b14a9ae1a5a1008eb3336e4e72d83d29033b8f29fa6a737429661637d4fdb01e21ab42599b8698eae79233153acab6ef3d6c8d17ed359b02f435b
7
+ data.tar.gz: 7fb670b7f0dd3970681afcc8d33fd96687a5a0ff1f9a4e7b8c4f3deca8e197c2abb889eb0a58afcda0f36c391d86a51c7f27bc33df6d884611350937bf5437e3
@@ -1,5 +1,11 @@
1
1
  ## master
2
2
 
3
+ * More informative stack trace for ParameterMissing error #235
4
+
5
+ ## v1.4.3
6
+
7
+ * Proper implementation of the :subdomain option in routes generation
8
+
3
9
  ## v1.4.2
4
10
 
5
11
  * Added JsRoutes namespace to Engine #230
@@ -1,3 +1,3 @@
1
1
  class JsRoutes
2
- VERSION = "1.4.3"
2
+ VERSION = "1.4.4"
3
3
  end
@@ -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 = function(message) {
14
- this.message = message;
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 = new Error();
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
 
@@ -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 = (@message) -> #
9
- ParameterMissing:: = new Error()
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.3
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: 2017-12-18 00:00:00.000000000 Z
11
+ date: 2018-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties