js_rails_routes 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/js_rails_routes/generator.rb +5 -1
- data/lib/js_rails_routes/language/javascript.rb +1 -1
- data/lib/js_rails_routes/language/typescript.rb +1 -1
- data/lib/js_rails_routes/version.rb +1 -1
- data/spec/js_rails_routes/language/javascript_spec.rb +1 -1
- data/spec/js_rails_routes/language/typescript_spec.rb +1 -1
- data/spec/js_rails_routes_spec.rb +4 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c11d8e6af1565c2c53a41fae11b7f802862abdc0fdf025d91c55b06718b69f42
|
4
|
+
data.tar.gz: 44d767c56274bf63c53d241dfd84feb1f2bac1e56f59e68d8b28ff3e6852ec98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba97b9bb129f473f3c50fb5bd4fc5804c95c77ae48a5acf34d6b02dd8fe5f8250af895915f3d834feb69a7878d3e01bb376fec2b6b85c4f1ca93d6c831e687bc
|
7
|
+
data.tar.gz: 9ad1938f061504f09dd194e991a352dcee227d07f6a6be2cfc633ed6b558386898e71fae6345f4a58c2622092a4a93dc2b2ea4f7cc37846a84a4c4039b40fb46
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,11 @@ This change log adheres to [keepachangelog.com](http://keepachangelog.com).
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.1.0] - 2024-02-09
|
10
|
+
### Changed
|
11
|
+
- Add eslint-disable comment not to affect eslint format
|
12
|
+
- Update generated scripts to adopt eslint rule
|
13
|
+
|
9
14
|
## [1.0.0] - 2022-05-13
|
10
15
|
|
11
16
|
### Changed
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ then `rake js:routes` generates "app/assets/javascripts/rails-routes.js" as:
|
|
38
38
|
// Don't edit manually. `rake js:routes` generates this file.
|
39
39
|
function process(route, params, keys) {
|
40
40
|
var query = [];
|
41
|
-
for (var param in params) if (
|
41
|
+
for (var param in params) if (Object.prototype.hasOwnProperty.call(params, param)) {
|
42
42
|
if (keys.indexOf(param) === -1) {
|
43
43
|
query.push(param + "=" + encodeURIComponent(params[param]));
|
44
44
|
}
|
@@ -17,7 +17,11 @@ module JSRailsRoutes
|
|
17
17
|
def generate(task)
|
18
18
|
builder.build.each do |artifact|
|
19
19
|
file_name = File.join(config.output_dir, artifact.file_name)
|
20
|
-
file_body =
|
20
|
+
file_body = <<~FILE_BODY.chomp
|
21
|
+
/* eslint-disable */
|
22
|
+
// Don't edit manually. `rake #{task}` generates this file.
|
23
|
+
#{artifact.body}
|
24
|
+
FILE_BODY
|
21
25
|
writable.write(file_name, file_body)
|
22
26
|
end
|
23
27
|
end
|
@@ -9,7 +9,7 @@ module JSRailsRoutes
|
|
9
9
|
PROCESS_FUNC = <<~JAVASCRIPT
|
10
10
|
function process(route, params, keys) {
|
11
11
|
var query = [];
|
12
|
-
for (var param in params) if (
|
12
|
+
for (var param in params) if (Object.prototype.hasOwnProperty.call(params, param)) {
|
13
13
|
if (keys.indexOf(param) === -1) {
|
14
14
|
query.push(param + "=" + encodeURIComponent(params[param]));
|
15
15
|
}
|
@@ -12,7 +12,7 @@ module JSRailsRoutes
|
|
12
12
|
function process(route: string, params: Record<string, Value> | undefined, keys: string[]): string {
|
13
13
|
if (!params) return route
|
14
14
|
var query: string[] = [];
|
15
|
-
for (var param in params) if (
|
15
|
+
for (var param in params) if (Object.prototype.hasOwnProperty.call(params, param)) {
|
16
16
|
if (keys.indexOf(param) === -1) {
|
17
17
|
query.push(param + "=" + encodeURIComponent(params[param].toString()));
|
18
18
|
}
|
@@ -12,7 +12,7 @@ RSpec.describe JSRailsRoutes::Language::JavaScript do
|
|
12
12
|
expect(subject).to eq <<~JAVASCRIPT
|
13
13
|
function process(route, params, keys) {
|
14
14
|
var query = [];
|
15
|
-
for (var param in params) if (
|
15
|
+
for (var param in params) if (Object.prototype.hasOwnProperty.call(params, param)) {
|
16
16
|
if (keys.indexOf(param) === -1) {
|
17
17
|
query.push(param + "=" + encodeURIComponent(params[param]));
|
18
18
|
}
|
@@ -15,7 +15,7 @@ RSpec.describe JSRailsRoutes::Language::TypeScript do
|
|
15
15
|
function process(route: string, params: Record<string, Value> | undefined, keys: string[]): string {
|
16
16
|
if (!params) return route
|
17
17
|
var query: string[] = [];
|
18
|
-
for (var param in params) if (
|
18
|
+
for (var param in params) if (Object.prototype.hasOwnProperty.call(params, param)) {
|
19
19
|
if (keys.indexOf(param) === -1) {
|
20
20
|
query.push(param + "=" + encodeURIComponent(params[param].toString()));
|
21
21
|
}
|
@@ -42,6 +42,7 @@ RSpec.describe JSRailsRoutes do
|
|
42
42
|
subject
|
43
43
|
|
44
44
|
expect(File.read(app_root.join('app/assets/javascripts/rails-routes.js'))).to eq <<~JAVASCRIPT
|
45
|
+
/* eslint-disable */
|
45
46
|
// Don't edit manually. `rake #{task}` generates this file.
|
46
47
|
#{JSRailsRoutes::Language::JavaScript::PROCESS_FUNC}
|
47
48
|
export function blogs_path(params) { return process('/blogs', params, []); }
|
@@ -55,6 +56,7 @@ RSpec.describe JSRailsRoutes do
|
|
55
56
|
JAVASCRIPT
|
56
57
|
|
57
58
|
expect(File.read(app_root.join('app/assets/javascripts/admin-routes.js'))).to eq <<~JAVASCRIPT
|
59
|
+
/* eslint-disable */
|
58
60
|
// Don't edit manually. `rake #{task}` generates this file.
|
59
61
|
#{JSRailsRoutes::Language::JavaScript::PROCESS_FUNC}
|
60
62
|
export function notes_path(params) { return process('/notes', params, []); }
|
@@ -94,6 +96,7 @@ RSpec.describe JSRailsRoutes do
|
|
94
96
|
subject
|
95
97
|
|
96
98
|
expect(File.read(app_root.join('app/assets/javascripts/rails-routes.ts'))).to eq <<~TYPESCRIPT
|
99
|
+
/* eslint-disable */
|
97
100
|
// Don't edit manually. `rake #{task}` generates this file.
|
98
101
|
#{JSRailsRoutes::Language::TypeScript::PROCESS_FUNC}
|
99
102
|
export function blogs_path(params?: Record<string, Value>) { return process('/blogs', params, []); }
|
@@ -107,6 +110,7 @@ RSpec.describe JSRailsRoutes do
|
|
107
110
|
TYPESCRIPT
|
108
111
|
|
109
112
|
expect(File.read(app_root.join('app/assets/javascripts/admin-routes.ts'))).to eq <<~TYPESCRIPT
|
113
|
+
/* eslint-disable */
|
110
114
|
// Don't edit manually. `rake #{task}` generates this file.
|
111
115
|
#{JSRailsRoutes::Language::TypeScript::PROCESS_FUNC}
|
112
116
|
export function notes_path(params?: Record<string, Value>) { return process('/notes', params, []); }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js_rails_routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Qiita Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -170,7 +170,7 @@ dependencies:
|
|
170
170
|
- - "!="
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: 0.19.1
|
173
|
-
description:
|
173
|
+
description:
|
174
174
|
email:
|
175
175
|
- engineers@qiita.com
|
176
176
|
executables: []
|
@@ -219,7 +219,7 @@ licenses:
|
|
219
219
|
- MIT
|
220
220
|
metadata:
|
221
221
|
rubygems_mfa_required: 'true'
|
222
|
-
post_install_message:
|
222
|
+
post_install_message:
|
223
223
|
rdoc_options: []
|
224
224
|
require_paths:
|
225
225
|
- lib
|
@@ -234,8 +234,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
234
|
- !ruby/object:Gem::Version
|
235
235
|
version: '0'
|
236
236
|
requirements: []
|
237
|
-
rubygems_version: 3.
|
238
|
-
signing_key:
|
237
|
+
rubygems_version: 3.4.1
|
238
|
+
signing_key:
|
239
239
|
specification_version: 4
|
240
240
|
summary: Generate a ES6 module that contains Rails routes.
|
241
241
|
test_files: []
|