ts_routes 0.1.0 → 0.2.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/README.md +8 -11
- data/lib/ts_routes/generator.rb +1 -1
- data/lib/ts_routes/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cd843a2d83376476d5c53066593deb4b6c7dd6b
|
4
|
+
data.tar.gz: c30a43ec163cbfe6ae165f78d8bdeaf5e27a6ee3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 555a4ffe0711f89708939e28eb3962bf31244b52c86901bb20f3b17b92f9ec7e5455357533251a23b69223b6bfeb9f64a7e32df318f42c823a483d3d0ff740e5
|
7
|
+
data.tar.gz: 2dd2cbb2b26a5c7f141d88e1d8841fe55b5d7875f7c2124c4a3dbfc0d920bd33df2d1ce77582623b65441e636d5cfb793f142f95e647622e83921e1e9652549e
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
This gem generates Rails URL helpers in TypeScript, inspired by [js-routes](https://github.com/railsware/js-routes).
|
4
4
|
|
5
5
|
|
6
|
-
##
|
6
|
+
## Usage
|
7
7
|
|
8
8
|
In your `lib/tasks/ts_routes.rake`:
|
9
9
|
|
@@ -35,6 +35,13 @@ console.log(Routes.entriesPath({ page: 1, per: 20 })); // => /entries?page=1&per
|
|
35
35
|
console.log(Routes.entryPath(1)); // => /entries/1
|
36
36
|
```
|
37
37
|
|
38
|
+
Generated URL helpers are almost compatible with Rails, but they are more strict:
|
39
|
+
|
40
|
+
* You must pass required parameters to the helpers as non-named (i.e. normal) arguments
|
41
|
+
* i.e. `Routes.entryPath(1)` for `/entries/:id`
|
42
|
+
* `Routes.entryPath({ id })` is refused
|
43
|
+
* You must pass optional parameters as the last argument
|
44
|
+
* i.e. `Routes.entriesPath({ page: 1, per: 2 })`
|
38
45
|
|
39
46
|
## Installation
|
40
47
|
|
@@ -52,16 +59,6 @@ Or install it yourself as:
|
|
52
59
|
|
53
60
|
$ gem install ts_routes
|
54
61
|
|
55
|
-
## Usage
|
56
|
-
|
57
|
-
Generated URL helpers are almost compatible with Rails:
|
58
|
-
|
59
|
-
* You must pass required parameters to the helpers as non-named (i.e. normal) arguments
|
60
|
-
* i.e. `Routes.entryPath(1)` for `/entries/:id`
|
61
|
-
* `Routes.entryPath({ id })` is refused
|
62
|
-
* You must pass optional parameters as the last argument
|
63
|
-
* i.e. `Routes.entriesPath({ page: 1, per: 2 })`
|
64
|
-
|
65
62
|
## Development
|
66
63
|
|
67
64
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/ts_routes/generator.rb
CHANGED
@@ -66,7 +66,7 @@ module TsRoutes
|
|
66
66
|
def mounted_app_routes(route)
|
67
67
|
app = route.app.respond_to?(:app) && route.app.respond_to?(:constraints) ? route.app.app : route.app
|
68
68
|
|
69
|
-
if app.respond_to?(:superclass) && app.superclass
|
69
|
+
if app.respond_to?(:superclass) && app.superclass <= Rails::Engine && !route.path.anchored
|
70
70
|
app.routes.named_routes.flat_map do |_, engine_route|
|
71
71
|
build_routes_if_match(engine_route, route)
|
72
72
|
end
|
data/lib/ts_routes/version.rb
CHANGED