Skip to content

Commit

Permalink
Merge pull request #56 from rage-rb/release-0-6
Browse files Browse the repository at this point in the history
0.6 release
  • Loading branch information
rsamoilov authored Dec 22, 2023
2 parents de4c36b + 8e850cd commit 7243ca6
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 6 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
## [Unreleased]

## [0.6.0] - 2023-12-22

### Added

- Implement after actions (#53).
- Zeitwerk autoloading and reloading by [@alex-rogachev](https://github.com/alex-rogachev) (#54).
- Support the `environment`, `binding`, `timeout`, and `max_clients` options when using `rage s` (#52).
- Add CORS middleware (#49).

### Fixed

- Prevent `block` and `sleep` channels from conflicting (#51).

## [0.5.2] - 2023-12-11

### Added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Check out in-depth API docs for more information:
- [Routing API](https://rage-rb.pages.dev/Rage/Router/DSL/Handler)
- [Fiber API](https://rage-rb.pages.dev/Fiber)
- [Logger API](https://rage-rb.pages.dev/Rage/Logger)
- [Configuration API](https://rage-rb.pages.dev/Rage/Configuration)

Also, see the [changelog](https://github.com/rage-rb/rage/blob/master/CHANGELOG.md) and [upcoming-releases](https://github.com/rage-rb/rage#upcoming-releases) for currently supported and planned features.

Expand Down
2 changes: 1 addition & 1 deletion lib/rage-rb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def self.configure(&)
end

def self.env
@__env ||= Rage::Env.new(ENV["RAGE_ENV"] || ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
@__env ||= Rage::Env.new(ENV["RAGE_ENV"])
end

def self.groups
Expand Down
9 changes: 8 additions & 1 deletion lib/rage/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def new(path)
def server
return help("server") if options.help?

ENV["RAGE_ENV"] = options[:environment] || "development"
set_env(options)

app = ::Rack::Builder.parse_file("config.ru")
app = app[0] if app.is_a?(Array)
Expand All @@ -49,6 +49,7 @@ def routes
# GET / application#index

# load config/application.rb
set_env(options)
environment

routes = Rage.__router.routes
Expand Down Expand Up @@ -101,6 +102,8 @@ def routes
def console
return help("console") if options.help?

set_env(options)

require "irb"
environment
ARGV.clear
Expand All @@ -112,6 +115,10 @@ def console
def environment
require File.expand_path("config/application.rb", Dir.pwd)
end

def set_env(options)
ENV["RAGE_ENV"] = options[:environment] || ENV["RAGE_ENV"] || ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
end
end

class NewAppGenerator < Thor::Group
Expand Down
2 changes: 1 addition & 1 deletion lib/rage/controller/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def after_action(action_name = nil, **opts, &block)
# skip_before_action :find_photo, only: :create
def skip_before_action(action_name, only: nil, except: nil)
i = @__before_actions&.find_index { |a| a[:name] == action_name }
raise Rage::Errors::RouterError, "The following action was specified to be skipped but couldn't be found: #{self}##{action_name}" unless i
raise "The following action was specified to be skipped but couldn't be found: #{self}##{action_name}" unless i
@__before_actions = @__before_actions.dup if @__before_actions.frozen?
Expand Down
4 changes: 2 additions & 2 deletions lib/rage/logger/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class Rage::Logger
# @param shift_period_suffix [String] the log file suffix format for daily, weekly or monthly rotation
# @param binmode sets whether the logger writes in binary mode
def initialize(log, level: Logger::DEBUG, formatter: Rage::TextFormatter.new, shift_age: 0, shift_size: 104857600, shift_period_suffix: "%Y%m%d", binmode: false)
if log && log != File::NULL
@logdev = Logger::LogDevice.new(log, shift_age:, shift_size:, shift_period_suffix:, binmode:)
@logdev = if log && log != File::NULL
Logger::LogDevice.new(log, shift_age:, shift_size:, shift_period_suffix:, binmode:)
end

@formatter = formatter
Expand Down
1 change: 1 addition & 0 deletions lib/rage/middleware/cors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def allow(*origins, methods: "*", allow_headers: "*", expose_headers: nil, max_a
origins.each do |origin|
if origin == "*"
@origins = "*"
break
elsif origin.is_a?(Regexp) || origin =~ /^\S+:\/\//
@origins << origin
else
Expand Down
2 changes: 1 addition & 1 deletion lib/rage/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Rage
VERSION = "0.5.2"
VERSION = "0.6.0"
end
12 changes: 12 additions & 0 deletions spec/cors_middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
end
end

context "with mixed origins" do
let(:cors) do
described_class.new(app) do
allow "*", "localhost:3000"
end
end

it "sets correct headers" do
expect(subject).to eq([200, { "Access-Control-Allow-Origin" => "http://localhost:3000" }, ["test response"]])
end
end

context "with matching origins" do
let(:cors) do
described_class.new(app) do
Expand Down

0 comments on commit 7243ca6

Please sign in to comment.