js_from_routes 2.0.6 → 3.0.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
  SHA256:
3
- metadata.gz: 9053499de4df17e1ef042b1b54e4c172ab8ab94b2c0c353e6b8035efa8d3c0e5
4
- data.tar.gz: 6fc5926dfcf3b0f94bde9c7176af31522c36bf206d6636563415143655414c3e
3
+ metadata.gz: 4dc77943e97a5b5ddb24ebf0dea4f8eb246ceee14e7e0db6820d18fa3d5e880d
4
+ data.tar.gz: f4903735ecf2a1456735483c9f79ff0852a76f6d2ec091196b4310d4cb453a08
5
5
  SHA512:
6
- metadata.gz: 30c30f206f148dcb9ca5dac38f4f5eb07d0b6d49f5ca4c87dd4e358a3b7af12ce1fe0750cb0554c91c0655c2cadcaf6ad47438a35b9ee9678eaf3cf4945ba2d5
7
- data.tar.gz: 2515d4737e9202d93e99b3f573f43667d2beea1dc61a2fafdabf2a3752478e36289fd742649fe55396185604b3ff8b04d0742048e6d8ec7ef7530627107e0931
6
+ metadata.gz: 18e08f5bbccf22d80325ed48f6dbde2381f7369749d1fcdf28793a44242e56291bff6b5024a5ecd634eef88dc01c0ca36e1104a25874c0baae48ed6acf77c116
7
+ data.tar.gz: e5b921b29440548ae6624782084d5e90ed78c87609e8f3fbef64e3767b7e90cf9954c58184747df05cdb6f9998719f8a54c973ce95d863f7e4c1e77301d16108
data/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ # [3.0.0](https://github.com/ElMassimo/js_from_routes/compare/js_from_routes@2.1.0...js_from_routes@3.0.0) (2023-10-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * **breaking:** no longer map `index` to `list` and `show` to `get` ([5eb3f48](https://github.com/ElMassimo/js_from_routes/commit/5eb3f48de71fe38ee1c67d9b91a81d71a437e1a8))
7
+ * add `export_if` to allow using custom `:export` values ([fd1776c](https://github.com/ElMassimo/js_from_routes/commit/fd1776cc91402f1e9a9003031cb9fd6c3a0d63f9))
8
+
9
+
10
+
11
+
12
+ If you want to preserve the old behavior:
13
+
14
+ ```ruby
15
+ JsFromRoutes.config do |config|
16
+ config.helper_mappings = {"index" => "list", "show" => "get"}
17
+ end
18
+ ```
19
+
20
+ # [2.1.0](https://github.com/ElMassimo/js_from_routes/compare/js_from_routes@2.0.6...js_from_routes@2.1.0) (2023-02-07)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * use relative paths in auto-generated files ([#36](https://github.com/ElMassimo/js_from_routes/issues/36)) ([0440c50](https://github.com/ElMassimo/js_from_routes/commit/0440c505b1b4d3cca6c390004234faacd10b9480)), closes [#35](https://github.com/ElMassimo/js_from_routes/issues/35)
26
+
27
+
28
+
1
29
  ## [2.0.6](https://github.com/ElMassimo/js_from_routes/compare/js_from_routes@2.0.5...js_from_routes@2.0.6) (2022-05-25)
2
30
 
3
31
 
@@ -37,7 +37,7 @@ module JsFromRoutes
37
37
 
38
38
  # Public: Name of the JS file with helpers for the the given controller.
39
39
  def import_filename
40
- @config.output_folder.basename.join((basename.split(".")[0]).to_s)
40
+ filename.relative_path_from(@config.output_folder).to_s.sub(/\.\w+$/, "")
41
41
  end
42
42
 
43
43
  # Public: Name of the file as a valid JS variable.
@@ -174,8 +174,9 @@ module JsFromRoutes
174
174
  {
175
175
  all_helpers_file: true,
176
176
  client_library: "@js-from-routes/client",
177
+ export_if: ->(route) { route.defaults.fetch(:export, nil) },
177
178
  file_suffix: "Api.js",
178
- helper_mappings: {"index" => "list", "show" => "get"},
179
+ helper_mappings: {},
179
180
  output_folder: root.join("app", dir, "api"),
180
181
  template_path: File.expand_path("template.js.erb", __dir__),
181
182
  template_all_path: File.expand_path("template_all.js.erb", __dir__),
@@ -186,7 +187,7 @@ module JsFromRoutes
186
187
  # Internal: Returns exported routes grouped by controller name.
187
188
  def exported_routes_by_controller(routes)
188
189
  routes.select { |route|
189
- route.defaults.fetch(:export, false) && route.requirements[:controller]
190
+ config.export_if.call(route) && route.requirements[:controller]
190
191
  }.group_by { |route|
191
192
  route.requirements.fetch(:controller)
192
193
  }
@@ -1,5 +1,5 @@
1
1
  //
2
2
  // DO NOT MODIFY: This file was automatically generated by JsFromRoutes.
3
3
  <% helpers.each do |helper| %>
4
- export { default as <%= helper.js_name %> } from '~/<%= helper.import_filename %>'
4
+ export { default as <%= helper.js_name %> } from './<%= helper.import_filename %>'
5
5
  <% end %>
@@ -1,5 +1,5 @@
1
1
  //
2
2
  // DO NOT MODIFY: This file was automatically generated by JsFromRoutes.
3
- import * as helpers from '~/api/all'
4
- export * from '~/api/all'
3
+ import * as helpers from './all'
4
+ export * from './all'
5
5
  export default helpers
@@ -4,5 +4,5 @@
4
4
  # Generates one file per controller, and one function per route.
5
5
  module JsFromRoutes
6
6
  # Public: This library adheres to semantic versioning.
7
- VERSION = "2.0.6"
7
+ VERSION = "3.0.0"
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js_from_routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-25 00:00:00.000000000 Z
11
+ date: 2023-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
- rubygems_version: 3.2.32
170
+ rubygems_version: 3.4.10
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: Generate JS automatically from Rails routes.