Skip to content

Commit a17691c

Browse files
authored
chore: fix the build for ruby 3.0.x
* Add webrick as a dev dependency webrick is no longer a bundled dependency for Ruby 3 and up. * Fix translation errors in Ruby 3.x Ruby 3 is stricter about hashes being used interchangeably with keyword arguments, and will give errors like: ArgumentError: wrong number of arguments (given 2, expected 0..1) Explicitly map options hash to positional argument with ** to fix * Replace Proc.new usage for Ruby 3 Ruby 3 no longer supports Proc.new without a block to mean "the block that was passed to this method". Use an explicit &block instead This commit does not fix as-notifications, on this line: https://github.com/bernd/as-notifications/blob/v1.0.0/lib/as/notifications/fanout.rb#L18 * Update as-notifications to 1.0.2 Since 1.0.2 is now compatible with Ruby 3.0, we have one spec we no longer have to use the Proc.new { } form with. Thanks Bernd!
1 parent 9a6ced4 commit a17691c

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/webmachine/dispatcher/route.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Route
5858
# @yield [req] an optional guard block
5959
# @yieldparam [Request] req the request object
6060
# @see Dispatcher#add_route
61-
def initialize(path_spec, *args)
61+
def initialize(path_spec, *args, &block)
6262
if args.last.is_a? Hash
6363
bindings = args.pop
6464
else
@@ -67,7 +67,7 @@ def initialize(path_spec, *args)
6767

6868
resource = args.pop
6969
guards = args
70-
guards << Proc.new if block_given?
70+
guards << block if block_given?
7171

7272
warn t('match_all_symbol') if path_spec.include? MATCH_ALL_STR
7373

lib/webmachine/translation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Translation
1313
# variables to interpolate.
1414
# @return [String] the interpolated string
1515
def t(key, options={})
16-
::I18n.t(key, options.merge(:scope => :webmachine))
16+
::I18n.t(key, **options.merge(:scope => :webmachine))
1717
end
1818
end
1919
end

webmachine.gemspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ Gem::Specification.new do |gem|
1717

1818
gem.add_runtime_dependency(%q<i18n>, [">= 0.4.0"])
1919
gem.add_runtime_dependency(%q<multi_json>)
20-
gem.add_runtime_dependency(%q<as-notifications>, ["~> 1.0"])
20+
gem.add_runtime_dependency(%q<as-notifications>, [">= 1.0.2", "< 2.0"])
21+
22+
gem.add_development_dependency(%q<webrick>, ["~> 1.7.0"])
2123

2224
ignores = File.read(".gitignore").split(/\r?\n/).reject{ |f| f =~ /^(#.+|\s*)$/ }.map {|f| Dir[f] }.flatten
2325
gem.files = (Dir['**/*','.gitignore'] - ignores).reject {|f| !File.file?(f) }

0 commit comments

Comments
 (0)