From deccbd5a3e05c09dafb037fcf6776297d9505dc0 Mon Sep 17 00:00:00 2001 From: Eric Guo Date: Fri, 26 Feb 2016 20:44:23 +0800 Subject: [PATCH] Make `plugin :tmp_restart` behavior correct in Windows. Inspired by below PR. https://github.com/rails-api/active_model_serializers/pull/1014 --- lib/puma/plugin.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/puma/plugin.rb b/lib/puma/plugin.rb index da9b3284..289a0fbc 100644 --- a/lib/puma/plugin.rb +++ b/lib/puma/plugin.rb @@ -58,8 +58,21 @@ module Puma Plugins = PluginRegistry.new class Plugin + # Matches + # "C:/Ruby22/lib/ruby/gems/2.2.0/gems/puma-3.0.1/lib/puma/plugin/tmp_restart.rb:3:in `'" + # AS + # C:/Ruby22/lib/ruby/gems/2.2.0/gems/puma-3.0.1/lib/puma/plugin/tmp_restart.rb + CALLER_FILE = / + \A # start of string + .+ # file path (one or more characters) + (?= # stop previous match when + :\d+ # a colon is followed by one or more digits + :in # followed by a colon followed by in + ) + /x + def self.extract_name(ary) - path = ary.first.split(":").first + path = ary.first[CALLER_FILE] m = %r!puma/plugin/([^/]*)\.rb$!.match(path) return m[1]