routes_lazy_routes 0.4.1 → 0.4.3
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/.github/workflows/main.yml +41 -22
- data/Gemfile +9 -1
- data/README.md +11 -0
- data/lib/routes_lazy_routes/application.rb +10 -0
- data/lib/routes_lazy_routes/railtie.rb +1 -2
- data/lib/routes_lazy_routes/routes_reloader_wrapper.rb +7 -1
- data/lib/routes_lazy_routes/version.rb +1 -1
- metadata +3 -4
- data/lib/routes_lazy_routes/command/routes_command.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 272b3d3c76bca9133328661041ba10f7614baa22b4543c1e1a5b3290d1fc4a63
|
4
|
+
data.tar.gz: 5ec08f51f3b8441d0e1b71dc1620f95837273eb1cd9a490e2be8807dddf2e580
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a75d08698a13d3051fd50ec395a711cbf7ebbdf0804dcb7fd426ee0c441019203040d9d58e84f990496ee17dfaa8d117ff4a62c5eddee4f1bbcd1f1821251085
|
7
|
+
data.tar.gz: 87d3e4a5eaf8170c70b63039c525fdd88b2a3ea8a1cde7aede9e7f52405e203d81d58a6bbf1ff1adb68774036fbc6f07c3b53e1925bc5d3f3ca4af891612dddb
|
data/.github/workflows/main.yml
CHANGED
@@ -1,33 +1,52 @@
|
|
1
1
|
name: Ruby
|
2
2
|
|
3
|
-
on: [push,pull_request]
|
3
|
+
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
6
|
build:
|
7
7
|
strategy:
|
8
8
|
matrix:
|
9
|
+
ruby_version: [ruby-head, '3.3', '3.2', '3.1']
|
10
|
+
rails_version: ['edge', '7.1', '7.0', '6.1']
|
11
|
+
|
9
12
|
include:
|
10
|
-
-
|
11
|
-
|
12
|
-
-
|
13
|
-
|
14
|
-
-
|
15
|
-
|
16
|
-
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
- ruby_version: '3.0'
|
14
|
+
rails_version: '7.1'
|
15
|
+
- ruby_version: '3.0'
|
16
|
+
rails_version: '7.0'
|
17
|
+
- ruby_version: '3.0'
|
18
|
+
rails_version: '6.1'
|
19
|
+
- ruby_version: '3.0'
|
20
|
+
rails_version: '6.0'
|
21
|
+
|
22
|
+
- ruby_version: '2.7'
|
23
|
+
rails_version: '7.1'
|
24
|
+
- ruby_version: '2.7'
|
25
|
+
rails_version: '7.0'
|
26
|
+
- ruby_version: '2.7'
|
27
|
+
rails_version: '6.1'
|
28
|
+
- ruby_version: '2.7'
|
29
|
+
rails_version: '6.0'
|
30
|
+
- ruby_version: '2.7'
|
31
|
+
rails_version: '5.2'
|
32
|
+
|
33
|
+
- ruby_version: '2.6'
|
34
|
+
rails_version: '6.0'
|
35
|
+
- ruby_version: '2.6'
|
36
|
+
rails_version: '5.2'
|
37
|
+
|
20
38
|
runs-on: ubuntu-latest
|
39
|
+
|
40
|
+
env:
|
41
|
+
RAILS_VERSION: ${{ matrix.rails_version }}
|
42
|
+
|
21
43
|
steps:
|
22
|
-
- uses: actions/checkout@
|
23
|
-
|
24
|
-
|
44
|
+
- uses: actions/checkout@v3
|
45
|
+
|
46
|
+
- uses: ruby/setup-ruby@v1
|
25
47
|
with:
|
26
|
-
ruby-version: ${{ matrix.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
bundle exec rake
|
32
|
-
env:
|
33
|
-
RAILS_VERSION: ${{ matrix.rails-version }}
|
48
|
+
ruby-version: ${{ matrix.ruby_version }}
|
49
|
+
rubygems: latest
|
50
|
+
bundler-cache: true
|
51
|
+
|
52
|
+
- run: bundle exec rake
|
data/Gemfile
CHANGED
@@ -5,8 +5,16 @@ source "https://rubygems.org"
|
|
5
5
|
# Specify your gem's dependencies in routes_lazy_routes.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
|
8
|
+
if ENV['RAILS_VERSION'] == 'edge'
|
9
|
+
gem 'rails', git: 'https://github.com/rails/rails.git'
|
10
|
+
elsif ENV['RAILS_VERSION']
|
11
|
+
gem 'rails', "~> #{ENV['RAILS_VERSION']}.0"
|
12
|
+
end
|
9
13
|
|
10
14
|
gem "rake", "~> 13.0"
|
11
15
|
|
12
16
|
gem "minitest", "~> 5.0"
|
17
|
+
|
18
|
+
gem 'base64'
|
19
|
+
gem 'bigdecimal'
|
20
|
+
gem 'mutex_m'
|
data/README.md
CHANGED
@@ -44,6 +44,17 @@ If you're bundling this in the production server, it'd be a good idea to throw a
|
|
44
44
|
|
45
45
|
- And, as already explained, sending a request to the Rails server automatically runs `RoutesLazyRoutes.eager_load!` on the server.
|
46
46
|
|
47
|
+
- On the other hand, you need manually calling `RoutesLazyRoutes.eager_load!` inside your worker process (e.g. Sidekiq) to resolve named routes like the following:
|
48
|
+
``` ruby
|
49
|
+
# config/initializers/sidekiq.rb
|
50
|
+
Sidekiq.configure_server do |config|
|
51
|
+
if defined?(RoutesLazyRoutes)
|
52
|
+
Rails.application.config.after_initialize do
|
53
|
+
RoutesLazyRoutes.eager_load!
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
```
|
47
58
|
|
48
59
|
## Contributing
|
49
60
|
|
@@ -21,5 +21,15 @@ module RoutesLazyRoutes
|
|
21
21
|
load "#{__dir__}/tasks/routes_lazy_routes.rake"
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
# A monkey-patch that eager loads routes before the routes command is executed by prepending this module to the
|
26
|
+
# require_enviornment! method that's called when boot_application! is executed performing console commands.
|
27
|
+
module RoutesCommandEagerLoader
|
28
|
+
def require_environment!
|
29
|
+
super
|
30
|
+
|
31
|
+
RoutesLazyRoutes.eager_load!
|
32
|
+
end
|
33
|
+
end
|
24
34
|
end
|
25
35
|
end
|
@@ -8,8 +8,7 @@ module RoutesLazyRoutes
|
|
8
8
|
Rails::Application.prepend RoutesLazyRoutes::Application::TaskLoader
|
9
9
|
|
10
10
|
if defined? Rails::Command::RoutesCommand
|
11
|
-
|
12
|
-
Rails::Command::RoutesCommand.prepend RoutesLazyRoutes::Command::RoutesCommand
|
11
|
+
Rails::Application.prepend RoutesLazyRoutes::Application::RoutesCommandEagerLoader
|
13
12
|
end
|
14
13
|
|
15
14
|
initializer :routes_lazy_routes, before: :add_routing_paths do
|
@@ -2,7 +2,13 @@
|
|
2
2
|
|
3
3
|
module RoutesLazyRoutes
|
4
4
|
class RoutesReloaderWrapper
|
5
|
-
delegate :paths,
|
5
|
+
delegate :paths,
|
6
|
+
:eager_load=,
|
7
|
+
:run_after_load_paths=,
|
8
|
+
:updated?,
|
9
|
+
:route_sets,
|
10
|
+
:external_routes,
|
11
|
+
to: :@original_routes_reloader
|
6
12
|
|
7
13
|
def initialize(original_routes_reloader)
|
8
14
|
@original_routes_reloader = original_routes_reloader
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: routes_lazy_routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -70,7 +70,6 @@ files:
|
|
70
70
|
- bin/setup
|
71
71
|
- lib/routes_lazy_routes.rb
|
72
72
|
- lib/routes_lazy_routes/application.rb
|
73
|
-
- lib/routes_lazy_routes/command/routes_command.rb
|
74
73
|
- lib/routes_lazy_routes/lazy_routes_middleware.rb
|
75
74
|
- lib/routes_lazy_routes/railtie.rb
|
76
75
|
- lib/routes_lazy_routes/routes_reloader_wrapper.rb
|
@@ -98,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
97
|
- !ruby/object:Gem::Version
|
99
98
|
version: '0'
|
100
99
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
100
|
+
rubygems_version: 3.4.13
|
102
101
|
signing_key:
|
103
102
|
specification_version: 4
|
104
103
|
summary: A Rails routes lazy loader
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RoutesLazyRoutes
|
4
|
-
module Command
|
5
|
-
module RoutesCommand
|
6
|
-
# A monkey-patch that eager_loads the routes right before running the `rails routes` command.
|
7
|
-
def require_environment!
|
8
|
-
super
|
9
|
-
|
10
|
-
RoutesLazyRoutes.eager_load!
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|