rage-rb 1.13.0 → 1.14.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: d2f73c4770587ebabc7d8fa0c4793d53742196b928f21cc362799cb068849982
4
- data.tar.gz: aecaa4ae2848bc1b15a38da29d3030d718d74697faaf8525e60e82d10b24396c
3
+ metadata.gz: b63589b942c187505390393db5ff827ad647a8ba22b2b6d544f47a0075f73701
4
+ data.tar.gz: 91cad1e502090ab52bb872ce9216f1deb2cfe150560bf328bb61267a719a5c1c
5
5
  SHA512:
6
- metadata.gz: bb31ef275be5dc22322af8c9d563befc000ad2d15bb22454f2d3664736e6e7881ccdac365e6687fc123c23da1a06ee3cd4d63d08b8b5123c1fee67ebb97fbc57
7
- data.tar.gz: 7debadefde85efa180f73e963b252cb1065a6b6f1bf4b8ca6e64e19d82a0ed838d3b321ddf9222006204ab59c3d90213e1a4eb6e1ff04d1d45572c1e166b3d77
6
+ metadata.gz: b0e44e8decbd7b68c8489e6559960585711ea1931ff5cff48622e5303b120bb5920567cf85610faaef7e25fa94d8289ceccaab82ba761ea8c28ded4b436624c6
7
+ data.tar.gz: 655432e0e793cfa07b744e0adc56f6dc4becd73c9e48d3eb1c4716055849e5c03f1927211d75400a3da97838846329a9520226122635781cbd0f5f6417319687
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.14.0] - 2025-03-10
4
+
5
+ ### Added
6
+
7
+ - Detect file updates in development (#132).
8
+
9
+ ### Fixed
10
+
11
+ - Update app template to include all app rake tasks by [pjb3](https://github.com/pjb3) (#130).
12
+
3
13
  ## [1.13.0] - 2025-02-12
4
14
 
5
15
  ### Added
data/README.md CHANGED
@@ -57,13 +57,16 @@ Check out in-depth API docs for more information:
57
57
  - [Fiber API](https://rage-rb.pages.dev/Fiber)
58
58
  - [Logger API](https://rage-rb.pages.dev/Rage/Logger)
59
59
  - [Configuration API](https://rage-rb.pages.dev/Rage/Configuration)
60
- - [CORS middleware](https://rage-rb.pages.dev/Rage/Cors)
60
+
61
+ Built-in middleware:
62
+ - [CORS](https://rage-rb.pages.dev/Rage/Cors)
63
+ - [RequestId](https://rage-rb.pages.dev/Rage/RequestId)
61
64
 
62
65
  Also, see the following integration guides:
63
66
 
64
- - [Rails integration](https://github.com/rage-rb/rage/wiki/Rails-integration)
65
- - [RSpec integration](https://github.com/rage-rb/rage/wiki/RSpec-integration)
66
- - [WebSockets guide](https://github.com/rage-rb/rage/wiki/WebSockets-guide)
67
+ - [Rails Integration](https://github.com/rage-rb/rage/wiki/Rails-integration)
68
+ - [RSpec Integration](https://github.com/rage-rb/rage/wiki/RSpec-integration)
69
+ - [WebSockets Guide](https://github.com/rage-rb/rage/wiki/WebSockets-guide)
67
70
 
68
71
  If you are a first-time contributor, make sure to check the [overview doc](https://github.com/rage-rb/rage/blob/master/OVERVIEW.md) that shows how Rage's core components interact with each other.
69
72
 
@@ -5,16 +5,16 @@ require "zeitwerk"
5
5
  class Rage::CodeLoader
6
6
  def initialize
7
7
  @reloading = false
8
+ @autoload_path = Rage.root.join("app")
8
9
  end
9
10
 
10
11
  def setup
11
12
  @loader = Zeitwerk::Loader.new
12
13
 
13
- autoload_path = "#{Rage.root}/app"
14
14
  enable_reloading = Rage.env.development?
15
15
  enable_eager_loading = !Rage.env.development? && !Rage.env.test?
16
16
 
17
- @loader.push_dir(autoload_path)
17
+ @loader.push_dir(@autoload_path.to_s)
18
18
  # The first level of directories in app directory won't be treated as modules
19
19
  # e.g. app/controllers/pages_controller.rb will be linked to PagesController class
20
20
  # instead of Controllers::PagesController
@@ -62,4 +62,15 @@ class Rage::CodeLoader
62
62
  def reloading?
63
63
  @reloading
64
64
  end
65
+
66
+ def check_updated!
67
+ current_watched = @autoload_path.glob("**/*.rb") + Rage.root.glob("config/routes.rb") + Rage.root.glob("config/openapi_components.*")
68
+ current_update_at = current_watched.max_by { |path| path.exist? ? path.mtime.to_f : 0 }&.mtime.to_f
69
+ return false if !@last_watched && !@last_update_at
70
+
71
+ current_watched.size != @last_watched.size || current_update_at != @last_update_at
72
+
73
+ ensure
74
+ @last_watched, @last_update_at = current_watched, current_update_at
75
+ end
65
76
  end
@@ -2,15 +2,32 @@
2
2
 
3
3
  class Rage::Reloader
4
4
  def initialize(app)
5
+ Iodine.on_state(:on_start) do
6
+ Rage.code_loader.check_updated!
7
+ end
5
8
  @app = app
6
9
  end
7
10
 
8
11
  def call(env)
9
- Rage.code_loader.reload
10
- @app.call(env)
12
+ with_reload do
13
+ @app.call(env)
14
+ end
11
15
  rescue Exception => e
12
16
  exception_str = "#{e.class} (#{e.message}):\n#{e.backtrace.join("\n")}"
13
17
  puts(exception_str)
14
18
  [500, {}, [exception_str]]
15
19
  end
20
+
21
+ private
22
+
23
+ def with_reload
24
+ if Rage.code_loader.check_updated!
25
+ Fiber.new(blocking: true) {
26
+ Rage.code_loader.reload
27
+ yield
28
+ }.resume
29
+ else
30
+ yield
31
+ end
32
+ end
16
33
  end
data/lib/rage/tasks.rb CHANGED
@@ -7,6 +7,7 @@ class Rage::Tasks
7
7
  class << self
8
8
  def init
9
9
  load_db_tasks if defined?(StandaloneMigrations)
10
+ load_app_tasks
10
11
  end
11
12
 
12
13
  private
@@ -29,5 +30,9 @@ class Rage::Tasks
29
30
 
30
31
  StandaloneMigrations::Tasks.load_tasks
31
32
  end
33
+
34
+ def load_app_tasks
35
+ Dir[Rage.root.join("lib/tasks/**/*.rake")].each { |file| load file }
36
+ end
32
37
  end
33
38
  end
data/lib/rage/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rage
4
- VERSION = "1.13.0"
4
+ VERSION = "1.14.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rage-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Samoilov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-12 00:00:00.000000000 Z
11
+ date: 2025-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor