js_from_routes 3.0.1 → 3.0.2
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/CHANGELOG.md +9 -0
- data/lib/js_from_routes/generator.rb +21 -17
- data/lib/js_from_routes/railtie.rb +1 -1
- data/lib/js_from_routes/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b4a7e4009c35ed9b21a6ea1010d157faaed01d21143086a7573d87ae1a21aae
|
4
|
+
data.tar.gz: 67db6af0cbae2656a450649384c86f19a9c890fd58e84ea99fa7f03299866dd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b519fba61999909979dd313995733497c9536cb5fda7bdf0c0585e133ab718f4b733c46014d2b3b039fa81b7b70d6b8939e3e155656613dafc0577f64970041
|
7
|
+
data.tar.gz: 570cc1c4a497adf344b02e52c8c1da005877830be355638f85be7c9fe664094b03ee9d62c66a5295db1dfcd5d47993928581c0949f239b90f041e0d85f51c619
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## [3.0.2](https://github.com/ElMassimo/js_from_routes/compare/js_from_routes@3.0.1...js_from_routes@3.0.2) (2024-09-25)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* remove references to OpenStruct ([#49](https://github.com/ElMassimo/js_from_routes/issues/49)) ([6c0d8de](https://github.com/ElMassimo/js_from_routes/commit/6c0d8ded2bf82ccc2f8f35508dc256c3b301069a)), closes [#47](https://github.com/ElMassimo/js_from_routes/issues/47)
|
7
|
+
|
8
|
+
|
9
|
+
|
1
10
|
## [3.0.1](https://github.com/ElMassimo/js_from_routes/compare/js_from_routes@3.0.0...js_from_routes@3.0.1) (2023-10-09)
|
2
11
|
|
3
12
|
|
@@ -126,10 +126,29 @@ module JsFromRoutes
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
+
class Configuration
|
130
|
+
attr_accessor :all_helpers_file, :client_library, :export_if, :file_suffix,
|
131
|
+
:helper_mappings, :output_folder, :template_path,
|
132
|
+
:template_all_path, :template_index_path
|
133
|
+
|
134
|
+
def initialize(root)
|
135
|
+
dir = %w[frontend packs javascript assets].find { |dir| root.join("app", dir).exist? }
|
136
|
+
@all_helpers_file = true
|
137
|
+
@client_library = "@js-from-routes/client"
|
138
|
+
@export_if = ->(route) { route.defaults.fetch(:export, nil) }
|
139
|
+
@file_suffix = "Api.js"
|
140
|
+
@helper_mappings = {}
|
141
|
+
@output_folder = root.join("app", dir, "api")
|
142
|
+
@template_path = File.expand_path("template.js.erb", __dir__)
|
143
|
+
@template_all_path = File.expand_path("template_all.js.erb", __dir__)
|
144
|
+
@template_index_path = File.expand_path("template_index.js.erb", __dir__)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
129
148
|
class << self
|
130
149
|
# Public: Configuration of the code generator.
|
131
150
|
def config
|
132
|
-
@config ||=
|
151
|
+
@config ||= Configuration.new(::Rails.root || Pathname.new(Dir.pwd))
|
133
152
|
yield(@config) if block_given?
|
134
153
|
@config
|
135
154
|
end
|
@@ -156,7 +175,7 @@ module JsFromRoutes
|
|
156
175
|
return unless config.all_helpers_file && !routes.empty?
|
157
176
|
|
158
177
|
preferred_extension = File.extname(config.file_suffix)
|
159
|
-
index_file = config.all_helpers_file == true ? "index#{preferred_extension}" : config.all_helpers_file
|
178
|
+
index_file = (config.all_helpers_file == true) ? "index#{preferred_extension}" : config.all_helpers_file
|
160
179
|
|
161
180
|
Template.new(config.template_all_path).write_if_changed OpenStruct.new(
|
162
181
|
cache_key: routes.map(&:import_filename).join + File.read(config.template_all_path),
|
@@ -169,21 +188,6 @@ module JsFromRoutes
|
|
169
188
|
)
|
170
189
|
end
|
171
190
|
|
172
|
-
def default_config(root)
|
173
|
-
dir = %w[frontend packs javascript assets].find { |dir| root.join("app", dir).exist? }
|
174
|
-
{
|
175
|
-
all_helpers_file: true,
|
176
|
-
client_library: "@js-from-routes/client",
|
177
|
-
export_if: ->(route) { route.defaults.fetch(:export, nil) },
|
178
|
-
file_suffix: "Api.js",
|
179
|
-
helper_mappings: {},
|
180
|
-
output_folder: root.join("app", dir, "api"),
|
181
|
-
template_path: File.expand_path("template.js.erb", __dir__),
|
182
|
-
template_all_path: File.expand_path("template_all.js.erb", __dir__),
|
183
|
-
template_index_path: File.expand_path("template_index.js.erb", __dir__),
|
184
|
-
}
|
185
|
-
end
|
186
|
-
|
187
191
|
# Internal: Returns exported routes grouped by controller name.
|
188
192
|
def exported_routes_by_controller(routes)
|
189
193
|
routes.select { |route|
|
@@ -30,7 +30,7 @@ class JsFromRoutes::Railtie < Rails::Railtie
|
|
30
30
|
initializer "js_from_routes.required_defaults" do |app|
|
31
31
|
ActionDispatch::Journey::Route.prepend Module.new {
|
32
32
|
def required_default?(key)
|
33
|
-
key == :export ? false : super
|
33
|
+
(key == :export) ? false : super
|
34
34
|
end
|
35
35
|
}
|
36
36
|
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: 3.0.
|
4
|
+
version: 3.0.2
|
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:
|
11
|
+
date: 2024-09-25 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.
|
170
|
+
rubygems_version: 3.5.16
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: Generate JS automatically from Rails routes.
|