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 +4 -4
- data/.rubocop.yml +2 -1
- data/.travis.yml +7 -5
- data/lib/ts_routes/runtime.ts +23 -5
- data/lib/ts_routes/version.rb +1 -1
- 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: 5791b921e57c9b8768e01ec57f89ae9c6f0f4df3
|
4
|
+
data.tar.gz: f4b841749d954fea3dd98a8282d78ae6cac99a8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 620ce508b12955929636d97a8206158a59d596263c7b5e66fef5d90ef068af62516052606dd551f9aed6e28a5b82e8ede3a20de73739e01af506200e3412c0fd
|
7
|
+
data.tar.gz: e145fbd28361b12b71bab30213479489ece90e92c511017f5ade3d5b2593d38152a1bf7e8306106a2c669a81a1961e6175581ad773f030b45600d96378b3c2c0
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -5,12 +5,14 @@ rvm:
|
|
5
5
|
- "2.3"
|
6
6
|
- "2.4"
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
-
|
8
|
+
before_install:
|
9
|
+
- nvm install 8
|
10
|
+
- npm install
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
cache:
|
13
|
+
bundler: true
|
14
|
+
directories:
|
15
|
+
- node_modules
|
14
16
|
|
15
17
|
script:
|
16
18
|
- bundle exec rake
|
data/lib/ts_routes/runtime.ts
CHANGED
@@ -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 =
|
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
|
-
|
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
|
52
|
+
return $isNotNull(value) && ("" + value).length > 0;
|
35
53
|
}
|
36
54
|
|
37
55
|
function $hasPresentOwnProperty(options: any, key: string): boolean {
|
data/lib/ts_routes/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|