[DRE-commits] [ruby-rack-mount] 01/03: add 0003-allow-conditions-to-duck-type-as-a-regexp-alike.patch
Cédric Boutillier
boutil at moszumanska.debian.org
Sat Jun 4 14:26:13 UTC 2016
This is an automated email from the git hooks/post-receive script.
boutil pushed a commit to branch master
in repository ruby-rack-mount.
commit 9d5b6ae4cbe7d07dad447bd7ba0f3842d4b3eea5
Author: Cédric Boutillier <boutil at debian.org>
Date: Sat Jun 4 15:56:50 2016 +0200
add 0003-allow-conditions-to-duck-type-as-a-regexp-alike.patch
---
...conditions-to-duck-type-as-a-regexp-alike.patch | 33 ++++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 34 insertions(+)
diff --git a/debian/patches/0003-allow-conditions-to-duck-type-as-a-regexp-alike.patch b/debian/patches/0003-allow-conditions-to-duck-type-as-a-regexp-alike.patch
new file mode 100644
index 0000000..25e7436
--- /dev/null
+++ b/debian/patches/0003-allow-conditions-to-duck-type-as-a-regexp-alike.patch
@@ -0,0 +1,33 @@
+Description: Allow conditions to duck-type as a Regexp-alike
+Author: Bob Aman <bob at sporkmonger.com>
+Origin: https://github.com/sporkmonger/rack-mount/commit/076aa2c47d9a4c081f1e9bcb56a826a9e72bd5c3.patch
+Reviewed-by: Cédric Boutillier <boutil at debian.org>
+Last-Update: 2016-06-04
+
+--- a/lib/rack/mount/code_generation.rb
++++ b/lib/rack/mount/code_generation.rb
+@@ -35,11 +35,20 @@
+ body << 'params = route.defaults.dup'
+
+ conditions = []
+- route.conditions.each do |method, condition|
++ route.conditions.each do |(method, condition)|
+ b = []
+- if condition.is_a?(Regexp)
+- b << "if m = obj.#{method}.match(#{condition.inspect})"
+- b << "matches[:#{method}] = m"
++ if condition.is_a?(Regexp) || condition.respond_to?(:match)
++ if condition.is_a?(Regexp)
++ b << "if m = #{condition.inspect}.match(obj.#{method})"
++ b << "matches[:#{method}] = m"
++ elsif condition.class.instance_method(:match).arity == 1 ||
++ condition.class.instance_method(:match).arity <= -1
++ b << "condition = route.conditions[#{method.inspect}]"
++ b << "if m = condition.match(obj.#{method})"
++ b << "matches[:#{method}] = m"
++ else
++ raise 'unexpected arity for condition\'s :match method'
++ end
+ if (named_captures = route.named_captures[method]) && named_captures.any?
+ b << 'captures = m.captures'
+ b << 'p = nil'
diff --git a/debian/patches/series b/debian/patches/series
index fa44e87..ac7086e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
+0003-allow-conditions-to-duck-type-as-a-regexp-alike.patch
0001-Fix-warning-from-Hash.patch
0002-Fix-Ruby-2.0.0-compatibility.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-rack-mount.git
More information about the Pkg-ruby-extras-commits
mailing list