ts_routes 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41ebddaca537c82f8c13f7e16a1bf7c2e8e7a3a7
4
- data.tar.gz: f6f82e0c73649d740fca92eb3648abd71de65044
3
+ metadata.gz: 5791b921e57c9b8768e01ec57f89ae9c6f0f4df3
4
+ data.tar.gz: f4b841749d954fea3dd98a8282d78ae6cac99a8a
5
5
  SHA512:
6
- metadata.gz: 305e44d28094f5dc7dbea2e645d7d0034250288e04bc3de9b5c8152a155951bb46a44ac3bec5c78c1a8a523c45106fa15a932bf5f2d3d1d77eb9fbc5af275727
7
- data.tar.gz: cb68c7e82175b4d52ef4ac5c80041e5f4a5c109345cf7083c1b5e3f02330e81eb883a1bd39948d47e65686ab2c951b506c2b071c03a2659ebd5b7163ad66e220
6
+ metadata.gz: 620ce508b12955929636d97a8206158a59d596263c7b5e66fef5d90ef068af62516052606dd551f9aed6e28a5b82e8ede3a20de73739e01af506200e3412c0fd
7
+ data.tar.gz: e145fbd28361b12b71bab30213479489ece90e92c511017f5ade3d5b2593d38152a1bf7e8306106a2c669a81a1961e6175581ad773f030b45600d96378b3c2c0
data/.rubocop.yml CHANGED
@@ -2,7 +2,8 @@ AllCops:
2
2
  TargetRubyVersion: 2.3
3
3
  DisplayCopNames: true
4
4
  Exclude:
5
- - tasks/**/*.*
5
+ - "vendor/**/*"
6
+ - "node_modules/**/*"
6
7
 
7
8
  Style:
8
9
  Enabled: false
data/.travis.yml CHANGED
@@ -5,12 +5,14 @@ rvm:
5
5
  - "2.3"
6
6
  - "2.4"
7
7
 
8
- language: node_js
9
- node_js:
10
- - "6"
8
+ before_install:
9
+ - nvm install 8
10
+ - npm install
11
11
 
12
- install:
13
- - bin/setup
12
+ cache:
13
+ bundler: true
14
+ directories:
15
+ - node_modules
14
16
 
15
17
  script:
16
18
  - bundle exec rake
@@ -15,13 +15,19 @@ function $buildOptions(options: any, names: string[]): string {
15
15
  const value = options[ key ];
16
16
 
17
17
  if (key === "anchor") {
18
- anchor = "#" + encodeURIComponent("" + value);
18
+ anchor = `#${$encode(value)}`;
19
+ } else if ($isScalarType(value)) {
20
+ q.push(`${$encode(key)}=${$encode(value)}`);
19
21
  } else if (Array.isArray(value)) {
20
22
  for (const v of value) {
21
- q.push(encodeURIComponent(key + "[]") + "=" + encodeURIComponent("" + v));
23
+ const k = `${key}[]`;
24
+ q.push(`${$encode(k)}=${$encode(v)}`);
25
+ }
26
+ } else if($isNotNull(value)) { // i.e. non-null, non-scalar, non-array type
27
+ for (const k of Object.keys(value)) {
28
+ const hk = `${key}[${k}]`;
29
+ q.push(`${$encode(hk)}=${$encode(value[k])}`);
22
30
  }
23
- } else if(value !== null && value !== undefined) {
24
- q.push(encodeURIComponent(key) + "=" + encodeURIComponent("" + value));
25
31
  }
26
32
  }
27
33
  return (q.length > 0 ? "?" + q.join("&") : "") + anchor;
@@ -30,8 +36,20 @@ function $buildOptions(options: any, names: string[]): string {
30
36
  }
31
37
  }
32
38
 
39
+ function $encode(value: any): string {
40
+ return encodeURIComponent(value);
41
+ }
42
+
43
+ function $isNotNull(value: any): boolean {
44
+ return value !== undefined && value !== null;
45
+ }
46
+
47
+ function $isScalarType(value: any): value is ScalarType {
48
+ return typeof(value) === "string" || typeof(value) === "number" || typeof(value) === "boolean";
49
+ }
50
+
33
51
  function $isPresent(value: any): boolean {
34
- return value !== undefined && value !== null && ("" + value).length > 0;
52
+ return $isNotNull(value) && ("" + value).length > 0;
35
53
  }
36
54
 
37
55
  function $hasPresentOwnProperty(options: any, key: string): boolean {
@@ -1,3 +1,3 @@
1
1
  module TsRoutes
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ts_routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - FUJI Goro (gfx)
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-17 00:00:00.000000000 Z
11
+ date: 2017-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties