deas 0.20.0 → 0.21.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.
- data/lib/deas/url.rb +1 -1
- data/lib/deas/version.rb +1 -1
- data/test/unit/router_tests.rb +6 -0
- data/test/unit/url_tests.rb +9 -3
- metadata +4 -7
- data/lib/deas/plugin.rb +0 -38
- data/test/unit/plugin_tests.rb +0 -95
data/lib/deas/url.rb
CHANGED
data/lib/deas/version.rb
CHANGED
data/test/unit/router_tests.rb
CHANGED
|
@@ -146,6 +146,12 @@ class Deas::Router
|
|
|
146
146
|
assert_equal exp_path, subject.url_for(:get_info, 'now')
|
|
147
147
|
end
|
|
148
148
|
|
|
149
|
+
should "'squash' duplicate forward-slashes when building urls" do
|
|
150
|
+
exp_path = "/info/now"
|
|
151
|
+
assert_equal exp_path, subject.url_for(:get_info, :for => '/now')
|
|
152
|
+
assert_equal exp_path, subject.url_for(:get_info, '/now')
|
|
153
|
+
end
|
|
154
|
+
|
|
149
155
|
should "complain if building a named url that hasn't been defined" do
|
|
150
156
|
assert_raises ArgumentError do
|
|
151
157
|
subject.url_for(:get_all_info, 'now')
|
data/test/unit/url_tests.rb
CHANGED
|
@@ -73,9 +73,6 @@ class Deas::Url
|
|
|
73
73
|
|
|
74
74
|
exp_path = "/goose/a/well/*"
|
|
75
75
|
assert_equal exp_path, subject.path_for('a', 'well', 'some' => 'goose')
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
should "pass on this" do
|
|
79
76
|
|
|
80
77
|
exp_path = "/a/goose/cooked/well"
|
|
81
78
|
assert_equal exp_path, subject.path_for('ignore', 'these', 'params', {
|
|
@@ -85,6 +82,15 @@ class Deas::Url
|
|
|
85
82
|
})
|
|
86
83
|
end
|
|
87
84
|
|
|
85
|
+
should "'squash' duplicate forward-slashes" do
|
|
86
|
+
exp_path = "/a/goose/cooked/well/"
|
|
87
|
+
assert_equal exp_path, subject.path_for({
|
|
88
|
+
'some' => '/a',
|
|
89
|
+
:thing => '/goose',
|
|
90
|
+
'splat' => ['///cooked', 'well//']
|
|
91
|
+
})
|
|
92
|
+
end
|
|
93
|
+
|
|
88
94
|
end
|
|
89
95
|
|
|
90
96
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: deas
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 75
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
8
|
+
- 21
|
|
9
9
|
- 0
|
|
10
|
-
version: 0.
|
|
10
|
+
version: 0.21.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Kelly Redding
|
|
@@ -16,7 +16,7 @@ autorequire:
|
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date: 2013-07-
|
|
19
|
+
date: 2013-07-24 00:00:00 Z
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
22
22
|
name: ns-options
|
|
@@ -148,7 +148,6 @@ files:
|
|
|
148
148
|
- lib/deas/error_handler.rb
|
|
149
149
|
- lib/deas/exceptions.rb
|
|
150
150
|
- lib/deas/logging.rb
|
|
151
|
-
- lib/deas/plugin.rb
|
|
152
151
|
- lib/deas/rack_request_fix.rb
|
|
153
152
|
- lib/deas/redirect_proxy.rb
|
|
154
153
|
- lib/deas/route.rb
|
|
@@ -188,7 +187,6 @@ files:
|
|
|
188
187
|
- test/unit/error_handler_tests.rb
|
|
189
188
|
- test/unit/exceptions_tests.rb
|
|
190
189
|
- test/unit/logging_tests.rb
|
|
191
|
-
- test/unit/plugin_tests.rb
|
|
192
190
|
- test/unit/redirect_proxy_tests.rb
|
|
193
191
|
- test/unit/route_proxy_tests.rb
|
|
194
192
|
- test/unit/route_tests.rb
|
|
@@ -259,7 +257,6 @@ test_files:
|
|
|
259
257
|
- test/unit/error_handler_tests.rb
|
|
260
258
|
- test/unit/exceptions_tests.rb
|
|
261
259
|
- test/unit/logging_tests.rb
|
|
262
|
-
- test/unit/plugin_tests.rb
|
|
263
260
|
- test/unit/redirect_proxy_tests.rb
|
|
264
261
|
- test/unit/route_proxy_tests.rb
|
|
265
262
|
- test/unit/route_tests.rb
|
data/lib/deas/plugin.rb
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
module Deas
|
|
2
|
-
module Plugin
|
|
3
|
-
|
|
4
|
-
# use the Plugin mixin to define your own custom plugins you want to mixin
|
|
5
|
-
# on your Deas view handlers. Define included hooks using `plugin_included`.
|
|
6
|
-
# this allows you to define multiple hooks separately and ensures the hooks
|
|
7
|
-
# will only be called once - even if your plugin is mixed in multiple times.
|
|
8
|
-
|
|
9
|
-
def self.included(receiver)
|
|
10
|
-
receiver.class_eval do
|
|
11
|
-
extend ClassMethods
|
|
12
|
-
|
|
13
|
-
# install an included hook that first checks if this plugin has
|
|
14
|
-
# already been installed on the reciever. If it has not been,
|
|
15
|
-
# class eval each callback on the receiver.
|
|
16
|
-
|
|
17
|
-
def self.included(plugin_receiver)
|
|
18
|
-
return if self.deas_plugin_receivers.include?(plugin_receiver)
|
|
19
|
-
|
|
20
|
-
self.deas_plugin_receivers.push(plugin_receiver)
|
|
21
|
-
self.deas_plugin_included_hooks.each do |hook|
|
|
22
|
-
plugin_receiver.class_eval(&hook)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
module ClassMethods
|
|
30
|
-
|
|
31
|
-
def deas_plugin_receivers; @plugin_receivers ||= []; end
|
|
32
|
-
def deas_plugin_included_hooks; @plugin_included_hooks ||= []; end
|
|
33
|
-
def plugin_included(&hook); self.deas_plugin_included_hooks << hook; end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
end
|
data/test/unit/plugin_tests.rb
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
require 'assert'
|
|
2
|
-
require 'deas/plugin'
|
|
3
|
-
|
|
4
|
-
module Deas::Plugin
|
|
5
|
-
|
|
6
|
-
class BaseTests < Assert::Context
|
|
7
|
-
TestPlugin = Module.new do
|
|
8
|
-
include Deas::Plugin
|
|
9
|
-
|
|
10
|
-
plugin_included{ inc_hook1 }
|
|
11
|
-
plugin_included{ inc_hook2 }
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
desc "Deas::Plugin"
|
|
15
|
-
setup do
|
|
16
|
-
@receiver = Class.new do
|
|
17
|
-
def self.inc_hook1; @hook1_count ||= 0; @hook1_count += 1; end
|
|
18
|
-
def self.hook1_count; @hook1_count ||= 0; end
|
|
19
|
-
def self.inc_hook2; @hook2_count ||= 0; @hook2_count += 1; end
|
|
20
|
-
def self.hook2_count; @hook2_count ||= 0; end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
@hook1 = proc{ 1 }
|
|
24
|
-
@hook2 = proc{ 2 }
|
|
25
|
-
|
|
26
|
-
@plugin = Module.new{ include Deas::Plugin }
|
|
27
|
-
end
|
|
28
|
-
subject{ @plugin }
|
|
29
|
-
|
|
30
|
-
should have_imeths :deas_plugin_included_hooks, :deas_plugin_receivers
|
|
31
|
-
should have_imeths :plugin_included
|
|
32
|
-
|
|
33
|
-
should "have no plugin_included_hooks by default" do
|
|
34
|
-
assert_empty subject.deas_plugin_included_hooks
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
should "have no plugin_receivers by default" do
|
|
38
|
-
assert_empty subject.deas_plugin_receivers
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
should "append hooks with #plugin_included" do
|
|
42
|
-
subject.plugin_included(&@hook1)
|
|
43
|
-
subject.plugin_included(&@hook2)
|
|
44
|
-
|
|
45
|
-
assert_equal @hook1, subject.deas_plugin_included_hooks.first
|
|
46
|
-
assert_equal @hook2, subject.deas_plugin_included_hooks.last
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
should "call the plugin included hooks when mixed in" do
|
|
50
|
-
assert_equal 0, @receiver.hook1_count
|
|
51
|
-
assert_equal 0, @receiver.hook2_count
|
|
52
|
-
|
|
53
|
-
@receiver.send(:include, BaseTests::TestPlugin)
|
|
54
|
-
|
|
55
|
-
assert_equal 1, @receiver.hook1_count
|
|
56
|
-
assert_equal 1, @receiver.hook2_count
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
should "call hooks once when mixed in multiple times" do
|
|
60
|
-
@receiver.send(:include, BaseTests::TestPlugin)
|
|
61
|
-
|
|
62
|
-
assert_equal 1, @receiver.hook1_count
|
|
63
|
-
assert_equal 1, @receiver.hook2_count
|
|
64
|
-
|
|
65
|
-
@receiver.send(:include, BaseTests::TestPlugin)
|
|
66
|
-
|
|
67
|
-
assert_equal 1, @receiver.hook1_count
|
|
68
|
-
assert_equal 1, @receiver.hook2_count
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
should "call hooks once when mixed in by a 3rd party" do
|
|
72
|
-
third_party = Module.new do
|
|
73
|
-
def self.included(receiver)
|
|
74
|
-
receiver.send(:include, BaseTests::TestPlugin)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
@receiver.send(:include, third_party)
|
|
78
|
-
|
|
79
|
-
assert_equal 1, @receiver.hook1_count
|
|
80
|
-
assert_equal 1, @receiver.hook2_count
|
|
81
|
-
|
|
82
|
-
@receiver.send(:include, BaseTests::TestPlugin)
|
|
83
|
-
|
|
84
|
-
assert_equal 1, @receiver.hook1_count
|
|
85
|
-
assert_equal 1, @receiver.hook2_count
|
|
86
|
-
|
|
87
|
-
@receiver.send(:include, third_party)
|
|
88
|
-
|
|
89
|
-
assert_equal 1, @receiver.hook1_count
|
|
90
|
-
assert_equal 1, @receiver.hook2_count
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
end
|