js_rails_routes 0.8.0 → 0.8.1
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abaf98e11062f86106203b6b2d68bbf65c83c00e0781122019cc1d0ca20a5fe3
|
4
|
+
data.tar.gz: 38cb07f953ea05bdb1a754a76bfc8e8fd2637c778b69eb35a6d39eb6484b5296
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c2c5bff02e8b53f16ec78fa3e818b693786f454c5cf226a13e3c9d67371e69d1e3d5eae538e5c9c52116abf5394902311afe8f5604ffa56e34fe77ba925d930
|
7
|
+
data.tar.gz: 10ebd6b90a0bf90b566ed76fa1aeef2ee87612c59c44728917fcc63107075d38c640e21cf450bd4b60d0479973aae407a14cd0112099cf33a134fd2677d2c814
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ This change log adheres to [keepachangelog.com](http://keepachangelog.com).
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.8.1] - 2018-08-21
|
10
|
+
### Fixed
|
11
|
+
- Camelize `params` keys as `camelize` option
|
12
|
+
|
9
13
|
## [0.8.0] - 2018-08-21
|
10
14
|
### Added
|
11
15
|
- Support TypeScript
|
@@ -62,7 +66,8 @@ This change log adheres to [keepachangelog.com](http://keepachangelog.com).
|
|
62
66
|
### Added
|
63
67
|
- Implement "js:rails:routes" task
|
64
68
|
|
65
|
-
[Unreleased]: https://github.com/yuku-t/js_rails_routes/compare/v0.8.
|
69
|
+
[Unreleased]: https://github.com/yuku-t/js_rails_routes/compare/v0.8.1...HEAD
|
70
|
+
[0.8.1]: https://github.com/yuku-t/js_rails_routes/compare/v0.8.0...v0.8.1
|
66
71
|
[0.8.0]: https://github.com/yuku-t/js_rails_routes/compare/v0.7.1...v0.8.0
|
67
72
|
[0.7.1]: https://github.com/yuku-t/js_rails_routes/compare/v0.7.0...v0.7.1
|
68
73
|
[0.7.0]: https://github.com/yuku-t/js_rails_routes/compare/v0.6.0...v0.7.0
|
@@ -46,11 +46,9 @@ module JSRailsRoutes
|
|
46
46
|
destructured_path = route_path.dup
|
47
47
|
keys = []
|
48
48
|
while destructured_path =~ JSRailsRoutes::PARAM_REGEXP
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
"' + params.#{Regexp.last_match(1)} + '#{Regexp.last_match(2)}"
|
53
|
-
)
|
49
|
+
key = camelize(Regexp.last_match(1))
|
50
|
+
keys.push("'#{key}'")
|
51
|
+
destructured_path.sub!(JSRailsRoutes::PARAM_REGEXP, "' + params.#{key} + '#{Regexp.last_match(2)}")
|
54
52
|
end
|
55
53
|
[destructured_path, keys]
|
56
54
|
end
|
@@ -61,6 +59,17 @@ module JSRailsRoutes
|
|
61
59
|
url_helper_name = route_name + '_path'
|
62
60
|
config.camelize.nil? ? url_helper_name : url_helper_name.camelize(config.camelize)
|
63
61
|
end
|
62
|
+
|
63
|
+
# @param name [String]
|
64
|
+
# @return [String]
|
65
|
+
def camelize(name)
|
66
|
+
config.camelize ? name.camelize(config.camelize) : name
|
67
|
+
end
|
68
|
+
|
69
|
+
# @return [JSRailsRoutes::Configuration]
|
70
|
+
def config
|
71
|
+
JSRailsRoutes.config
|
72
|
+
end
|
64
73
|
end
|
65
74
|
end
|
66
75
|
end
|
@@ -77,8 +77,8 @@ RSpec.describe JSRailsRoutes::Language::JavaScript do
|
|
77
77
|
#{described_class::PROCESS_FUNC}
|
78
78
|
export function ArticlesPath(params) { return process('/articles', params, []); }
|
79
79
|
export function NewArticlePath(params) { return process('/articles/new', params, []); }
|
80
|
-
export function EditArticlePath(params) { return process('/articles/' + params.
|
81
|
-
export function ArticlePath(params) { return process('/articles/' + params.
|
80
|
+
export function EditArticlePath(params) { return process('/articles/' + params.Id + '/edit', params, ['Id']); }
|
81
|
+
export function ArticlePath(params) { return process('/articles/' + params.Id + '', params, ['Id']); }
|
82
82
|
JAVASCRIPT
|
83
83
|
end
|
84
84
|
end
|
@@ -78,8 +78,8 @@ RSpec.describe JSRailsRoutes::Language::TypeScript do
|
|
78
78
|
#{described_class::PROCESS_FUNC}
|
79
79
|
export function ArticlesPath(params: Params) { return process('/articles', params, []); }
|
80
80
|
export function NewArticlePath(params: Params) { return process('/articles/new', params, []); }
|
81
|
-
export function EditArticlePath(params: Params) { return process('/articles/' + params.
|
82
|
-
export function ArticlePath(params: Params) { return process('/articles/' + params.
|
81
|
+
export function EditArticlePath(params: Params) { return process('/articles/' + params.Id + '/edit', params, ['Id']); }
|
82
|
+
export function ArticlePath(params: Params) { return process('/articles/' + params.Id + '', params, ['Id']); }
|
83
83
|
TYPESCRIPT
|
84
84
|
end
|
85
85
|
end
|